Search in sources :

Example 6 with Catalog

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)));
    }
}
Also used : Catalog(io.aeron.archive.Catalog) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with Catalog

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());
    }
}
Also used : File(java.io.File) Catalog(io.aeron.archive.Catalog) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with Catalog

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());
    }
}
Also used : ArchiveException(io.aeron.archive.client.ArchiveException) Catalog(io.aeron.archive.Catalog) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with Catalog

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());
    }
}
Also used : File(java.io.File) Catalog(io.aeron.archive.Catalog) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with Catalog

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());
}
Also used : Catalog(io.aeron.archive.Catalog) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Catalog (io.aeron.archive.Catalog)98 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)78 Test (org.junit.jupiter.api.Test)52 File (java.io.File)44 Checksum (io.aeron.archive.checksum.Checksum)40 ByteBuffer (java.nio.ByteBuffer)36 FileChannel (java.nio.channels.FileChannel)36 DataHeaderFlyweight (io.aeron.protocol.DataHeaderFlyweight)34 IOException (java.io.IOException)34 INVALID (io.aeron.archive.codecs.RecordingState.INVALID)30 VALID (io.aeron.archive.codecs.RecordingState.VALID)30 EpochClock (org.agrona.concurrent.EpochClock)30 Archive.segmentFileName (io.aeron.archive.Archive.segmentFileName)26 Checksums.crc32 (io.aeron.archive.checksum.Checksums.crc32)26 ByteBuffer.allocate (java.nio.ByteBuffer.allocate)26 IoUtil (org.agrona.IoUtil)26 Assertions (org.junit.jupiter.api.Assertions)26 Arguments (org.junit.jupiter.params.provider.Arguments)26 MethodSource (org.junit.jupiter.params.provider.MethodSource)26 Path (java.nio.file.Path)24