use of io.aeron.archive.Catalog in project aeron by real-logic.
the class ArchiveToolTests method verifyNoOptionsDoNotTruncateOnPageStraddle.
@Test
void verifyNoOptionsDoNotTruncateOnPageStraddle() {
assertFalse(verify(out, archiveDir, emptySet(), null, epochClock, (file) -> false));
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, invalidRecording0, INVALID, 0, NULL_POSITION, NULL_POSITION, 1, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording1, INVALID, 0, FRAME_ALIGNMENT - 7, NULL_POSITION, 2, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording2, INVALID, 0, 1024, FRAME_ALIGNMENT * 2, 3, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording3, INVALID, 0, 0, FRAME_ALIGNMENT * 5 + 11, 4, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording4, INVALID, 0, SEGMENT_LENGTH, NULL_POSITION, 5, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording5, INVALID, 0, 0, SEGMENT_LENGTH, 6, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording6, INVALID, 0, 0, NULL_POSITION, 7, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording7, INVALID, 0, 0, NULL_POSITION, 8, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording8, INVALID, 0, 0, NULL_POSITION, 9, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording9, INVALID, 0, 0, NULL_POSITION, 10, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording10, INVALID, 0, 128, NULL_POSITION, 11, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording11, INVALID, 0, 0, NULL_POSITION, 12, NULL_TIMESTAMP, 5, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording12, INVALID, 0, 0, NULL_POSITION, 13, NULL_TIMESTAMP, 9, 6, "ch1", "src1");
assertRecording(catalog, invalidRecording13, INVALID, 0, 0, NULL_POSITION, 14, NULL_TIMESTAMP, 0, 13, "ch1", "src1");
assertRecording(catalog, invalidRecording14, INVALID, 0, 128, NULL_POSITION, -14, 41, -14, 0, "ch1", "src1");
assertRecording(catalog, validRecording0, VALID, 0, 0, TERM_LENGTH + 64, 15, 100, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording1, VALID, 0, 1024, 1024, 16, 200, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording2, VALID, 0, TERM_LENGTH * 3 + 96, TERM_LENGTH * 3 + 96, 17, 300, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording3, VALID, 0, 7 * TERM_LENGTH + 96, 11 * TERM_LENGTH + 320, 18, 400, 7, 13, "ch2", "src2");
assertRecording(catalog, validRecording4, VALID, 0, 21 * TERM_LENGTH + (TERM_LENGTH - 64), 22 * TERM_LENGTH + 992, 19, 1, -25, 7, "ch2", "src2");
assertRecording(catalog, validRecording51, VALID, 0, 0, 64 + PAGE_SIZE, 20, 777, 0, 20, "ch2", "src2");
assertRecording(catalog, validRecording52, VALID, 0, 0, 128 + MTU_LENGTH, 21, 500, 0, 52, "ch2", "src2");
assertRecording(catalog, validRecording53, VALID, 0, 0, 64 + 3 * PAGE_SIZE, 22, 600, 0, 53, "ch2", "src2");
assertRecording(catalog, validRecording6, VALID, 0, 352, 960, 23, 700, 0, 6, "ch2", "src2");
}
Mockito.verify(out, times(24)).println(any(String.class));
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class ArchiveToolTests method checksumRecordingLastSegmentFile.
@Test
void checksumRecordingLastSegmentFile() {
checksumRecording(out, archiveDir, validRecording3, false, crc32(), epochClock);
assertTrue(verifyRecording(out, archiveDir, validRecording3, of(APPLY_CHECKSUM), crc32(), epochClock, (file) -> false));
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, validRecording3, VALID, 963969455, 7 * TERM_LENGTH + 96, 11 * TERM_LENGTH + 320, 18, 100, 7, 13, "ch2", "src2");
}
verifyRecording(out, archiveDir, validRecording3, allOf(VerifyOption.class), crc32(), epochClock, (file) -> false);
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, validRecording3, INVALID, 963969455, 7 * TERM_LENGTH + 96, 11 * TERM_LENGTH + 320, 18, 100, 7, 13, "ch2", "src2");
}
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class ArchiveToolTests method capacityIncreasesCapacityOfTheCatalog.
@Test
void capacityIncreasesCapacityOfTheCatalog() {
final long capacity;
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
capacity = catalog.capacity();
}
assertEquals(capacity * 2, capacity(archiveDir, capacity * 2));
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method shouldThrowArchiveExceptionIfNextRecordingIdIsInvalidWriteableCatalog.
@Test
void shouldThrowArchiveExceptionIfNextRecordingIdIsInvalidWriteableCatalog() throws IOException {
setNextRecordingId(-1);
final ArchiveException exception = assertThrows(ArchiveException.class, () -> new Catalog(archiveDir, clock, MIN_CAPACITY, true, null, null));
assertEquals("ERROR - invalid nextRecordingId: expected value greater or equal to " + (recordingThreeId + 1) + ", was -1", exception.getMessage());
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method shouldContainChannelFragment.
@Test
void shouldContainChannelFragment() {
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
final String originalChannel = "aeron:udp?endpoint=localhost:7777|tags=777|alias=TestString";
final String strippedChannel = "strippedChannelUri";
final long recordingId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 6, 1, strippedChannel, originalChannel, "sourceA");
assertTrue(catalog.wrapDescriptor(recordingId, unsafeBuffer));
recordingDescriptorDecoder.wrap(unsafeBuffer, RecordingDescriptorHeaderDecoder.BLOCK_LENGTH, RecordingDescriptorDecoder.BLOCK_LENGTH, RecordingDescriptorDecoder.SCHEMA_VERSION);
assertTrue(originalChannelContains(recordingDescriptorDecoder, ArrayUtil.EMPTY_BYTE_ARRAY));
final byte[] originalChannelBytes = originalChannel.getBytes(US_ASCII);
assertTrue(originalChannelContains(recordingDescriptorDecoder, originalChannelBytes));
final byte[] tagsBytes = "tags=777".getBytes(US_ASCII);
assertTrue(originalChannelContains(recordingDescriptorDecoder, tagsBytes));
final byte[] testBytes = "TestString".getBytes(US_ASCII);
assertTrue(originalChannelContains(recordingDescriptorDecoder, testBytes));
final byte[] wrongBytes = "wrong".getBytes(US_ASCII);
assertFalse(originalChannelContains(recordingDescriptorDecoder, wrongBytes));
}
}
Aggregations