Class ArchiveTool

java.lang.Object
io.aeron.archive.ArchiveTool

public class ArchiveTool extends Object
Tool for inspecting and performing administrative tasks on an Archive and its contents which is described in a Catalog.
  • Constructor Details

    • ArchiveTool

      public ArchiveTool()
  • Method Details

    • main

      public static void main(String[] args)
      Main method for launching the process.
      Parameters:
      args - passed to the process.
    • maxEntries

      @Deprecated public static int maxEntries(File archiveDir)
      Deprecated.
      Use capacity(File) instead.
      Get the maximum number of entries supported by a Catalog.
      Parameters:
      archiveDir - containing the Catalog.
      Returns:
      the maximum number of entries supported by a Catalog.
      See Also:
    • maxEntries

      @Deprecated public static int maxEntries(File archiveDir, long newMaxEntries)
      Deprecated.
      Set the maximum number of entries supported by a Catalog.
      Parameters:
      archiveDir - containing the Catalog.
      newMaxEntries - value to set.
      Returns:
      the maximum number of entries supported by a Catalog after update.
      See Also:
    • capacity

      public static long capacity(File archiveDir)
      Get the capacity in bytes of the Catalog.
      Parameters:
      archiveDir - containing the Catalog.
      Returns:
      capacity in bytes of the Catalog, i.e. size of the Catalog file.
    • capacity

      public static long capacity(File archiveDir, long newCapacity)
      Set the capacity in bytes of the Catalog. If new capacity is smaller than current Catalog capacity then this method is a no op.
      Parameters:
      archiveDir - containing the Catalog.
      newCapacity - value to set.
      Returns:
      the capacity of the Catalog after update.
    • describeAll

      public static void describeAll(PrintStream out, File archiveDir)
      Describe the metadata for all entries in the Catalog. This will include entries that have been invalidated.
      Parameters:
      out - to which the entries will be printed.
      archiveDir - containing the Catalog.
    • describe

      public static void describe(PrintStream out, File archiveDir)
      Describe the metadata for all valid entries in the Catalog. This will not include entries that have been invalidated.
      Parameters:
      out - to which the entries will be printed.
      archiveDir - containing the Catalog.
    • describeRecording

      public static void describeRecording(PrintStream out, File archiveDir, long recordingId)
      Describe the metadata for an entry in the Catalog identified by recording id.
      Parameters:
      out - to which the entry will be printed.
      archiveDir - containing the Catalog.
      recordingId - to identify the entry.
    • entryCount

      public static int entryCount(File archiveDir)
      Count of the number of entries in the Catalog.
      Parameters:
      archiveDir - containing the Catalog.
      Returns:
      the number of entries in the Catalog.
    • pid

      public static long pid(File archiveDir)
      Get the pid of the process for the Archive.
      Parameters:
      archiveDir - containing the MarkFile.
      Returns:
      the pid of the process for the Archive.
    • printErrors

      public static void printErrors(PrintStream out, File archiveDir)
      Print the errors in the MarkFile.
      Parameters:
      out - stream to which the errors will be printed.
      archiveDir - containing the MarkFile.
    • dump

      public static void dump(PrintStream out, File archiveDir, long fragmentCountLimit, ArchiveTool.ActionConfirmation<Long> confirmActionOnFragmentCountLimit)
      Dump the contents of an Archive so it can be inspected or debugged. Each recording will have its contents dumped up to fragmentCountLimit before requesting to continue.
      Parameters:
      out - to which the contents will be printed.
      archiveDir - containing the Archive.
      fragmentCountLimit - limit of data fragments to print from each recording before continue.
      confirmActionOnFragmentCountLimit - confirm continue to dump at limit.
    • verify

      public static boolean verify(PrintStream out, File archiveDir, Set<ArchiveTool.VerifyOption> options, String checksumClassName, ArchiveTool.ActionConfirmation<File> truncateOnPageStraddle)
      Verify descriptors in the catalog, checking recording files availability and contents.

      Faulty entries are marked as unusable.

      Parameters:
      out - stream to print results and errors to.
      archiveDir - that contains MarkFile, Catalog, and recordings.
      options - set of options that control verification behavior.
      truncateOnPageStraddle - action to perform if last fragment in the max segment file straddles the page boundary, i.e. if true the file will be truncated (last fragment will be deleted), if false the fragment is considered complete.
      checksumClassName - (optional) fully qualified class name of the Checksum implementation.
      Returns:
      true if no errors have been encountered, false otherwise (faulty entries are marked as unusable if false is returned)
    • verifyRecording

      public static boolean verifyRecording(PrintStream out, File archiveDir, long recordingId, Set<ArchiveTool.VerifyOption> options, String checksumClassName, ArchiveTool.ActionConfirmation<File> truncateOnPageStraddle)
      Verify descriptor in the catalog according to recordingId, checking recording files availability and contents.

      Faulty entries are marked as unusable.

      Parameters:
      out - stream to print results and errors to.
      archiveDir - that contains MarkFile, Catalog, and recordings.
      recordingId - to verify.
      options - set of options that control verification behavior.
      truncateOnPageStraddle - action to perform if last fragment in the max segment file straddles the page boundary, i.e. if true the file will be truncated (last fragment will be deleted), if false the fragment if considered complete.
      checksumClassName - (optional) fully qualified class name of the Checksum implementation.
      Returns:
      true if no errors have been encountered, false otherwise (the recording is marked as unusable if false is returned)
      Throws:
      AeronException - if there is no recording with recordingId in the archive
    • checksum

      public static void checksum(PrintStream out, File archiveDir, boolean allFiles, String checksumClassName)
      Compute and persist CRC-32(c) checksums for every fragment of a segment file for all recordings in the catalog.
      Parameters:
      out - stream to print results and errors to.
      archiveDir - that contains MarkFile, Catalog, and recordings.
      allFiles - should compute checksums for all segment file or only for the last one.
      checksumClassName - fully qualified class name of the Checksum implementation.
    • checksumRecording

      public static void checksumRecording(PrintStream out, File archiveDir, long recordingId, boolean allFiles, String checksumClassName)
      Compute and persist CRC-32(c) checksums for every fragment of a segment file(s) for a given recording.
      Parameters:
      out - stream to print results and errors to.
      archiveDir - that contains MarkFile, Catalog, and recordings.
      recordingId - to compute checksums for.
      allFiles - should compute checksums for all segment file or only for the last one.
      checksumClassName - fully qualified class name of the Checksum implementation.
      Throws:
      AeronException - if there is no recording with recordingId in the archive
    • markRecordingValid

      public static void markRecordingValid(PrintStream out, File archiveDir, long recordingId)
      Mark a recording valid by marking it as RecordingState.VALID in the catalog.
      Parameters:
      out - stream to print results and errors to.
      archiveDir - that contains MarkFile, Catalog, and recordings.
      recordingId - to revive
      Throws:
      AeronException - if there is no recording with recordingId in the archive
    • markRecordingInvalid

      public static void markRecordingInvalid(PrintStream out, File archiveDir, long recordingId)
      Mark a recording invalid by marking it as RecordingState.INVALID in the catalog.
      Parameters:
      out - stream to print results and errors to.
      archiveDir - that contains MarkFile, Catalog, and recordings.
      recordingId - to invalidate
      Throws:
      AeronException - if there is no recording with recordingId in the archive
    • migrate

      public static void migrate(PrintStream out, File archiveDir)
      Migrate previous archive MarkFile, Catalog, and recordings from previous version to the latest version.
      Parameters:
      out - output stream to print results and errors to.
      archiveDir - that contains MarkFile, Catalog and recordings.
    • compact

      public static void compact(PrintStream out, File archiveDir)
      Compact Catalog file by removing all recordings in state RecordingState.INVALID and delete the corresponding segment files.
      Parameters:
      out - stream to print results and errors to.
      archiveDir - that contains MarkFile, Catalog, and recordings.
    • deleteOrphanedSegments

      public static void deleteOrphanedSegments(PrintStream out, File archiveDir)
      Delete orphaned recording segments that have been detached for all recordings, i.e. outside the start and stop recording range, but are not deleted.
      Parameters:
      out - stream to print results and errors to.
      archiveDir - that contains MarkFile, Catalog, and recordings.
    • deleteOrphanedSegments

      public static void deleteOrphanedSegments(PrintStream out, File archiveDir, long targetRecordingId)
      Delete orphaned recording segments that have been detached, i.e. outside the start and stop recording range, but are not deleted.
      Parameters:
      out - stream to print results and errors to.
      archiveDir - that contains MarkFile, Catalog, and recordings.
      targetRecordingId - optional recordingId to delete orphaned segments for a specific recording. If Aeron.NULL_VALUE, delete orphaned segments for all recordings.