Search in sources :

Example 1 with RecordingDescriptorDecoder

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

the class Catalog method refreshAndFixDescriptor.

private void refreshAndFixDescriptor(final RecordingDescriptorHeaderDecoder headerDecoder, final RecordingDescriptorEncoder encoder, final RecordingDescriptorDecoder decoder, final Checksum checksum, final UnsafeBuffer buffer) {
    final long recordingId = decoder.recordingId();
    if (VALID == headerDecoder.state() && NULL_POSITION == decoder.stopPosition()) {
        final String[] segmentFiles = listSegmentFiles(archiveDir, recordingId);
        final String maxSegmentFile = findSegmentFileWithHighestPosition(segmentFiles);
        encoder.stopPosition(computeStopPosition(archiveDir, maxSegmentFile, decoder.startPosition(), decoder.termBufferLength(), decoder.segmentFileLength(), checksum, buffer, (segmentFile) -> {
            throw new ArchiveException("Found potentially incomplete last fragment straddling page boundary in file: " + segmentFile.getAbsolutePath() + "\nRun `ArchiveTool verify` for corrective action!");
        }));
        encoder.stopTimestamp(epochClock.time());
    }
}
Also used : AsciiEncoding.parseLongAscii(org.agrona.AsciiEncoding.parseLongAscii) RECORDING_SEGMENT_SUFFIX(io.aeron.archive.Archive.Configuration.RECORDING_SEGMENT_SUFFIX) 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) BitUtil(org.agrona.BitUtil) org.agrona(org.agrona) READ_WRITE(java.nio.channels.FileChannel.MapMode.READ_WRITE) io.aeron.archive.codecs(io.aeron.archive.codecs) NULL_POSITION(io.aeron.archive.client.AeronArchive.NULL_POSITION) READ_ONLY(java.nio.channels.FileChannel.MapMode.READ_ONLY) FrameDescriptor(io.aeron.logbuffer.FrameDescriptor) HEADER_LENGTH(io.aeron.protocol.DataHeaderFlyweight.HEADER_LENGTH) Aeron(io.aeron.Aeron) Predicate(java.util.function.Predicate) StandardOpenOption(java.nio.file.StandardOpenOption) IOException(java.io.IOException) Math.min(java.lang.Math.min) Checksum(io.aeron.archive.checksum.Checksum) File(java.io.File) NULL_TIMESTAMP(io.aeron.archive.client.AeronArchive.NULL_TIMESTAMP) RecordingDescriptorDecoder(io.aeron.archive.codecs.RecordingDescriptorDecoder) INVALID(io.aeron.archive.codecs.RecordingState.INVALID) VALID(io.aeron.archive.codecs.RecordingState.VALID) ByteOrder.nativeOrder(java.nio.ByteOrder.nativeOrder) ArchiveException(io.aeron.archive.client.ArchiveException) EpochClock(org.agrona.concurrent.EpochClock) Math.max(java.lang.Math.max) FileChannel(java.nio.channels.FileChannel) MappedByteBuffer(java.nio.MappedByteBuffer) ArchiveException(io.aeron.archive.client.ArchiveException)

Example 2 with RecordingDescriptorDecoder

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

the class Catalog method refreshAndFixDescriptor.

private void refreshAndFixDescriptor(final RecordingDescriptorHeaderDecoder headerDecoder, final RecordingDescriptorEncoder encoder, final RecordingDescriptorDecoder decoder, final Checksum checksum, final UnsafeBuffer buffer) {
    final long recordingId = decoder.recordingId();
    if (VALID == headerDecoder.state() && NULL_POSITION == decoder.stopPosition()) {
        final String[] segmentFiles = listSegmentFiles(archiveDir, recordingId);
        final String maxSegmentFile = findSegmentFileWithHighestPosition(segmentFiles);
        encoder.stopPosition(computeStopPosition(archiveDir, maxSegmentFile, decoder.startPosition(), decoder.termBufferLength(), decoder.segmentFileLength(), checksum, buffer, (segmentFile) -> {
            throw new ArchiveException("Found potentially incomplete last fragment straddling page boundary in file: " + segmentFile.getAbsolutePath() + "\nRun `ArchiveTool verify` for corrective action!");
        }));
        encoder.stopTimestamp(epochClock.time());
    }
}
Also used : AsciiEncoding.parseLongAscii(org.agrona.AsciiEncoding.parseLongAscii) RECORDING_SEGMENT_SUFFIX(io.aeron.archive.Archive.Configuration.RECORDING_SEGMENT_SUFFIX) 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) BitUtil(org.agrona.BitUtil) org.agrona(org.agrona) READ_WRITE(java.nio.channels.FileChannel.MapMode.READ_WRITE) io.aeron.archive.codecs(io.aeron.archive.codecs) NULL_POSITION(io.aeron.archive.client.AeronArchive.NULL_POSITION) READ_ONLY(java.nio.channels.FileChannel.MapMode.READ_ONLY) FrameDescriptor(io.aeron.logbuffer.FrameDescriptor) HEADER_LENGTH(io.aeron.protocol.DataHeaderFlyweight.HEADER_LENGTH) Aeron(io.aeron.Aeron) Predicate(java.util.function.Predicate) StandardOpenOption(java.nio.file.StandardOpenOption) IOException(java.io.IOException) Math.min(java.lang.Math.min) Checksum(io.aeron.archive.checksum.Checksum) File(java.io.File) NULL_TIMESTAMP(io.aeron.archive.client.AeronArchive.NULL_TIMESTAMP) RecordingDescriptorDecoder(io.aeron.archive.codecs.RecordingDescriptorDecoder) INVALID(io.aeron.archive.codecs.RecordingState.INVALID) VALID(io.aeron.archive.codecs.RecordingState.VALID) ByteOrder.nativeOrder(java.nio.ByteOrder.nativeOrder) ArchiveException(io.aeron.archive.client.ArchiveException) EpochClock(org.agrona.concurrent.EpochClock) Math.max(java.lang.Math.max) FileChannel(java.nio.channels.FileChannel) MappedByteBuffer(java.nio.MappedByteBuffer) ArchiveException(io.aeron.archive.client.ArchiveException)

Aggregations

Aeron (io.aeron.Aeron)2 FILE_IO_MAX_LENGTH_DEFAULT (io.aeron.archive.Archive.Configuration.FILE_IO_MAX_LENGTH_DEFAULT)2 RECORDING_SEGMENT_SUFFIX (io.aeron.archive.Archive.Configuration.RECORDING_SEGMENT_SUFFIX)2 Checksum (io.aeron.archive.checksum.Checksum)2 NULL_POSITION (io.aeron.archive.client.AeronArchive.NULL_POSITION)2 NULL_TIMESTAMP (io.aeron.archive.client.AeronArchive.NULL_TIMESTAMP)2 ArchiveException (io.aeron.archive.client.ArchiveException)2 io.aeron.archive.codecs (io.aeron.archive.codecs)2 RecordingDescriptorDecoder (io.aeron.archive.codecs.RecordingDescriptorDecoder)2 INVALID (io.aeron.archive.codecs.RecordingState.INVALID)2 VALID (io.aeron.archive.codecs.RecordingState.VALID)2 FrameDescriptor (io.aeron.logbuffer.FrameDescriptor)2 HEADER_LENGTH (io.aeron.protocol.DataHeaderFlyweight.HEADER_LENGTH)2 File (java.io.File)2 IOException (java.io.IOException)2 Math.max (java.lang.Math.max)2 Math.min (java.lang.Math.min)2 ByteBuffer (java.nio.ByteBuffer)2 ByteOrder.nativeOrder (java.nio.ByteOrder.nativeOrder)2 MappedByteBuffer (java.nio.MappedByteBuffer)2