use of net.openhft.chronicle.queue.impl.CommonStore in project Chronicle-Queue by OpenHFT.
the class FsFullReadTest method testFullReadFs.
@Ignore("broken test")
@Test
public void testFullReadFs() throws Exception {
SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(basePath).blockSize(256 << 1000).rollCycle(RollCycles.DAILY).build();
ExcerptTailer tailer = queue.createTailer();
DocumentContext dc = tailer.readingDocument();
boolean doExit = false;
int entries = 0;
while (!doExit) {
try {
if (dc.isPresent()) {
entries++;
Wire w = dc.wire();
LocalDateTime dt = w.read().dateTime();
assertNotNull(dt);
byte[] b = w.read().bytes();
assertEquals(1024, b.length);
} else {
System.out.println("Exiting");
doExit = true;
}
} finally {
dc.close();
}
}
System.out.println(String.format("Read %d entries.", entries));
CommonStore commonStore = queue.storeForCycle(queue.cycle(), 0, false);
File file = commonStore.file();
queue.close();
int dumpEntries = 0;
try {
MappedBytes bytes = MappedBytes.mappedBytes(file, 4 << 20);
bytes.readLimit(bytes.realCapacity());
WireDumper dumper = WireDumper.of(bytes);
Bytes<ByteBuffer> buffer = Bytes.elasticByteBuffer();
while (bytes.readRemaining() >= 4) {
StringBuilder sb = new StringBuilder();
boolean last = dumper.dumpOne(sb, buffer);
assertTrue(sb.length() > 0);
if (last)
break;
dumpEntries++;
}
} catch (IOException ioe) {
err.println("Failed to read " + file + " " + ioe);
}
assertEquals(dumpEntries, entries);
}
Aggregations