use of io.aeron.archive.Catalog in project Aeron by real-logic.
the class CatalogTest method before.
@BeforeEach
void before() {
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
recordingOneId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 6, 1, "channelG", "channelG?tag=f", "sourceA");
recordingTwoId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 7, 2, "channelH", "channelH?tag=f", "sourceV");
recordingThreeId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 8, 3, "channelThatIsVeryLongAndShouldNotBeTruncated", "channelThatIsVeryLongAndShouldNotBeTruncated?tag=f", "source can also be a very very very long String and it will not be truncated even " + "if gets very very long");
}
}
use of io.aeron.archive.Catalog in project Aeron by real-logic.
the class CatalogTest method growCatalogThrowsArchiveExceptionIfCatalogIsFull.
@Test
void growCatalogThrowsArchiveExceptionIfCatalogIsFull() {
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
final ArchiveException exception = assertThrows(ArchiveException.class, () -> catalog.growCatalog(CAPACITY, (int) (CAPACITY + 1)));
assertEquals("ERROR - catalog is full, max capacity reached: " + CAPACITY, exception.getMessage());
}
}
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 findLastReturnsLastFoundRecordingMatchingGivenCriteria.
@Test
void findLastReturnsLastFoundRecordingMatchingGivenCriteria() {
final int sessionId = 6;
final int streamId = 1;
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
final long recordingF = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, sessionId, streamId, "F", "channelG?tag=f", "sourceA");
catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, sessionId, streamId, "X", "channelG?tag=x", "sourceA");
catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, sessionId, streamId + 1, "F", "channelG?tag=f", "sourceA");
catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, sessionId + 1, streamId, "F", "channelG?tag=f", "sourceA");
assertEquals(recordingF, catalog.findLast(recordingOneId, sessionId, streamId, "channelG?tag=f".getBytes(US_ASCII)));
}
}
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