@Override public PersistentQueue<T> get() { try { return new PersistentQueue<T>(new ChronicleQueuePersistor<T>(basePath, codec, clearOnStart, deleteOnExit, ChronicleQueueBuilder.vanilla(basePath) .indexBlockSize(indexBlockSize) .synchronous(sync) .dataBlockSize(dataBlockSize))); } catch (IOException e) { throw new IllegalStateException(e.getMessage(), e); } }
long dataOffset = dataBytes.index() * builder.dataBlockSize() + offset; long indexValue = ((long) lastThreadId << INDEX_DATA_OFFSET_BITS) + dataOffset;
this.chronicle = ChronicleQueueBuilder.vanilla(pathToChronicle).cycleLength((int)this.queueRollingInterval).cycleFormat(this.cycleFormat).build(); this.queueConsumer = new DefaultStreamingMessageQueueConsumer(this.getId(), this.chronicle.createTailer(), this.queueWaitStrategy); this.queueProducer = new DefaultStreamingMessageQueueProducer(this.getId(), this.chronicle.createAppender(), this.queueWaitStrategy);
nextSynchronous = builder.synchronous(); capacityAddr = limitAddr; finished = false;
VanillaChronicle(ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder) { this.builder = builder.clone(); this.lifecycleListener = this.builder.fileLifecycleListener(); this.marshallersCache = new ThreadLocal<>(); this.tailerCache = new ThreadLocal<>(); this.appenderCache = new ThreadLocal<>(); this.name = builder.path().getName(); this.dateCache = new VanillaDateCache( builder.path(), builder.cycleFormat(), builder.cycleLength(), builder.cycleTimeZone()); this.indexBlockSizeBits = Maths.intLog2(builder.indexBlockSize()); this.indexBlockSizeMask = -1 >>> -indexBlockSizeBits; this.indexBlockLongsBits = indexBlockSizeBits - 3; this.indexBlockLongsMask = indexBlockSizeMask >>> 3; this.indexCache = new VanillaIndexCache(this.builder, dateCache, indexBlockSizeBits, builder.fileLifecycleListener()); this.dataBlockSizeBits = Maths.intLog2(builder.dataBlockSize()); this.dataBlockSizeMask = -1 >>> -dataBlockSizeBits; this.dataCache = new VanillaDataCache(this.builder, dateCache, dataBlockSizeBits); this.entriesForCycleBits = Maths.intLog2(this.builder.entriesPerCycle()); this.entriesForCycleMask = -1L >>> -entriesForCycleBits; if (!VanillaChronicleUtils.exists(builder.path())) { builder.path().mkdirs(); } }
VanillaIndexCache( @NotNull ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder, @NotNull VanillaDateCache dateCache, int blocksBits, FileLifecycleListener fileLifecycleListener) { this.fileLifecycleListener = fileLifecycleListener; this.baseFile = builder.path(); this.basePath = this.baseFile.getAbsolutePath(); this.blockBits = blocksBits; this.dateCache = dateCache; this.cache = new VanillaMappedCache<>( builder.indexCacheCapacity(), true, builder.cleanupOnClose() ); this.indexFileMap = new LinkedHashMap<IndexKey, File>(32, 1.0f, true) { @Override protected boolean removeEldestEntry(Map.Entry<IndexKey, File> eldest) { return size() >= 32; } }; }
public VanillaChronicleQueueBuilder cycleLength(int cycleLength) { return cycleLength(cycleLength, true); }
VanillaDataCache( @NotNull ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder, @NotNull VanillaDateCache dateCache, int blockBits) { this.fileLifecycleListener = builder.fileLifecycleListener(); this.basePath = builder.path().getAbsolutePath(); this.blockBits = blockBits; this.dateCache = dateCache; this.cache = new VanillaMappedCache<>( builder.dataCacheCapacity(), true, builder.cleanupOnClose() ); }
public static VanillaChronicleQueueBuilder vanilla(File path) { return new VanillaChronicleQueueBuilder(path); }
public int cycle() { return (int) (System.currentTimeMillis() / builder.cycleLength()); }
public VanillaChronicleQueueBuilder cycle(VanillaChronicle.Cycle cycle) { cycleFormat(cycle.format()); cycleLength(cycle.length(), false); entriesPerCycle(cycle.entries()); return this; }
public VanillaAppenderImpl() { this.lastCycle = Integer.MIN_VALUE; this.lastThreadId = Integer.MIN_VALUE; this.lastWrittenIndex = -1; this.appenderCycle = -1; this.nextSynchronous = builder.synchronous(); this.lastDataIndex = 0; this.lastIndexIndex = 0; }