use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method shouldNotGrowCatalogWhenReachingFullIfRecordingsFit.
@Test
void shouldNotGrowCatalogWhenReachingFullIfRecordingsFit() {
after();
final File archiveDir = ArchiveTests.makeTestDirectory();
final long capacity = 384 + CatalogHeaderEncoder.BLOCK_LENGTH;
try (Catalog catalog = new Catalog(archiveDir, null, 0, capacity, clock, null, segmentFileBuffer)) {
for (int i = 0; i < 2; i++) {
recordingOneId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 6, 1, "channelG", "channelG?tag=f", "sourceA");
}
}
try (Catalog catalog = new Catalog(archiveDir, clock)) {
assertEquals(2, catalog.entryCount());
assertEquals(capacity, catalog.capacity());
}
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method shouldComputeChecksumOfTheRecordingDescriptorUponAddingToTheCatalog.
@Test
void shouldComputeChecksumOfTheRecordingDescriptorUponAddingToTheCatalog() {
final Checksum checksum = crc32();
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, checksum, segmentFileBuffer)) {
final long recordingId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 6, 1, "channelNew", "channelNew?tag=X", "sourceX");
final long recordingId2 = catalog.addNewRecording(1, 100, 2, 222, 111, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 16, 12, "channelNew2", "channelNew?tag=X2", "sourceX2");
catalog.forEach((recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> {
if (recordingId == descriptorDecoder.recordingId()) {
assertEquals(1691549102, headerDecoder.checksum());
} else if (recordingId2 == descriptorDecoder.recordingId()) {
assertEquals(1452384985, headerDecoder.checksum());
} else {
assertEquals(0, headerDecoder.checksum());
}
});
}
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method shouldFixTimestampForEmptyRecordingAfterFailure.
@Test
void shouldFixTimestampForEmptyRecordingAfterFailure() {
final long newRecordingId = newRecording();
try (Catalog catalog = new Catalog(archiveDir, clock)) {
final CatalogEntryProcessor entryProcessor = (recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> assertEquals(NULL_TIMESTAMP, descriptorDecoder.stopTimestamp());
assertTrue(catalog.forEntry(newRecordingId, entryProcessor));
}
currentTimeMs = 42L;
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
final CatalogEntryProcessor entryProcessor = (recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> assertEquals(42L, descriptorDecoder.stopTimestamp());
assertTrue(catalog.forEntry(newRecordingId, entryProcessor));
}
}
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 growCatalogShouldNotExceedMaxCatalogCapacity.
@Test
void growCatalogShouldNotExceedMaxCatalogCapacity() {
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
final long maxCatalogCapacity = CAPACITY * 1024;
catalog.growCatalog(maxCatalogCapacity, (int) (maxCatalogCapacity - 10_000));
assertEquals(maxCatalogCapacity, catalog.capacity());
}
}
Aggregations