Package io.aeron.archive
Class ArchiveTool
java.lang.Object
io.aeron.archive.ArchiveTool
Tool for inspecting and performing administrative tasks on an
Archive and its contents which is described
in a Catalog.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAllows user to confirm or reject an action.static enumSet of options forverify(PrintStream, File, Set, String, ActionConfirmation)andverifyRecording(PrintStream, File, long, Set, String, ActionConfirmation)methods. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longGet the capacity in bytes of theCatalog.static longSet the capacity in bytes of theCatalog.static voidchecksum(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.static voidchecksumRecording(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.static voidcompact(PrintStream out, File archiveDir) Compact Catalog file by removing all recordings in stateRecordingState.INVALIDand delete the corresponding segment files.static voiddeleteOrphanedSegments(PrintStream out, File archiveDir) Delete orphaned recording segments that have been detached for all recordings, i.e.static voiddeleteOrphanedSegments(PrintStream out, File archiveDir, long targetRecordingId) Delete orphaned recording segments that have been detached, i.e.static voiddescribe(PrintStream out, File archiveDir) Describe the metadata for all valid entries in theCatalog.static voiddescribeAll(PrintStream out, File archiveDir) Describe the metadata for all entries in theCatalog.static voiddescribeRecording(PrintStream out, File archiveDir, long recordingId) Describe the metadata for an entry in theCatalogidentified by recording id.static voiddump(PrintStream out, File archiveDir, long fragmentCountLimit, ArchiveTool.ActionConfirmation<Long> confirmActionOnFragmentCountLimit) Dump the contents of anArchiveso it can be inspected or debugged.static intentryCount(File archiveDir) Count of the number of entries in theCatalog.static voidMain method for launching the process.static voidmarkRecordingInvalid(PrintStream out, File archiveDir, long recordingId) Mark a recording invalid by marking it asRecordingState.INVALIDin the catalog.static voidmarkRecordingValid(PrintStream out, File archiveDir, long recordingId) Mark a recording valid by marking it asRecordingState.VALIDin the catalog.static intmaxEntries(File archiveDir) Deprecated.static intmaxEntries(File archiveDir, long newMaxEntries) Deprecated.Usecapacity(File, long)instead.static voidmigrate(PrintStream out, File archiveDir) Migrate previous archiveMarkFile,Catalog, and recordings from previous version to the latest version.static longGet the pid of the process for theArchive.static voidprintErrors(PrintStream out, File archiveDir) Print the errors in theMarkFile.static booleanverify(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.static booleanverifyRecording(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.
-
Constructor Details
-
ArchiveTool
public ArchiveTool()
-
-
Method Details
-
main
Main method for launching the process.- Parameters:
args- passed to the process.
-
maxEntries
Deprecated.Usecapacity(File)instead.Get the maximum number of entries supported by aCatalog.- Parameters:
archiveDir- containing theCatalog.- Returns:
- the maximum number of entries supported by a
Catalog. - See Also:
-
maxEntries
Deprecated.Usecapacity(File, long)instead.Set the maximum number of entries supported by aCatalog.- Parameters:
archiveDir- containing theCatalog.newMaxEntries- value to set.- Returns:
- the maximum number of entries supported by a
Catalogafter update. - See Also:
-
capacity
Get the capacity in bytes of theCatalog.- Parameters:
archiveDir- containing theCatalog.- Returns:
- capacity in bytes of the
Catalog, i.e. size of theCatalogfile.
-
capacity
Set the capacity in bytes of theCatalog. If new capacity is smaller than currentCatalogcapacity then this method is a no op.- Parameters:
archiveDir- containing theCatalog.newCapacity- value to set.- Returns:
- the capacity of the
Catalogafter update.
-
describeAll
Describe the metadata for all entries in theCatalog. This will include entries that have been invalidated.- Parameters:
out- to which the entries will be printed.archiveDir- containing theCatalog.
-
describe
Describe the metadata for all valid entries in theCatalog. This will not include entries that have been invalidated.- Parameters:
out- to which the entries will be printed.archiveDir- containing theCatalog.
-
describeRecording
Describe the metadata for an entry in theCatalogidentified by recording id.- Parameters:
out- to which the entry will be printed.archiveDir- containing theCatalog.recordingId- to identify the entry.
-
entryCount
Count of the number of entries in theCatalog.- Parameters:
archiveDir- containing theCatalog.- Returns:
- the number of entries in the
Catalog.
-
pid
Get the pid of the process for theArchive. -
printErrors
Print the errors in theMarkFile.- Parameters:
out- stream to which the errors will be printed.archiveDir- containing theMarkFile.
-
dump
public static void dump(PrintStream out, File archiveDir, long fragmentCountLimit, ArchiveTool.ActionConfirmation<Long> confirmActionOnFragmentCountLimit) Dump the contents of anArchiveso 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 theArchive.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 containsMarkFile,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. iftruethe file will be truncated (last fragment will be deleted), iffalsethe fragment is considered complete.checksumClassName- (optional) fully qualified class name of theChecksumimplementation.- Returns:
trueif no errors have been encountered,falseotherwise (faulty entries are marked as unusable iffalseis 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 containsMarkFile,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. iftruethe file will be truncated (last fragment will be deleted), iffalsethe fragment if considered complete.checksumClassName- (optional) fully qualified class name of theChecksumimplementation.- Returns:
trueif no errors have been encountered,falseotherwise (the recording is marked as unusable iffalseis returned)- Throws:
AeronException- if there is no recording withrecordingIdin 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. -
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 containsMarkFile,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 theChecksumimplementation.- Throws:
AeronException- if there is no recording withrecordingIdin the archive
-
markRecordingValid
Mark a recording valid by marking it asRecordingState.VALIDin the catalog.- Parameters:
out- stream to print results and errors to.archiveDir- that containsMarkFile,Catalog, and recordings.recordingId- to revive- Throws:
AeronException- if there is no recording withrecordingIdin the archive
-
markRecordingInvalid
Mark a recording invalid by marking it asRecordingState.INVALIDin the catalog.- Parameters:
out- stream to print results and errors to.archiveDir- that containsMarkFile,Catalog, and recordings.recordingId- to invalidate- Throws:
AeronException- if there is no recording withrecordingIdin the archive
-
migrate
Migrate previous archiveMarkFile,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
Compact Catalog file by removing all recordings in stateRecordingState.INVALIDand delete the corresponding segment files.- Parameters:
out- stream to print results and errors to.archiveDir- that containsMarkFile,Catalog, and recordings.
-
deleteOrphanedSegments
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 containsMarkFile,Catalog, and recordings.
-
deleteOrphanedSegments
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 containsMarkFile,Catalog, and recordings.targetRecordingId- optional recordingId to delete orphaned segments for a specific recording. IfAeron.NULL_VALUE, delete orphaned segments for all recordings.
-
capacity(File)instead.