Search in sources :

Example 1 with INSTANCE

use of org.agrona.concurrent.SystemEpochClock.INSTANCE in project Aeron by real-logic.

the class ArchiveTool method migrate.

/**
 * Migrate previous archive {@link org.agrona.MarkFile}, {@link Catalog}, and recordings from previous version
 * to the latest version.
 *
 * @param out        output stream to print results and errors to.
 * @param archiveDir that contains MarkFile, Catalog and recordings.
 */
public static void migrate(final PrintStream out, final File archiveDir) {
    final EpochClock epochClock = INSTANCE;
    try {
        final int markFileVersion;
        final IntConsumer noVersionCheck = (version) -> {
        };
        try (ArchiveMarkFile markFile = openMarkFileReadWrite(archiveDir, epochClock);
            Catalog catalog = openCatalogReadWrite(archiveDir, epochClock, MIN_CAPACITY, null, noVersionCheck)) {
            markFileVersion = markFile.decoder().version();
            out.println("MarkFile version=" + fullVersionString(markFileVersion));
            out.println("Catalog version=" + fullVersionString(catalog.version()));
            out.println("Latest version=" + fullVersionString(ArchiveMarkFile.SEMANTIC_VERSION));
        }
        final List<ArchiveMigrationStep> steps = ArchiveMigrationPlanner.createPlan(markFileVersion);
        for (final ArchiveMigrationStep step : steps) {
            try (ArchiveMarkFile markFile = openMarkFileReadWrite(archiveDir, epochClock);
                Catalog catalog = openCatalogReadWrite(archiveDir, epochClock, MIN_CAPACITY, null, noVersionCheck)) {
                out.println("Migration step " + step.toString());
                step.migrate(out, markFile, catalog, archiveDir);
            }
        }
    } catch (final Exception ex) {
        ex.printStackTrace(out);
    }
}
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) EpochClock(org.agrona.concurrent.EpochClock) Catalog(io.aeron.archive.Catalog) IOException(java.io.IOException) AeronException(io.aeron.exceptions.AeronException) IntConsumer(java.util.function.IntConsumer)

Aggregations

CncFileDescriptor (io.aeron.CncFileDescriptor)1 CommonContext (io.aeron.CommonContext)1 CATALOG_FILE_NAME (io.aeron.archive.Archive.Configuration.CATALOG_FILE_NAME)1 FILE_IO_MAX_LENGTH_DEFAULT (io.aeron.archive.Archive.Configuration.FILE_IO_MAX_LENGTH_DEFAULT)1 APPLY_CHECKSUM (io.aeron.archive.ArchiveTool.VerifyOption.APPLY_CHECKSUM)1 VERIFY_ALL_SEGMENT_FILES (io.aeron.archive.ArchiveTool.VerifyOption.VERIFY_ALL_SEGMENT_FILES)1 Catalog (io.aeron.archive.Catalog)1 MigrationUtils.fullVersionString (io.aeron.archive.MigrationUtils.fullVersionString)1 ReplaySession.isInvalidHeader (io.aeron.archive.ReplaySession.isInvalidHeader)1 Checksum (io.aeron.archive.checksum.Checksum)1 Checksums.newInstance (io.aeron.archive.checksum.Checksums.newInstance)1 NULL_POSITION (io.aeron.archive.client.AeronArchive.NULL_POSITION)1 AeronArchive.segmentFileBasePosition (io.aeron.archive.client.AeronArchive.segmentFileBasePosition)1 io.aeron.archive.codecs (io.aeron.archive.codecs)1 INVALID (io.aeron.archive.codecs.RecordingState.INVALID)1 VALID (io.aeron.archive.codecs.RecordingState.VALID)1 MarkFileHeaderDecoder (io.aeron.archive.codecs.mark.MarkFileHeaderDecoder)1 Configuration (io.aeron.driver.Configuration)1 AeronException (io.aeron.exceptions.AeronException)1 FrameDescriptor (io.aeron.logbuffer.FrameDescriptor)1