use of io.aeron.archive.Catalog.PAGE_SIZE in project aeron by real-logic.
the class CatalogTest method shouldFixTimestampAndPositionAfterFailurePageStraddle.
@Test
public void shouldFixTimestampAndPositionAfterFailurePageStraddle() throws Exception {
final long newRecordingId = newRecording();
final File segmentFile = new File(archiveDir, segmentFileName(newRecordingId, 0));
try (FileChannel log = FileChannel.open(segmentFile.toPath(), READ, WRITE, CREATE)) {
final ByteBuffer bb = ByteBuffer.allocateDirect(HEADER_LENGTH);
final DataHeaderFlyweight flyweight = new DataHeaderFlyweight(bb);
flyweight.frameLength(PAGE_SIZE - 32);
log.write(bb);
bb.clear();
flyweight.frameLength(128);
log.write(bb, PAGE_SIZE - 32);
bb.clear();
flyweight.frameLength(0);
log.write(bb, PAGE_SIZE - 32 + 128);
}
try (Catalog catalog = new Catalog(archiveDir, clock)) {
catalog.forEntry((he, hd, e, decoder) -> {
assertThat(decoder.stopTimestamp(), is(NULL_TIMESTAMP));
assertThat(decoder.stopPosition(), is(NULL_POSITION));
}, newRecordingId);
}
currentTimeMs = 42L;
try (Catalog catalog = new Catalog(archiveDir, null, 0, MAX_ENTRIES, clock)) {
assertTrue(catalog.forEntry((he, hd, e, decoder) -> {
assertThat(decoder.stopTimestamp(), is(42L));
assertThat(decoder.stopPosition(), is((long) PAGE_SIZE - 32));
}, newRecordingId));
}
}
Aggregations