Package io.aeron.archive
Class ArchiveMarkFile
java.lang.Object
io.aeron.archive.ArchiveMarkFile
- All Implemented Interfaces:
AutoCloseable
Used to mark the presence of a running
Archive in a directory to guard it.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName for the archiveMarkFilestored in theArchive.Configuration.ARCHIVE_DIR_PROP_NAME.static final intHeader length for theMarkFilecontaining the metadata.static final StringName for a file contain a link to the directory containing theMarkFile.static final intMajor version for the archive files stored on disk.static final intMinor version for the archive files stored on disk.static final intPatch version for the archive files stored on disk.static final intCombined semantic version for the stored files. -
Constructor Summary
ConstructorsConstructorDescriptionArchiveMarkFile(File directory, String filename, EpochClock epochClock, long timeoutMs, Consumer<String> logger) Construct theMarkFilebased on an existing directory containing a mark file of a running archive.ArchiveMarkFile(File directory, String filename, EpochClock epochClock, long timeoutMs, IntConsumer versionCheck, Consumer<String> logger) Open an existingMarkFileor create a new one to be used in migration. -
Method Summary
Modifier and TypeMethodDescriptionlongRead the activity timestamp of the archive with volatile semantics.longGet archive id that is stored in the mark file.voidclose()io.aeron.archive.codecs.mark.MarkFileHeaderDecoderdecoder()The decoder for reading theMarkFileheader.io.aeron.archive.codecs.mark.MarkFileHeaderEncoderencoder()The encoder for writing theMarkFileheader.The direct buffer which wraps the region of theMarkFilewhich contains the error log.voidforce()Forces any changes made to the mark file's content to be written to the storage device containing the mapped file.static booleanisArchiveMarkFile(Path path, BasicFileAttributes attributes) Determine if the path matches the archive mark file name.booleanisClosed()Check if theMarkFileis closed.Get the parent directory containing the mark file.static voidsaveExistingErrors(File markFile, AtomicBuffer errorBuffer, PrintStream logger) Save the existing errors from aMarkFileto aPrintStreamfor logging.voidDeprecated, for removal: This API element is subject to removal in a future version.voidsignalReady(long activityTimestamp) Signal the archive has concluded successfully and ready to start.voidSignal the archive has terminated cleanly.toString()voidupdateActivityTimestamp(long nowMs) Update the activity timestamp as a proof of life.
-
Field Details
-
MAJOR_VERSION
public static final int MAJOR_VERSIONMajor version for the archive files stored on disk. A change to this requires migration.- See Also:
-
MINOR_VERSION
public static final int MINOR_VERSIONMinor version for the archive files stored on disk. A change to this indicates new features.- See Also:
-
PATCH_VERSION
public static final int PATCH_VERSIONPatch version for the archive files stored on disk. A change to this indicates feature parity bug fixes.- See Also:
-
SEMANTIC_VERSION
public static final int SEMANTIC_VERSIONCombined semantic version for the stored files.- See Also:
-
HEADER_LENGTH
public static final int HEADER_LENGTHHeader length for theMarkFilecontaining the metadata.- See Also:
-
FILENAME
Name for the archiveMarkFilestored in theArchive.Configuration.ARCHIVE_DIR_PROP_NAME.- See Also:
-
LINK_FILENAME
Name for a file contain a link to the directory containing theMarkFile.- See Also:
-
-
Constructor Details
-
ArchiveMarkFile
public ArchiveMarkFile(File directory, String filename, EpochClock epochClock, long timeoutMs, Consumer<String> logger) Construct theMarkFilebased on an existing directory containing a mark file of a running archive.- Parameters:
directory- containing the archive files.filename- for the mark file.epochClock- to be used for checking liveness.timeoutMs- after which the opening will be aborted if no archive starts.logger- to detail any discoveries.
-
ArchiveMarkFile
public ArchiveMarkFile(File directory, String filename, EpochClock epochClock, long timeoutMs, IntConsumer versionCheck, Consumer<String> logger) Open an existingMarkFileor create a new one to be used in migration.- Parameters:
directory- containing the archive files.filename- for the mark file.epochClock- to be used for checking liveness.timeoutMs- after which the opening will be aborted if no archive starts.versionCheck- for confirming the correct version.logger- to detail any discoveries.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
isClosed
public boolean isClosed()Check if theMarkFileis closed.- Returns:
- true if the
MarkFileis closed.
-
archiveId
public long archiveId()Get archive id that is stored in the mark file.- Returns:
- archive id or
Aeron.NULL_VALUEif mark file does not contain this information. - Since:
- 1.47.0
-
signalReady
Deprecated, for removal: This API element is subject to removal in a future version.UsesignalReady(long)instead.Signal the archive has concluded successfully and ready to start. -
signalReady
public void signalReady(long activityTimestamp) Signal the archive has concluded successfully and ready to start.- Parameters:
activityTimestamp- to be used.
-
signalTerminated
public void signalTerminated()Signal the archive has terminated cleanly. -
updateActivityTimestamp
public void updateActivityTimestamp(long nowMs) Update the activity timestamp as a proof of life.- Parameters:
nowMs- activity timestamp as a proof of life.
-
activityTimestampVolatile
public long activityTimestampVolatile()Read the activity timestamp of the archive with volatile semantics.- Returns:
- the activity timestamp of the archive with volatile semantics.
-
encoder
public io.aeron.archive.codecs.mark.MarkFileHeaderEncoder encoder()The encoder for writing theMarkFileheader.- Returns:
- the encoder for writing the
MarkFileheader.
-
decoder
public io.aeron.archive.codecs.mark.MarkFileHeaderDecoder decoder()The decoder for reading theMarkFileheader.- Returns:
- the decoder for reading the
MarkFileheader.
-
errorBuffer
The direct buffer which wraps the region of theMarkFilewhich contains the error log.- Returns:
- the direct buffer which wraps the region of the
MarkFilewhich contains the error log.
-
saveExistingErrors
Save the existing errors from aMarkFileto aPrintStreamfor logging.- Parameters:
markFile- which contains the error buffer.errorBuffer- which wraps the error log.logger- to which the existing errors will be printed.
-
isArchiveMarkFile
Determine if the path matches the archive mark file name.- Parameters:
path- to match.attributes- ignored, only needed for BiPredicate signature matching.- Returns:
- true if the filename matches.
-
parentDirectory
Get the parent directory containing the mark file.- Returns:
- parent directory of the mark file.
- See Also:
-
force
public void force()Forces any changes made to the mark file's content to be written to the storage device containing the mapped file.- Since:
- 1.44.0
-
toString
-
signalReady(long)instead.