VanillaIndexCache implements Closeable { int lastIndexFile(int cycle) { return lastIndexFile(cycle, 0); } VanillaIndexCache(@NotNull String basePath, int blockBits, @NotNull DateCache dateCache);  VanillaIndexCache(@NotNull String basePath, int blockBits, @NotNull DateCache dateCache, @NotNull VanillaChronicleConfig config);  VanillaIndexCache(@NotNull String basePath, int blockBits, @NotNull DateCache dateCache, int capacity);  VanillaIndexCache(@NotNull String basePath, int blockBits, @NotNull DateCache dateCache, int capacity, boolean cleanupOnClose); File fileFor(int cycle, int indexCount, boolean forAppend); synchronized VanillaMappedBytes indexFor(int cycle, int indexCount, boolean forAppend); @Override synchronized void close(); VanillaMappedBytes append(int cycle, long indexValue, boolean synchronous, long[] position); static long append(final VanillaMappedBytes bytes, final long indexValue, final boolean synchronous); static long countIndices(final VanillaMappedBytes buffer); long firstCycle(); long lastCycle(); void checkCounts(int min, int max);  }
@Test public void testLastIndexFile() throws Exception { final String baseDir = getTestPath(); assertNotNull(baseDir); final DateCache dateCache = new DateCache("yyyyMMddHHmmss", 1000); final VanillaIndexCache cache = new VanillaIndexCache(baseDir, 10 + 3, dateCache); final int cycle = (int) (System.currentTimeMillis() / 1000); try { assertEquals(0, cache.lastIndexFile(cycle)); final VanillaMappedBytes vanillaBuffer0 = cache.indexFor(cycle, 0, true); assertEquals("index-0", cache.fileFor(cycle, 0, true).getName()); vanillaBuffer0.release(); assertEquals(0, cache.lastIndexFile(cycle)); final VanillaMappedBytes vanillaBuffer1 = cache.indexFor(cycle, 1, true); assertEquals("index-1", cache.fileFor(cycle, 1, true).getName()); vanillaBuffer1.release(); assertEquals(1, cache.lastIndexFile(cycle)); final VanillaMappedBytes vanillaBuffer3 = cache.indexFor(cycle, 3, true); assertEquals("index-3", cache.fileFor(cycle, 3, true).getName()); vanillaBuffer3.release(); assertEquals(3, cache.lastIndexFile(cycle)); cache.checkCounts(1, 1); } finally { cache.close(); IOTools.deleteDir(baseDir); assertFalse(new File(baseDir).exists()); } }