use of io.aeron.archive.Catalog in project Aeron by real-logic.
the class CatalogTest method findLastReturnsNullRecordingIdIfRecordingIsInTheInvalidState.
@Test
void findLastReturnsNullRecordingIdIfRecordingIsInTheInvalidState() {
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
assertTrue(catalog.invalidateRecording(recordingOneId));
assertEquals(NULL_RECORD_ID, catalog.findLast(0, 6, 1, "channelG?tag=f".getBytes(US_ASCII)));
}
}
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 growCatalogThrowsArchiveExceptionIfRecordingIsTooBig.
@Test
void growCatalogThrowsArchiveExceptionIfRecordingIsTooBig() {
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
final ArchiveException exception = assertThrows(ArchiveException.class, () -> catalog.growCatalog(CAPACITY * 2, Integer.MAX_VALUE));
assertEquals("ERROR - recording is too big: total recording length is " + Integer.MAX_VALUE + " bytes, available space is " + (CAPACITY * 2 - 800) + " bytes", exception.getMessage());
}
}
use of io.aeron.archive.Catalog in project Aeron by real-logic.
the class CatalogTest method shouldGrowCatalogWhenMaxCapacityReached.
@Test
void shouldGrowCatalogWhenMaxCapacityReached() {
after();
final File archiveDir = ArchiveTests.makeTestDirectory();
try (Catalog catalog = new Catalog(archiveDir, null, 0, MIN_CAPACITY, clock, null, segmentFileBuffer)) {
for (int i = 0; i < 4; 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(4, catalog.entryCount());
assertEquals(819, catalog.capacity());
}
}
use of io.aeron.archive.Catalog in project Aeron by real-logic.
the class CatalogTest method shouldThrowIllegalArgumentExceptionIfCatalogCapacityIsLessThanMinimalCapacity.
@ParameterizedTest
@ValueSource(longs = { -1, 0, MIN_CAPACITY - 1 })
void shouldThrowIllegalArgumentExceptionIfCatalogCapacityIsLessThanMinimalCapacity(final long capacity) {
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> new Catalog(archiveDir, null, 0, capacity, clock, null, segmentFileBuffer));
assertEquals("Invalid catalog capacity provided: expected value >= " + MIN_CAPACITY + ", got " + capacity, exception.getMessage());
}
Aggregations