public VanillaTailerImpl() throws IOException { this.fsWatchEnabled = builder.enableFsWatcher(); this.fsWatch = fsWatchEnabled ? FileSystems.getDefault().newWatchService() : null; this.fsWatchPath = fsWatchEnabled ? builder.path().toPath() : null; this.fsWatchKey = null; }
void checkNotClosed() { if (closed) { throw new IllegalStateException(builder.path() + " is closed"); } }
@Override public void clear() { indexCache.close(); dataCache.close(); IOTools.deleteDir(builder.path().getAbsolutePath()); }
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; } }; }
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() ); }