CQ: 4.5.27.
I have created 2 chronicle for one for write (single thread) and other reader (N threads) reading same file using single chronicleReader.
SingleChronicleQueue chronicleWriter = chronicleFactory.createChronicle("Writer", path, RollCycles.MINUTELY);
SingleChronicleQueue chronicleReader = chronicleFactory.createChronicle("Reader", path, RollCycles.MINUTELY);
public class ChronicleFactory {
ChronicleProcessorImpl chronicleProcessor = new ChronicleProcessorImpl();
public SingleChronicleQueue createChronicle(String instance, String persistenceDir, RollCycles rollCycles) {
SingleChronicleQueue chronicle = null;
try {
chronicle = SingleChronicleQueueBuilder.binary(persistenceDir).rollCycle(rollCycles).storeFileListener(new StoreFileListener() {
@Override
public void onReleased(int i, File file) {
System.out.println(Thread.currentThread().getName() + " onReleased called for file: " + file.getAbsolutePath());
//chronicleProcessor.onRead(file);
}
@Override
public void onAcquired(int cycle, File file) {
System.out.println( Thread.currentThread().getName() + " onAcquired called for file: " + file.getAbsolutePath());
}
}).build();
} catch (Exception e) {
e.printStackTrace();
}
return chronicle;
}
}
When and how many times StoreFileListener onRelease gets called for Reader (N thread with their own tailer)? In beginning I am registering number of interested readers and once I receive equal number of release signal I mark file for deletion. But I have seen onAcquired and onReleased occurs multiple times on the same file for Reader.
What I understood onReleased should only happen once when a chronicle file is read completely.
Can I use same chronicleReader for multiple reads? And how many release events will I get if I have multiple reader on same chronicle? Is it also possible a file is released by reader but still a writer is writing on the same file?