Search in sources :

Example 91 with Catalog

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

the class CatalogTest method shouldAllowMultipleInstancesForSameStream.

@Test
void shouldAllowMultipleInstancesForSameStream() {
    try (Catalog catalog = new Catalog(archiveDir, clock)) {
        assertEquals(CAPACITY, catalog.capacity());
        final long newRecordingId = newRecording();
        assertNotEquals(recordingOneId, newRecordingId);
    }
}
Also used : Catalog(io.aeron.archive.Catalog) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 92 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 93 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 94 with Catalog

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

the class CatalogTest method shouldReadNextRecordingIdFromCatalogHeader.

@Test
void shouldReadNextRecordingIdFromCatalogHeader() throws IOException {
    final long nextRecordingId = 10101010;
    setNextRecordingId(nextRecordingId);
    try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
        assertEquals(nextRecordingId, catalog.nextRecordingId());
    }
}
Also used : Catalog(io.aeron.archive.Catalog) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 95 with Catalog

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

the class ArchiveTool method dump.

/**
 * Dump the contents of an {@link Archive} so it can be inspected or debugged. Each recording will have its
 * contents dumped up to fragmentCountLimit before requesting to continue.
 *
 * @param out                               to which the contents will be printed.
 * @param archiveDir                        containing the {@link Archive}.
 * @param fragmentCountLimit                limit of data fragments to print from each recording before continue.
 * @param confirmActionOnFragmentCountLimit confirm continue to dump at limit.
 */
public static void dump(final PrintStream out, final File archiveDir, final long fragmentCountLimit, final ActionConfirmation<Long> confirmActionOnFragmentCountLimit) {
    try (Catalog catalog = openCatalogReadOnly(archiveDir, INSTANCE);
        ArchiveMarkFile markFile = openMarkFile(archiveDir, out::println)) {
        printMarkInformation(markFile, out);
        out.println("Catalog capacity in bytes: " + catalog.capacity());
        out.println();
        out.println("Dumping up to " + fragmentCountLimit + " fragments per recording");
        catalog.forEach((recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> dump(out, archiveDir, catalog, fragmentCountLimit, confirmActionOnFragmentCountLimit, headerDecoder, descriptorDecoder));
    }
}
Also used : Catalog(io.aeron.archive.Catalog)

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