public static void cleanup(SingleChronicleQueue queue, Long lastReadIndex) {
RollingResourcesCache cache = new RollingResourcesCache(queue.rollCycle(), queue.epoch(), (name) -> new File(queue.file().getAbsolutePath(), name + SingleChronicleQueue.SUFFIX));
ExcerptTailer reader = queue.createTailer();
if (reader.moveToIndex(lastReadIndex)) {
Long lastCleanableTime = cache.resourceFor(reader.cycle()).millis;
Long loadedResourceTime = cache.resourceFor(reader.toStart().cycle()).millis;
while(lastCleanableTime > loadedResourceTime) {
RollingResourcesCache.Resource currentResource = cache.resourceFor(reader.toStart().cycle());
loadedResourceTime = currentResource.millis;
log("deleting file => " + currentResource.path);
currentResource.path.delete();
}
} else {
log("Bug!! Didn't move to index: "+ lastReadIndex);
}
}
--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Note that you will not be able to remove your file in the StoreFileListener if you are using Windows. There is an open issue on this.