Search in sources :

Example 1 with FRAME_ALIGNMENT

use of io.aeron.logbuffer.FrameDescriptor.FRAME_ALIGNMENT in project Aeron by real-logic.

the class ManageRecordingHistoryTest method shouldMigrateSegmentsForStreamNotSegmentAligned.

@Test
@InterruptAfter(10)
void shouldMigrateSegmentsForStreamNotSegmentAligned() throws IOException {
    final int initialTermId = 7;
    final long targetPosition = (SEGMENT_LENGTH * 3L) + 1;
    final long startPosition = (TERM_LENGTH * 2L) + (FRAME_ALIGNMENT * 2L);
    uriBuilder.initialPosition(startPosition, initialTermId, TERM_LENGTH);
    try (Publication publication = aeronArchive.addRecordedExclusivePublication(uriBuilder.build(), STREAM_ID)) {
        final CountersReader counters = aeron.countersReader();
        final int dstCounterId = awaitRecordingCounterId(counters, publication.sessionId());
        final long dstRecordingId = RecordingPos.getRecordingId(counters, dstCounterId);
        offerToPosition(publication, "dst-message-", targetPosition);
        awaitPosition(counters, dstCounterId, publication.position());
        aeronArchive.stopRecording(publication);
        final long segmentFileBasePosition = AeronArchive.segmentFileBasePosition(startPosition, startPosition + (SEGMENT_LENGTH * 2L), TERM_LENGTH, SEGMENT_LENGTH);
        final long purgedSegments = aeronArchive.purgeSegments(dstRecordingId, segmentFileBasePosition);
        assertEquals(2L, purgedSegments);
        assertEquals(segmentFileBasePosition, aeronArchive.getStartPosition(dstRecordingId));
        final long srcRecordingId;
        final String migrateChannel = uriBuilder.initialPosition(startPosition, initialTermId, TERM_LENGTH).endpoint("localhost:4444").build();
        try (Publication migratePub = aeronArchive.addRecordedExclusivePublication(migrateChannel, STREAM_ID)) {
            final int srcCounterId = awaitRecordingCounterId(counters, migratePub.sessionId());
            srcRecordingId = RecordingPos.getRecordingId(counters, srcCounterId);
            offerToPosition(migratePub, "src-message-", segmentFileBasePosition);
            awaitPosition(counters, srcCounterId, migratePub.position());
            aeronArchive.stopRecording(migratePub);
        }
        final File archiveDir = archive.context().archiveDir();
        final String srcPrefix = srcRecordingId + "-";
        final String[] srcFiles = archiveDir.list((dir, name) -> name.startsWith(srcPrefix));
        assertThat(srcFiles, arrayContainingInAnyOrder(Archive.segmentFileName(srcRecordingId, SEGMENT_LENGTH), Archive.segmentFileName(srcRecordingId, SEGMENT_LENGTH * 2L), Archive.segmentFileName(srcRecordingId, SEGMENT_LENGTH * 3L)));
        final String dstPrefix = dstRecordingId + "-";
        String[] dstFiles = archiveDir.list((dir, name) -> name.startsWith(dstPrefix));
        assertThat(dstFiles, arrayContaining(Archive.segmentFileName(dstRecordingId, segmentFileBasePosition)));
        final byte[] srcBytes = Files.readAllBytes(new File(archiveDir, Archive.segmentFileName(srcRecordingId, segmentFileBasePosition)).toPath());
        assertEquals(SEGMENT_LENGTH, srcBytes.length);
        final byte[] dstBytes = Files.readAllBytes(new File(archiveDir, Archive.segmentFileName(dstRecordingId, segmentFileBasePosition)).toPath());
        assertEquals(SEGMENT_LENGTH, dstBytes.length);
        assertThat(srcBytes, not(equalTo(dstBytes)));
        final long migratedSegments = aeronArchive.migrateSegments(srcRecordingId, dstRecordingId);
        assertEquals(2L, migratedSegments);
        assertEquals(startPosition, aeronArchive.getStartPosition(dstRecordingId));
        assertEquals(startPosition, aeronArchive.getStopPosition(srcRecordingId));
        Tests.await(() -> {
            final String[] files = archiveDir.list((dir, name) -> name.startsWith(srcPrefix));
            return null != files && 0 == files.length;
        });
        dstFiles = archiveDir.list((dir, name) -> name.startsWith(dstPrefix));
        assertThat(dstFiles, arrayContainingInAnyOrder(Archive.segmentFileName(dstRecordingId, SEGMENT_LENGTH), Archive.segmentFileName(dstRecordingId, SEGMENT_LENGTH * 2L), Archive.segmentFileName(dstRecordingId, SEGMENT_LENGTH * 3L)));
        final byte[] migratedBytes = Files.readAllBytes(new File(archiveDir, Archive.segmentFileName(dstRecordingId, segmentFileBasePosition)).toPath());
        assertArrayEquals(dstBytes, migratedBytes);
    }
}
Also used : SystemTestWatcher(io.aeron.test.SystemTestWatcher) Tests(io.aeron.test.Tests) BeforeEach(org.junit.jupiter.api.BeforeEach) FRAME_ALIGNMENT(io.aeron.logbuffer.FrameDescriptor.FRAME_ALIGNMENT) CountersReader(org.agrona.concurrent.status.CountersReader) RecordingSignalAdapter(io.aeron.archive.client.RecordingSignalAdapter) RecordingSignalConsumer(io.aeron.archive.client.RecordingSignalConsumer) MutableReference(org.agrona.collections.MutableReference) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) ChannelUriStringBuilder(io.aeron.ChannelUriStringBuilder) AeronArchive(io.aeron.archive.client.AeronArchive) ArchiveSystemTests(io.aeron.archive.ArchiveSystemTests) RecordingSignal(io.aeron.archive.codecs.RecordingSignal) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Publication(io.aeron.Publication) TestMediaDriver(io.aeron.test.driver.TestMediaDriver) Path(java.nio.file.Path) CloseHelper(org.agrona.CloseHelper) RecordingPos(io.aeron.archive.status.RecordingPos) MediaDriver(io.aeron.driver.MediaDriver) Aeron(io.aeron.Aeron) InterruptingTestCallback(io.aeron.test.InterruptingTestCallback) Files(java.nio.file.Files) StandardOpenOption(java.nio.file.StandardOpenOption) Matchers(org.hamcrest.Matchers) IOException(java.io.IOException) LogBufferDescriptor(io.aeron.logbuffer.LogBufferDescriptor) File(java.io.File) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter) AfterEach(org.junit.jupiter.api.AfterEach) ThreadingMode(io.aeron.driver.ThreadingMode) TempDir(org.junit.jupiter.api.io.TempDir) Assertions(org.junit.jupiter.api.Assertions) Publication(io.aeron.Publication) File(java.io.File) CountersReader(org.agrona.concurrent.status.CountersReader) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 2 with FRAME_ALIGNMENT

use of io.aeron.logbuffer.FrameDescriptor.FRAME_ALIGNMENT in project Aeron by real-logic.

the class ManageRecordingHistoryTest method shouldMigrateSegmentsForStreamJoinedAtTheBeginning.

@Test
@InterruptAfter(10)
void shouldMigrateSegmentsForStreamJoinedAtTheBeginning() throws IOException {
    final long targetPosition = (SEGMENT_LENGTH * 3L) + 1;
    try (Publication publication = aeronArchive.addRecordedPublication(uriBuilder.build(), STREAM_ID)) {
        final CountersReader counters = aeron.countersReader();
        final int dstCounterId = awaitRecordingCounterId(counters, publication.sessionId());
        final long dstRecordingId = RecordingPos.getRecordingId(counters, dstCounterId);
        offerToPosition(publication, "dst-message-", targetPosition);
        awaitPosition(counters, dstCounterId, publication.position());
        aeronArchive.stopRecording(publication);
        final long startPosition = 0L;
        final long migratePosition = AeronArchive.segmentFileBasePosition(startPosition, SEGMENT_LENGTH * 2L, TERM_LENGTH, SEGMENT_LENGTH);
        final long count = aeronArchive.purgeSegments(dstRecordingId, migratePosition);
        assertEquals(2L, count);
        assertEquals(migratePosition, aeronArchive.getStartPosition(dstRecordingId));
        final long srcRecordingId;
        final String migrateChannel = uriBuilder.initialPosition(startPosition, publication.initialTermId(), TERM_LENGTH).endpoint("localhost:4444").build();
        try (Publication migratePub = aeronArchive.addRecordedExclusivePublication(migrateChannel, STREAM_ID)) {
            final int srcCounterId = awaitRecordingCounterId(counters, migratePub.sessionId());
            srcRecordingId = RecordingPos.getRecordingId(counters, srcCounterId);
            offerToPosition(migratePub, "src-message-", SEGMENT_LENGTH * 4 + TERM_LENGTH + FRAME_ALIGNMENT);
            awaitPosition(counters, srcCounterId, migratePub.position());
            aeronArchive.stopRecording(migratePub);
        }
        aeronArchive.truncateRecording(srcRecordingId, migratePosition);
        final File archiveDir = archive.context().archiveDir();
        final String srcPrefix = srcRecordingId + "-";
        Tests.await(() -> {
            final String[] srcFiles = archiveDir.list((dir, name) -> name.startsWith(srcPrefix));
            if (null != srcFiles && 2 == srcFiles.length) {
                assertThat(srcFiles, arrayContainingInAnyOrder(Archive.segmentFileName(srcRecordingId, 0), Archive.segmentFileName(srcRecordingId, SEGMENT_LENGTH)));
                return true;
            }
            return false;
        });
        final Path srcFile = new File(archiveDir, Archive.segmentFileName(srcRecordingId, migratePosition) + ".del").toPath();
        Files.write(srcFile, new byte[] { 0x1, 0x2, 0x3 }, StandardOpenOption.CREATE_NEW);
        final String dstPrefix = dstRecordingId + "-";
        String[] dstFiles = archiveDir.list((dir, name) -> name.startsWith(dstPrefix));
        assertThat(dstFiles, arrayContainingInAnyOrder(Archive.segmentFileName(dstRecordingId, SEGMENT_LENGTH * 2L), Archive.segmentFileName(dstRecordingId, SEGMENT_LENGTH * 3L)));
        final Path dstFile = new File(archiveDir, Archive.segmentFileName(dstRecordingId, migratePosition)).toPath();
        final byte[] dstBytes = Files.readAllBytes(dstFile);
        assertEquals(SEGMENT_LENGTH, dstBytes.length);
        final long migratedSegments = aeronArchive.migrateSegments(srcRecordingId, dstRecordingId);
        assertEquals(2L, migratedSegments);
        assertEquals(startPosition, aeronArchive.getStartPosition(dstRecordingId));
        Tests.await(() -> {
            final String[] srcFiles = archiveDir.list((dir, name) -> name.startsWith(srcPrefix));
            return null != srcFiles && 0 == srcFiles.length;
        });
        dstFiles = archiveDir.list((dir, name) -> name.startsWith(dstPrefix));
        assertThat(dstFiles, arrayContainingInAnyOrder(Archive.segmentFileName(dstRecordingId, 0), Archive.segmentFileName(dstRecordingId, SEGMENT_LENGTH), Archive.segmentFileName(dstRecordingId, SEGMENT_LENGTH * 2L), Archive.segmentFileName(dstRecordingId, SEGMENT_LENGTH * 3L)));
        final byte[] migratedBytes = Files.readAllBytes(dstFile);
        assertArrayEquals(dstBytes, migratedBytes);
    }
}
Also used : Path(java.nio.file.Path) SystemTestWatcher(io.aeron.test.SystemTestWatcher) Tests(io.aeron.test.Tests) BeforeEach(org.junit.jupiter.api.BeforeEach) FRAME_ALIGNMENT(io.aeron.logbuffer.FrameDescriptor.FRAME_ALIGNMENT) CountersReader(org.agrona.concurrent.status.CountersReader) RecordingSignalAdapter(io.aeron.archive.client.RecordingSignalAdapter) RecordingSignalConsumer(io.aeron.archive.client.RecordingSignalConsumer) MutableReference(org.agrona.collections.MutableReference) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) ChannelUriStringBuilder(io.aeron.ChannelUriStringBuilder) AeronArchive(io.aeron.archive.client.AeronArchive) ArchiveSystemTests(io.aeron.archive.ArchiveSystemTests) RecordingSignal(io.aeron.archive.codecs.RecordingSignal) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Publication(io.aeron.Publication) TestMediaDriver(io.aeron.test.driver.TestMediaDriver) Path(java.nio.file.Path) CloseHelper(org.agrona.CloseHelper) RecordingPos(io.aeron.archive.status.RecordingPos) MediaDriver(io.aeron.driver.MediaDriver) Aeron(io.aeron.Aeron) InterruptingTestCallback(io.aeron.test.InterruptingTestCallback) Files(java.nio.file.Files) StandardOpenOption(java.nio.file.StandardOpenOption) Matchers(org.hamcrest.Matchers) IOException(java.io.IOException) LogBufferDescriptor(io.aeron.logbuffer.LogBufferDescriptor) File(java.io.File) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter) AfterEach(org.junit.jupiter.api.AfterEach) ThreadingMode(io.aeron.driver.ThreadingMode) TempDir(org.junit.jupiter.api.io.TempDir) Assertions(org.junit.jupiter.api.Assertions) Publication(io.aeron.Publication) File(java.io.File) CountersReader(org.agrona.concurrent.status.CountersReader) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 3 with FRAME_ALIGNMENT

use of io.aeron.logbuffer.FrameDescriptor.FRAME_ALIGNMENT in project Aeron by real-logic.

the class ArchiveToolTests method verifyAllOptionsTruncateOnPageStraddle.

@Test
void verifyAllOptionsTruncateOnPageStraddle() {
    final Checksum checksum = crc32();
    try (Catalog catalog = openCatalogReadWrite(archiveDir, epochClock, MIN_CAPACITY, checksum, null)) {
        catalog.forEach((recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> catalog.updateChecksum(recordingDescriptorOffset));
    }
    assertFalse(verify(out, archiveDir, allOf(VerifyOption.class), checksum, epochClock, (file) -> true));
    try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
        assertRecording(catalog, invalidRecording0, INVALID, -119969720, NULL_POSITION, NULL_POSITION, 1, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording1, INVALID, 768794941, FRAME_ALIGNMENT - 7, NULL_POSITION, 2, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording2, INVALID, -1340428433, 1024, FRAME_ALIGNMENT * 2, 3, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording3, INVALID, 1464972620, 0, FRAME_ALIGNMENT * 5 + 11, 4, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording4, INVALID, 21473288, SEGMENT_LENGTH, NULL_POSITION, 5, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording5, INVALID, -2119992405, 0, SEGMENT_LENGTH, 6, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording6, INVALID, 2054096463, 0, NULL_POSITION, 7, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording7, INVALID, -1050175867, 0, NULL_POSITION, 8, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording8, INVALID, -504693275, 0, NULL_POSITION, 9, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording9, INVALID, -2036430506, 0, NULL_POSITION, 10, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording10, INVALID, -414736820, 128, NULL_POSITION, 11, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording11, INVALID, 1983095657, 0, NULL_POSITION, 12, NULL_TIMESTAMP, 5, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording12, INVALID, -1308504240, 0, NULL_POSITION, 13, NULL_TIMESTAMP, 9, 6, "ch1", "src1");
        assertRecording(catalog, invalidRecording13, INVALID, -273182324, 0, NULL_POSITION, 14, NULL_TIMESTAMP, 0, 13, "ch1", "src1");
        assertRecording(catalog, invalidRecording14, INVALID, 213018412, 128, NULL_POSITION, -14, 41, -14, 0, "ch1", "src1");
        assertRecording(catalog, validRecording0, VALID, 356725588, 0, TERM_LENGTH + 64, 15, 100, 0, 2, "ch2", "src2");
        assertRecording(catalog, validRecording1, VALID, -1571032591, 1024, 1024, 16, 200, 0, 2, "ch2", "src2");
        assertRecording(catalog, validRecording2, VALID, 114203747, TERM_LENGTH * 3 + 96, TERM_LENGTH * 3 + 96, 17, 300, 0, 2, "ch2", "src2");
        assertRecording(catalog, validRecording3, INVALID, 963969455, 7 * TERM_LENGTH + 96, 7 * TERM_LENGTH + 128, 18, NULL_TIMESTAMP, 7, 13, "ch2", "src2");
        assertRecording(catalog, validRecording4, INVALID, 162247708, 21 * TERM_LENGTH + (TERM_LENGTH - 64), 22 * TERM_LENGTH + 992, 19, 1, -25, 7, "ch2", "src2");
        assertRecording(catalog, validRecording51, VALID, -940881948, 0, 64 + PAGE_SIZE, 20, 777, 0, 20, "ch2", "src2");
        assertRecording(catalog, validRecording52, INVALID, 1046083782, 0, NULL_POSITION, 21, NULL_TIMESTAMP, 0, 52, "ch2", "src2");
        assertRecording(catalog, validRecording53, INVALID, 428178649, 0, NULL_POSITION, 22, NULL_TIMESTAMP, 0, 53, "ch2", "src2");
        assertRecording(catalog, validRecording6, VALID, -175549265, 352, 960, 23, 400, 0, 6, "ch2", "src2");
    }
    Mockito.verify(out, times(24)).println(any(String.class));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Arrays(java.util.Arrays) FRAME_ALIGNMENT(io.aeron.logbuffer.FrameDescriptor.FRAME_ALIGNMENT) RECORDING_SEGMENT_SUFFIX(io.aeron.archive.Archive.Configuration.RECORDING_SEGMENT_SUFFIX) Catalog(io.aeron.archive.Catalog) IoUtil(org.agrona.IoUtil) ByteBuffer(java.nio.ByteBuffer) ArrayList(java.util.ArrayList) READ(java.nio.file.StandardOpenOption.READ) ByteBuffer.allocate(java.nio.ByteBuffer.allocate) Files.createTempDirectory(java.nio.file.Files.createTempDirectory) EnumSet.allOf(java.util.EnumSet.allOf) AeronArchive(io.aeron.archive.client.AeronArchive) Path(java.nio.file.Path) WRITE(java.nio.file.StandardOpenOption.WRITE) MethodSource(org.junit.jupiter.params.provider.MethodSource) PrintStream(java.io.PrintStream) MutableBoolean(org.agrona.collections.MutableBoolean) LogBufferDescriptor.positionBitsToShift(io.aeron.logbuffer.LogBufferDescriptor.positionBitsToShift) ArchiveTool(io.aeron.archive.ArchiveTool) Collections.emptySet(java.util.Collections.emptySet) VERIFY_ALL_SEGMENT_FILES(io.aeron.archive.ArchiveTool.VerifyOption.VERIFY_ALL_SEGMENT_FILES) IOException(java.io.IOException) Mockito.times(org.mockito.Mockito.times) Checksum(io.aeron.archive.checksum.Checksum) Arguments(org.junit.jupiter.params.provider.Arguments) File(java.io.File) Mockito(org.mockito.Mockito) INVALID(io.aeron.archive.codecs.RecordingState.INVALID) VALID(io.aeron.archive.codecs.RecordingState.VALID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) List(java.util.List) Collections.addAll(java.util.Collections.addAll) org.junit.jupiter.api(org.junit.jupiter.api) Executable(org.junit.jupiter.api.function.Executable) APPLY_CHECKSUM(io.aeron.archive.ArchiveTool.VerifyOption.APPLY_CHECKSUM) EnumSet.of(java.util.EnumSet.of) Assertions(org.junit.jupiter.api.Assertions) RecordingState(io.aeron.archive.codecs.RecordingState) EpochClock(org.agrona.concurrent.EpochClock) DataHeaderFlyweight(io.aeron.protocol.DataHeaderFlyweight) Checksums.crc32(io.aeron.archive.checksum.Checksums.crc32) Archive.segmentFileName(io.aeron.archive.Archive.segmentFileName) FileChannel(java.nio.channels.FileChannel) Files.deleteIfExists(java.nio.file.Files.deleteIfExists) LogBufferDescriptor.computeTermIdFromPosition(io.aeron.logbuffer.LogBufferDescriptor.computeTermIdFromPosition) Checksum(io.aeron.archive.checksum.Checksum) Catalog(io.aeron.archive.Catalog) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with FRAME_ALIGNMENT

use of io.aeron.logbuffer.FrameDescriptor.FRAME_ALIGNMENT in project Aeron by real-logic.

the class ArchiveToolTests method verifyNoOptionsDoNotTruncateOnPageStraddle.

@Test
void verifyNoOptionsDoNotTruncateOnPageStraddle() {
    assertFalse(verify(out, archiveDir, emptySet(), null, epochClock, (file) -> false));
    try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
        assertRecording(catalog, invalidRecording0, INVALID, 0, NULL_POSITION, NULL_POSITION, 1, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording1, INVALID, 0, FRAME_ALIGNMENT - 7, NULL_POSITION, 2, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording2, INVALID, 0, 1024, FRAME_ALIGNMENT * 2, 3, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording3, INVALID, 0, 0, FRAME_ALIGNMENT * 5 + 11, 4, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording4, INVALID, 0, SEGMENT_LENGTH, NULL_POSITION, 5, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording5, INVALID, 0, 0, SEGMENT_LENGTH, 6, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording6, INVALID, 0, 0, NULL_POSITION, 7, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording7, INVALID, 0, 0, NULL_POSITION, 8, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording8, INVALID, 0, 0, NULL_POSITION, 9, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording9, INVALID, 0, 0, NULL_POSITION, 10, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording10, INVALID, 0, 128, NULL_POSITION, 11, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording11, INVALID, 0, 0, NULL_POSITION, 12, NULL_TIMESTAMP, 5, 1, "ch1", "src1");
        assertRecording(catalog, invalidRecording12, INVALID, 0, 0, NULL_POSITION, 13, NULL_TIMESTAMP, 9, 6, "ch1", "src1");
        assertRecording(catalog, invalidRecording13, INVALID, 0, 0, NULL_POSITION, 14, NULL_TIMESTAMP, 0, 13, "ch1", "src1");
        assertRecording(catalog, invalidRecording14, INVALID, 0, 128, NULL_POSITION, -14, 41, -14, 0, "ch1", "src1");
        assertRecording(catalog, validRecording0, VALID, 0, 0, TERM_LENGTH + 64, 15, 100, 0, 2, "ch2", "src2");
        assertRecording(catalog, validRecording1, VALID, 0, 1024, 1024, 16, 200, 0, 2, "ch2", "src2");
        assertRecording(catalog, validRecording2, VALID, 0, TERM_LENGTH * 3 + 96, TERM_LENGTH * 3 + 96, 17, 300, 0, 2, "ch2", "src2");
        assertRecording(catalog, validRecording3, VALID, 0, 7 * TERM_LENGTH + 96, 11 * TERM_LENGTH + 320, 18, 400, 7, 13, "ch2", "src2");
        assertRecording(catalog, validRecording4, VALID, 0, 21 * TERM_LENGTH + (TERM_LENGTH - 64), 22 * TERM_LENGTH + 992, 19, 1, -25, 7, "ch2", "src2");
        assertRecording(catalog, validRecording51, VALID, 0, 0, 64 + PAGE_SIZE, 20, 777, 0, 20, "ch2", "src2");
        assertRecording(catalog, validRecording52, VALID, 0, 0, 128 + MTU_LENGTH, 21, 500, 0, 52, "ch2", "src2");
        assertRecording(catalog, validRecording53, VALID, 0, 0, 64 + 3 * PAGE_SIZE, 22, 600, 0, 53, "ch2", "src2");
        assertRecording(catalog, validRecording6, VALID, 0, 352, 960, 23, 700, 0, 6, "ch2", "src2");
    }
    Mockito.verify(out, times(24)).println(any(String.class));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Arrays(java.util.Arrays) FRAME_ALIGNMENT(io.aeron.logbuffer.FrameDescriptor.FRAME_ALIGNMENT) RECORDING_SEGMENT_SUFFIX(io.aeron.archive.Archive.Configuration.RECORDING_SEGMENT_SUFFIX) Catalog(io.aeron.archive.Catalog) IoUtil(org.agrona.IoUtil) ByteBuffer(java.nio.ByteBuffer) ArrayList(java.util.ArrayList) READ(java.nio.file.StandardOpenOption.READ) ByteBuffer.allocate(java.nio.ByteBuffer.allocate) Files.createTempDirectory(java.nio.file.Files.createTempDirectory) EnumSet.allOf(java.util.EnumSet.allOf) AeronArchive(io.aeron.archive.client.AeronArchive) Path(java.nio.file.Path) WRITE(java.nio.file.StandardOpenOption.WRITE) MethodSource(org.junit.jupiter.params.provider.MethodSource) PrintStream(java.io.PrintStream) MutableBoolean(org.agrona.collections.MutableBoolean) LogBufferDescriptor.positionBitsToShift(io.aeron.logbuffer.LogBufferDescriptor.positionBitsToShift) ArchiveTool(io.aeron.archive.ArchiveTool) Collections.emptySet(java.util.Collections.emptySet) VERIFY_ALL_SEGMENT_FILES(io.aeron.archive.ArchiveTool.VerifyOption.VERIFY_ALL_SEGMENT_FILES) IOException(java.io.IOException) Mockito.times(org.mockito.Mockito.times) Checksum(io.aeron.archive.checksum.Checksum) Arguments(org.junit.jupiter.params.provider.Arguments) File(java.io.File) Mockito(org.mockito.Mockito) INVALID(io.aeron.archive.codecs.RecordingState.INVALID) VALID(io.aeron.archive.codecs.RecordingState.VALID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) List(java.util.List) Collections.addAll(java.util.Collections.addAll) org.junit.jupiter.api(org.junit.jupiter.api) Executable(org.junit.jupiter.api.function.Executable) APPLY_CHECKSUM(io.aeron.archive.ArchiveTool.VerifyOption.APPLY_CHECKSUM) EnumSet.of(java.util.EnumSet.of) Assertions(org.junit.jupiter.api.Assertions) RecordingState(io.aeron.archive.codecs.RecordingState) EpochClock(org.agrona.concurrent.EpochClock) DataHeaderFlyweight(io.aeron.protocol.DataHeaderFlyweight) Checksums.crc32(io.aeron.archive.checksum.Checksums.crc32) Archive.segmentFileName(io.aeron.archive.Archive.segmentFileName) FileChannel(java.nio.channels.FileChannel) Files.deleteIfExists(java.nio.file.Files.deleteIfExists) LogBufferDescriptor.computeTermIdFromPosition(io.aeron.logbuffer.LogBufferDescriptor.computeTermIdFromPosition) Catalog(io.aeron.archive.Catalog) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

AeronArchive (io.aeron.archive.client.AeronArchive)4 FRAME_ALIGNMENT (io.aeron.logbuffer.FrameDescriptor.FRAME_ALIGNMENT)4 File (java.io.File)4 IOException (java.io.IOException)4 Path (java.nio.file.Path)4 Assertions (org.junit.jupiter.api.Assertions)4 Aeron (io.aeron.Aeron)2 ChannelUriStringBuilder (io.aeron.ChannelUriStringBuilder)2 Publication (io.aeron.Publication)2 RECORDING_SEGMENT_SUFFIX (io.aeron.archive.Archive.Configuration.RECORDING_SEGMENT_SUFFIX)2 Archive.segmentFileName (io.aeron.archive.Archive.segmentFileName)2 ArchiveSystemTests (io.aeron.archive.ArchiveSystemTests)2 ArchiveTool (io.aeron.archive.ArchiveTool)2 APPLY_CHECKSUM (io.aeron.archive.ArchiveTool.VerifyOption.APPLY_CHECKSUM)2 VERIFY_ALL_SEGMENT_FILES (io.aeron.archive.ArchiveTool.VerifyOption.VERIFY_ALL_SEGMENT_FILES)2 Catalog (io.aeron.archive.Catalog)2 Checksum (io.aeron.archive.checksum.Checksum)2 Checksums.crc32 (io.aeron.archive.checksum.Checksums.crc32)2 RecordingSignalAdapter (io.aeron.archive.client.RecordingSignalAdapter)2 RecordingSignalConsumer (io.aeron.archive.client.RecordingSignalConsumer)2