public VanillaMappedBytes put(T key, File path, long size) throws IOException { return put(key,path,size,-1); }
public void checkCounts(int min, int max) { this.cache.checkCounts(min, max); }
@Override public synchronized void close() { this.cache.close(); }
public synchronized VanillaMappedBytes indexFor(int cycle, int indexCount, boolean forAppend) throws IOException { key.cycle = cycle; key.indexCount = indexCount << blockBits; VanillaMappedBytes vmb = this.cache.get(key); if(vmb == null) { vmb = this.cache.put( key.clone(), VanillaChronicleUtils.mkFiles( basePath, dateCache.formatFor(cycle), FILE_NAME_PREFIX + indexCount, forAppend), 1L << blockBits, indexCount); } vmb.reserve(); return vmb; }
public VanillaIndexCache(@NotNull String basePath, int blockBits, @NotNull DateCache dateCache, int capacity, boolean cleanupOnClose) { this.basePath = basePath; this.baseFile = new File(basePath); this.blockBits = blockBits; this.dateCache = dateCache; this.cache = new VanillaMappedCache<IndexKey>(capacity, true, cleanupOnClose); }
public synchronized VanillaMappedBytes dataFor(int cycle, int threadId, int dataCount, boolean forWrite) throws IOException { key.cycle = cycle; key.threadId = threadId; key.dataCount = dataCount; VanillaMappedBytes vmb = this.cache.get(key); if(vmb == null) { vmb = this.cache.put( key.clone(), VanillaChronicleUtils.mkFiles( basePath, dateCache.formatFor(cycle), FILE_NAME_PREFIX + threadId + "-" + dataCount, forWrite), 1L << blockBits, dataCount); } vmb.reserve(); return vmb; }
public VanillaDataCache(@NotNull String basePath, int blockBits, @NotNull DateCache dateCache, int capacity, boolean cleanupOnClose) { this.basePath = basePath; this.blockBits = blockBits; this.dateCache = dateCache; this.cache = new VanillaMappedCache<DataKey>(capacity, true, cleanupOnClose); }
public synchronized VanillaMappedBytes dataFor(int cycle, int threadId, int dataCount, boolean forWrite) throws IOException { key.cycle = cycle; key.threadId = threadId; key.dataCount = dataCount; VanillaMappedBytes vmb = this.cache.get(key); if (vmb == null || vmb.refCount() < 1) { long start = System.nanoTime(); File file = VanillaChronicleUtils.mkFiles( dateCache.valueFor(cycle).path, FILE_NAME_PREFIX + threadId + "-" + dataCount, forWrite); vmb = this.cache.put(key.clone(), file, 1L << blockBits, dataCount); fileLifecycleListener.onEvent(EventType.NEW, file, System.nanoTime() - start); } vmb.reserve(); return vmb; }
public VanillaMappedBytes put(T key, File path, long size) throws IOException { return put(key, path, size, -1); }
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() ); }
@Override public synchronized void close() { this.cache.close(); }
public void checkCounts(int min, int max) { this.cache.checkCounts(min, max); }
public synchronized VanillaMappedBytes indexFor(int cycle, int indexCount, boolean forAppend) throws IOException { key.cycle = cycle; key.indexCount = indexCount; VanillaMappedBytes vmb = this.cache.get(key); if (vmb == null) { File file = this.indexFileMap.get(key); if (file == null) { this.indexFileMap.put( key.clone(), file = indexFileFor(cycle, indexCount, dateCache) ); } long start = System.nanoTime(); File parent = file.getParentFile(); if (forAppend && !VanillaChronicleUtils.exists(parent)) { parent.mkdirs(); } if (!forAppend && !VanillaChronicleUtils.exists(file)) { return null; } vmb = this.cache.put(key.clone(), file, 1L << blockBits, indexCount); fileLifecycleListener.onEvent(EventType.NEW, file, System.nanoTime() - start); } vmb.reserve(); return vmb; }
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; } }; }
@Override public synchronized void close() { this.cache.close(); }
public void checkCounts(int min, int max) { this.cache.checkCounts(min,max); }
@Override public synchronized void close() { this.cache.close(); }
public void checkCounts(int min, int max) { this.cache.checkCounts(min,max); }