use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method testInvalidateRecording.
private void testInvalidateRecording(final long recordingId) {
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
final int entries = catalog.entryCount();
assertTrue(catalog.wrapDescriptor(recordingId, unsafeBuffer));
recordingDescriptorHeaderDecoder.wrap(unsafeBuffer, 0, RecordingDescriptorHeaderDecoder.BLOCK_LENGTH, RecordingDescriptorHeaderDecoder.SCHEMA_VERSION);
assertTrue(catalog.invalidateRecording(recordingId));
assertEquals(INVALID, recordingDescriptorHeaderDecoder.state());
assertEquals(entries - 1, catalog.entryCount());
assertFalse(catalog.hasRecording(recordingId));
}
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method recordingStoppedShouldUpdateChecksum.
@Test
void recordingStoppedShouldUpdateChecksum() {
final Checksum checksum = crc32();
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, checksum, segmentFileBuffer)) {
assertChecksum(catalog, recordingOneId, 0);
catalog.recordingStopped(recordingOneId, 140, 231723682323L);
assertChecksum(catalog, recordingOneId, 1656993099);
}
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method shouldThrowExceptionAfterFailureOnPageStraddle.
@Test
void shouldThrowExceptionAfterFailureOnPageStraddle() 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);
log.write(bb, PAGE_SIZE - 128);
bb.clear();
bb.put(0, (byte) 0).limit(1).position(0);
log.write(bb, PAGE_SIZE + 127);
}
final ArchiveException exception = assertThrows(ArchiveException.class, () -> {
final Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer);
catalog.close();
});
assertThat(exception.getMessage(), containsString(segmentFile.getAbsolutePath()));
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method shouldThrowArchiveExceptionIfNextRecordingIdIsSmallerThanTheActualLastRecordInTheCatalog.
@Test
void shouldThrowArchiveExceptionIfNextRecordingIdIsSmallerThanTheActualLastRecordInTheCatalog() throws IOException {
setNextRecordingId(recordingTwoId);
final ArchiveException exception = assertThrows(ArchiveException.class, () -> new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer));
assertEquals("ERROR - invalid nextRecordingId: expected value greater or equal to " + (recordingThreeId + 1) + ", was " + recordingTwoId, exception.getMessage());
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method shouldAppendToExistingIndex.
@Test
void shouldAppendToExistingIndex() {
final long newRecordingId;
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, () -> 3L, null, segmentFileBuffer)) {
newRecordingId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 9, 4, "channelJ", "channelJ?tag=f", "sourceN");
}
try (Catalog catalog = new Catalog(archiveDir, clock)) {
verifyRecordingForId(catalog, recordingOneId, 160, 6, 1, "channelG", "sourceA");
verifyRecordingForId(catalog, newRecordingId, 160, 9, 4, "channelJ", "sourceN");
}
}
Aggregations