use of io.aeron.protocol.DataHeaderFlyweight.HEADER_LENGTH in project Aeron by real-logic.
the class CatalogTest method shouldUseChecksumToVerifyLastFragmentAfterPageStraddle.
@Test
void shouldUseChecksumToVerifyLastFragmentAfterPageStraddle() 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 = allocate(HEADER_LENGTH);
final DataHeaderFlyweight flyweight = new DataHeaderFlyweight(bb);
flyweight.frameLength(PAGE_SIZE - 128);
log.write(bb);
bb.clear();
flyweight.frameLength(256);
flyweight.sessionId(1025596259);
log.write(bb, PAGE_SIZE - 128);
bb.clear();
bb.put(0, (byte) 0).limit(1).position(0);
log.write(bb, PAGE_SIZE + 127);
}
currentTimeMs = 42L;
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, crc32(), null)) {
assertTrue(catalog.forEntry(newRecordingId, (recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> {
assertEquals(42L, descriptorDecoder.stopTimestamp());
assertEquals(PAGE_SIZE + 128, descriptorDecoder.stopPosition());
}));
}
}
use of io.aeron.protocol.DataHeaderFlyweight.HEADER_LENGTH in project aeron by real-logic.
the class CatalogTest method shouldUseChecksumToVerifyLastFragmentAfterPageStraddle.
@Test
void shouldUseChecksumToVerifyLastFragmentAfterPageStraddle() 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 = allocate(HEADER_LENGTH);
final DataHeaderFlyweight flyweight = new DataHeaderFlyweight(bb);
flyweight.frameLength(PAGE_SIZE - 128);
log.write(bb);
bb.clear();
flyweight.frameLength(256);
flyweight.sessionId(1025596259);
log.write(bb, PAGE_SIZE - 128);
bb.clear();
bb.put(0, (byte) 0).limit(1).position(0);
log.write(bb, PAGE_SIZE + 127);
}
currentTimeMs = 42L;
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, crc32(), null)) {
assertTrue(catalog.forEntry(newRecordingId, (recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> {
assertEquals(42L, descriptorDecoder.stopTimestamp());
assertEquals(PAGE_SIZE + 128, descriptorDecoder.stopPosition());
}));
}
}
Aggregations