Class ArchiveMarkFile

java.lang.Object
io.aeron.archive.ArchiveMarkFile
All Implemented Interfaces:
AutoCloseable

public class ArchiveMarkFile extends Object implements AutoCloseable
Used to mark the presence of a running Archive in a directory to guard it.
  • Field Details

    • MAJOR_VERSION

      public static final int MAJOR_VERSION
      Major version for the archive files stored on disk. A change to this requires migration.
      See Also:
    • MINOR_VERSION

      public static final int MINOR_VERSION
      Minor version for the archive files stored on disk. A change to this indicates new features.
      See Also:
    • PATCH_VERSION

      public static final int PATCH_VERSION
      Patch 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_VERSION
      Combined semantic version for the stored files.
      See Also:
    • HEADER_LENGTH

      public static final int HEADER_LENGTH
      Header length for the MarkFile containing the metadata.
      See Also:
    • FILENAME

      public static final String FILENAME
      Name for the archive MarkFile stored in the Archive.Configuration.ARCHIVE_DIR_PROP_NAME.
      See Also:
  • Constructor Details

    • ArchiveMarkFile

      public ArchiveMarkFile(File directory, String filename, EpochClock epochClock, long timeoutMs, Consumer<String> logger)
      Construct the MarkFile based 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 existing MarkFile or 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:
      close in interface AutoCloseable
    • isClosed

      public boolean isClosed()
      Check if the MarkFile is closed.
      Returns:
      true if the MarkFile is closed.
    • archiveId

      public long archiveId()
      Get archive id that is stored in the mark file.
      Returns:
      archive id or Aeron.NULL_VALUE if mark file does not contain this information.
      Since:
      1.47.0
    • signalReady

      @Deprecated(forRemoval=true) public void signalReady()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use signalReady(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 the MarkFile header.
      Returns:
      the encoder for writing the MarkFile header.
    • decoder

      public io.aeron.archive.codecs.mark.MarkFileHeaderDecoder decoder()
      The decoder for reading the MarkFile header.
      Returns:
      the decoder for reading the MarkFile header.
    • errorBuffer

      public AtomicBuffer errorBuffer()
      The direct buffer which wraps the region of the MarkFile which contains the error log.
      Returns:
      the direct buffer which wraps the region of the MarkFile which contains the error log.
    • saveExistingErrors

      public static void saveExistingErrors(File markFile, AtomicBuffer errorBuffer, PrintStream logger)
      Save the existing errors from a MarkFile to a PrintStream for logging.
      Parameters:
      markFile - which contains the error buffer.
      errorBuffer - which wraps the error log.
      logger - to which the existing errors will be printed.
    • isArchiveMarkFile

      public static boolean isArchiveMarkFile(Path path, BasicFileAttributes attributes)
      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

      public File 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

      public String toString()
      Overrides:
      toString in class Object