Search in sources :

Example 1 with Checksum

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

the class ArchiveTool method createVerifyEntryProcessor.

private static CatalogEntryProcessor createVerifyEntryProcessor(final PrintStream out, final File archiveDir, final Set<VerifyOption> options, final Catalog catalog, final Checksum checksum, final EpochClock epochClock, final MutableInteger errorCount, final ActionConfirmation<File> truncateOnPageStraddle) {
    final ByteBuffer buffer = BufferUtil.allocateDirectAligned(FILE_IO_MAX_LENGTH_DEFAULT, CACHE_LINE_LENGTH);
    buffer.order(LITTLE_ENDIAN);
    final DataHeaderFlyweight headerFlyweight = new DataHeaderFlyweight(buffer);
    return (recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> verifyRecording(out, archiveDir, options, catalog, checksum, epochClock, errorCount, truncateOnPageStraddle, headerFlyweight, recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder);
}
Also used : CACHE_LINE_LENGTH(org.agrona.BitUtil.CACHE_LINE_LENGTH) MigrationUtils.fullVersionString(io.aeron.archive.MigrationUtils.fullVersionString) NATIVE_BYTE_ORDER(org.agrona.BufferUtil.NATIVE_BYTE_ORDER) IntConsumer(java.util.function.IntConsumer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) ByteBuffer(java.nio.ByteBuffer) FILE_IO_MAX_LENGTH_DEFAULT(io.aeron.archive.Archive.Configuration.FILE_IO_MAX_LENGTH_DEFAULT) org.agrona(org.agrona) Collectors.toMap(java.util.stream.Collectors.toMap) Path(java.nio.file.Path) HDR_TYPE_PAD(io.aeron.protocol.HeaderFlyweight.HDR_TYPE_PAD) NULL_POSITION(io.aeron.archive.client.AeronArchive.NULL_POSITION) LogBufferDescriptor.positionBitsToShift(io.aeron.logbuffer.LogBufferDescriptor.positionBitsToShift) HEADER_LENGTH(io.aeron.protocol.DataHeaderFlyweight.HEADER_LENGTH) VERIFY_ALL_SEGMENT_FILES(io.aeron.archive.ArchiveTool.VerifyOption.VERIFY_ALL_SEGMENT_FILES) StandardOpenOption(java.nio.file.StandardOpenOption) Math.min(java.lang.Math.min) INVALID(io.aeron.archive.codecs.RecordingState.INVALID) VALID(io.aeron.archive.codecs.RecordingState.VALID) Stream(java.util.stream.Stream) LITTLE_ENDIAN(java.nio.ByteOrder.LITTLE_ENDIAN) EpochClock(org.agrona.concurrent.EpochClock) DataHeaderFlyweight(io.aeron.protocol.DataHeaderFlyweight) ReplaySession.isInvalidHeader(io.aeron.archive.ReplaySession.isInvalidHeader) java.util(java.util) Checksums.newInstance(io.aeron.archive.checksum.Checksums.newInstance) Catalog(io.aeron.archive.Catalog) HeaderFlyweight(io.aeron.protocol.HeaderFlyweight) Configuration(io.aeron.driver.Configuration) READ_WRITE(java.nio.channels.FileChannel.MapMode.READ_WRITE) io.aeron.archive.codecs(io.aeron.archive.codecs) MutableInteger(org.agrona.collections.MutableInteger) PrintStream(java.io.PrintStream) FrameDescriptor(io.aeron.logbuffer.FrameDescriptor) Collections.emptySet(java.util.Collections.emptySet) Files(java.nio.file.Files) SESSION_ID_FIELD_OFFSET(io.aeron.protocol.DataHeaderFlyweight.SESSION_ID_FIELD_OFFSET) AeronArchive.segmentFileBasePosition(io.aeron.archive.client.AeronArchive.segmentFileBasePosition) IOException(java.io.IOException) CommonContext(io.aeron.CommonContext) Checksum(io.aeron.archive.checksum.Checksum) AeronException(io.aeron.exceptions.AeronException) File(java.io.File) INSTANCE(org.agrona.concurrent.SystemEpochClock.INSTANCE) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) APPLY_CHECKSUM(io.aeron.archive.ArchiveTool.VerifyOption.APPLY_CHECKSUM) CncFileDescriptor(io.aeron.CncFileDescriptor) MarkFileHeaderDecoder(io.aeron.archive.codecs.mark.MarkFileHeaderDecoder) HDR_TYPE_DATA(io.aeron.protocol.HeaderFlyweight.HDR_TYPE_DATA) FileChannel(java.nio.channels.FileChannel) BitUtil.align(org.agrona.BitUtil.align) CATALOG_FILE_NAME(io.aeron.archive.Archive.Configuration.CATALOG_FILE_NAME) MappedByteBuffer(java.nio.MappedByteBuffer) LogBufferDescriptor.computeTermIdFromPosition(io.aeron.logbuffer.LogBufferDescriptor.computeTermIdFromPosition) DataHeaderFlyweight(io.aeron.protocol.DataHeaderFlyweight) ByteBuffer(java.nio.ByteBuffer) MappedByteBuffer(java.nio.MappedByteBuffer)

Example 2 with Checksum

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

the class ArchiveTest method recordChecksumBufferReturnsValueAssignedIfThreadingModeIsDEDICATED.

@Test
void recordChecksumBufferReturnsValueAssignedIfThreadingModeIsDEDICATED() {
    final UnsafeBuffer buffer = mock(UnsafeBuffer.class);
    final Checksum recordChecksum = mock(Checksum.class);
    final Archive.Context context = new Archive.Context().recordChecksum(recordChecksum).threadingMode(DEDICATED);
    context.recordChecksumBuffer(buffer);
    assertSame(buffer, context.recordChecksumBuffer());
}
Also used : Context(io.aeron.archive.Archive.Context) CommonContext(io.aeron.CommonContext) AeronArchive(io.aeron.archive.client.AeronArchive) Checksum(io.aeron.archive.checksum.Checksum) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) Context(io.aeron.archive.Archive.Context) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with Checksum

use of io.aeron.archive.checksum.Checksum 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 4 with Checksum

use of io.aeron.archive.checksum.Checksum 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)

Example 5 with Checksum

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

the class CatalogTest method stopPositionShouldUpdateChecksum.

@Test
void stopPositionShouldUpdateChecksum() {
    final Checksum checksum = crc32();
    try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, checksum, segmentFileBuffer)) {
        assertChecksum(catalog, recordingTwoId, 0);
        catalog.stopPosition(recordingTwoId, 7777);
        assertChecksum(catalog, recordingTwoId, -1985007076);
    }
}
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

Checksum (io.aeron.archive.checksum.Checksum)18 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 Catalog (io.aeron.archive.Catalog)11 AeronArchive (io.aeron.archive.client.AeronArchive)8 Test (org.junit.jupiter.api.Test)8 INVALID (io.aeron.archive.codecs.RecordingState.INVALID)7 VALID (io.aeron.archive.codecs.RecordingState.VALID)7 File (java.io.File)7 IOException (java.io.IOException)7 ByteBuffer (java.nio.ByteBuffer)7 FileChannel (java.nio.channels.FileChannel)7 EpochClock (org.agrona.concurrent.EpochClock)7 RECORDING_SEGMENT_SUFFIX (io.aeron.archive.Archive.Configuration.RECORDING_SEGMENT_SUFFIX)6 APPLY_CHECKSUM (io.aeron.archive.ArchiveTool.VerifyOption.APPLY_CHECKSUM)6 VERIFY_ALL_SEGMENT_FILES (io.aeron.archive.ArchiveTool.VerifyOption.VERIFY_ALL_SEGMENT_FILES)6 LogBufferDescriptor.computeTermIdFromPosition (io.aeron.logbuffer.LogBufferDescriptor.computeTermIdFromPosition)6 LogBufferDescriptor.positionBitsToShift (io.aeron.logbuffer.LogBufferDescriptor.positionBitsToShift)6 DataHeaderFlyweight (io.aeron.protocol.DataHeaderFlyweight)6 PrintStream (java.io.PrintStream)6 Path (java.nio.file.Path)6