Search in sources :

Example 11 with Catalog

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

Example 12 with Catalog

use of io.aeron.archive.Catalog in project Aeron by real-logic.

the class CatalogTest method shouldReloadExistingIndex.

@Test
void shouldReloadExistingIndex() {
    try (Catalog catalog = new Catalog(archiveDir, clock)) {
        verifyRecordingForId(catalog, recordingOneId, 160, 6, 1, "channelG", "sourceA");
        verifyRecordingForId(catalog, recordingTwoId, 160, 7, 2, "channelH", "sourceV");
        verifyRecordingForId(catalog, recordingThreeId, 352, 8, 3, "channelThatIsVeryLongAndShouldNotBeTruncated", "source can also be a very very very long String and it will not be truncated even " + "if gets very very long");
    }
}
Also used : Catalog(io.aeron.archive.Catalog) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with Catalog

use of io.aeron.archive.Catalog in project Aeron by real-logic.

the class CatalogTest method extendRecordingShouldUpdateChecksum.

@Test
void extendRecordingShouldUpdateChecksum() {
    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");
        assertChecksum(catalog, recordingId, 1691549102);
        catalog.extendRecording(recordingId, 555, 13, 31);
        assertChecksum(catalog, recordingId, -1694749833);
    }
}
Also used : Checksum(io.aeron.archive.checksum.Checksum) Catalog(io.aeron.archive.Catalog) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with Catalog

use of io.aeron.archive.Catalog in project Aeron by real-logic.

the class CatalogTest method shouldAppendToExistingIndex.

@Test
void shouldAppendToExistingIndex() {
    final long newRecordingId;
    try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, () -> 3L, null, segmentFileBuffer)) {
        newRecordingId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 9, 4, "channelJ", "channelJ?tag=f", "sourceN");
    }
    try (Catalog catalog = new Catalog(archiveDir, clock)) {
        verifyRecordingForId(catalog, recordingOneId, 160, 6, 1, "channelG", "sourceA");
        verifyRecordingForId(catalog, newRecordingId, 160, 9, 4, "channelJ", "sourceN");
    }
}
Also used : Catalog(io.aeron.archive.Catalog) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with Catalog

use of io.aeron.archive.Catalog in project Aeron by real-logic.

the class CatalogTest method recordingStoppedShouldUpdateChecksum.

@Test
void recordingStoppedShouldUpdateChecksum() {
    final Checksum checksum = crc32();
    try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, checksum, segmentFileBuffer)) {
        assertChecksum(catalog, recordingOneId, 0);
        catalog.recordingStopped(recordingOneId, 140, 231723682323L);
        assertChecksum(catalog, recordingOneId, 1656993099);
    }
}
Also used : Checksum(io.aeron.archive.checksum.Checksum) Catalog(io.aeron.archive.Catalog) Test(org.junit.jupiter.api.Test) 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