Package io.aeron.cluster.service
Class ClusterMarkFile
java.lang.Object
io.aeron.cluster.service.ClusterMarkFile
- All Implemented Interfaces:
AutoCloseable
Used to indicate if a cluster component is running and what configuration it is using. Errors encountered by
the service are recorded within this file by a
DistinctErrorLog.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMax allowed length for the error log buffer.static final intMin length for the error log buffer.static final StringFile extension used by the mark file.static final StringMark file name.static final intLength of theheadersection.static final StringFile extension used by the link file.static final StringLink file name.static final intMajor version.static final intMinor version.static final intPatch version.static final intFull semantic version.static final StringService mark file name.static final intSpecial version to indicate that component failed to start. -
Constructor Summary
ConstructorsConstructorDescriptionClusterMarkFile(File file, io.aeron.cluster.codecs.mark.ClusterComponentType type, int errorBufferLength, EpochClock epochClock, long timeoutMs) Deprecated, for removal: This API element is subject to removal in a future version.ClusterMarkFile(File file, io.aeron.cluster.codecs.mark.ClusterComponentType type, int errorBufferLength, EpochClock epochClock, long timeoutMs, int filePageSize) Create newMarkFilefor a cluster component but check if an existing component is active.ClusterMarkFile(File directory, String filename, EpochClock epochClock, long timeoutMs, Consumer<String> logger) Construct to read the status of an existingMarkFilefor a cluster component. -
Method Summary
Modifier and TypeMethodDescriptionlongRead the activity timestamp of the cluster component with volatile semantics.longGet the current value of a candidate term id if a vote is placed in an election with volatile semantics.static voidcheckHeaderLength(String aeronDirectory, String controlChannel, String ingressChannel, String serviceName, String authenticator) Check if the header length is sufficient for encoding the provided properties.voidclose()intIdentity of the cluster instance so multiple clusters can run on the same driver.voidclusterId(int clusterId) Identity of the cluster instance so multiple clusters can run on the same driver.io.aeron.cluster.codecs.mark.MarkFileHeaderDecoderdecoder()The decoder for reading theMarkFileheader.io.aeron.cluster.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.booleanisClosed()Check if theMarkFileis closed.static booleanisConsensusModuleMarkFile(Path path, BasicFileAttributes attributes) Determines if this path name matches the consensus module file name pattern.static booleanisServiceMarkFile(Path path, BasicFileAttributes attributes) Determines if this path name matches the service mark file name pattern.static StringlinkFilenameForService(int serviceId) The filename to be used for the link file given a service id.The control properties for communicating between the consensus module and the services.static StringmarkFilenameForService(int serviceId) The filename to be used for the mark file given a service id.intmemberId()Cluster member id.voidmemberId(int memberId) Member id assigned as part of active join to the log in a clustered service.Get the parent directory containing the mark file.static voidsaveExistingErrors(File markFile, AtomicBuffer errorBuffer, io.aeron.cluster.codecs.mark.ClusterComponentType type, PrintStream logger) Save the existing errors from aMarkFileto aPrintStreamfor logging.voidSignal the cluster component has failed to conclude and cannot start.voidDeprecated, for removal: This API element is subject to removal in a future version.UsesignalReady(long)instead.voidsignalReady(long activityTimestamp) Signal the cluster component has concluded successfully and ready to start.voidSignal the cluster component has been terminated.toString()voidupdateActivityTimestamp(long nowMs) Update the activity timestamp as a proof of life.
-
Field Details
-
MAJOR_VERSION
public static final int MAJOR_VERSIONMajor version.- See Also:
-
MINOR_VERSION
public static final int MINOR_VERSIONMinor version.- See Also:
-
PATCH_VERSION
public static final int PATCH_VERSIONPatch version.- See Also:
-
SEMANTIC_VERSION
public static final int SEMANTIC_VERSIONFull semantic version. -
HEADER_LENGTH
public static final int HEADER_LENGTHLength of theheadersection.- See Also:
-
VERSION_FAILED
public static final int VERSION_FAILEDSpecial version to indicate that component failed to start.- See Also:
-
ERROR_BUFFER_MIN_LENGTH
public static final int ERROR_BUFFER_MIN_LENGTHMin length for the error log buffer.- See Also:
-
ERROR_BUFFER_MAX_LENGTH
public static final int ERROR_BUFFER_MAX_LENGTHMax allowed length for the error log buffer.- See Also:
-
FILE_EXTENSION
File extension used by the mark file.- See Also:
-
LINK_FILE_EXTENSION
File extension used by the link file.- See Also:
-
FILENAME
Mark file name.- See Also:
-
LINK_FILENAME
Link file name.- See Also:
-
SERVICE_FILENAME_PREFIX
Service mark file name.- See Also:
-
-
Constructor Details
-
ClusterMarkFile
@Deprecated(forRemoval=true) public ClusterMarkFile(File file, io.aeron.cluster.codecs.mark.ClusterComponentType type, int errorBufferLength, EpochClock epochClock, long timeoutMs) Deprecated, for removal: This API element is subject to removal in a future version.Create newMarkFilefor a cluster component but check if an existing component is active. -
ClusterMarkFile
public ClusterMarkFile(File file, io.aeron.cluster.codecs.mark.ClusterComponentType type, int errorBufferLength, EpochClock epochClock, long timeoutMs, int filePageSize) Create newMarkFilefor a cluster component but check if an existing component is active.- Parameters:
file- full qualified file to theMarkFile.type- of cluster component theMarkFilerepresents.errorBufferLength- for storing the error log.epochClock- for checking liveness against.timeoutMs- for the activity check on an existingMarkFile.filePageSize- for aligning file length to.- Since:
- 1.48.0
-
ClusterMarkFile
public ClusterMarkFile(File directory, String filename, EpochClock epochClock, long timeoutMs, Consumer<String> logger) Construct to read the status of an existingMarkFilefor a cluster component.- Parameters:
directory- in which the mark file exists.filename- for theMarkFile.epochClock- to be used for checking liveness.timeoutMs- to wait for file to exist.logger- to which debug information will be written if an issue occurs.
-
-
Method Details
-
parentDirectory
Get the parent directory containing the mark file.- Returns:
- parent directory of the mark file.
- See Also:
-
isServiceMarkFile
Determines if this path name matches the service mark file name pattern.- Parameters:
path- to examine.attributes- ignored, only needed for BiPredicate signature matching.- Returns:
- true if the name matches.
-
isConsensusModuleMarkFile
Determines if this path name matches the consensus module file name pattern.- Parameters:
path- to examine.attributes- ignored, only needed for BiPredicate signature matching.- Returns:
- true if the name matches.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
isClosed
public boolean isClosed()Check if theMarkFileis closed.- Returns:
- true if the
MarkFileis closed.
-
candidateTermId
public long candidateTermId()Get the current value of a candidate term id if a vote is placed in an election with volatile semantics.- Returns:
- the current candidate term id within an election after voting or
Aeron.NULL_VALUEif no voting phase of an election is currently active.
-
memberId
public int memberId()Cluster member id.- Returns:
- cluster member id.
-
memberId
public void memberId(int memberId) Member id assigned as part of active join to the log in a clustered service.- Parameters:
memberId- assigned as part of active join to the log in a clustered service.
-
clusterId
public int clusterId()Identity of the cluster instance so multiple clusters can run on the same driver.- Returns:
- id of the cluster instance so multiple clusters can run on the same driver.
-
clusterId
public void clusterId(int clusterId) Identity of the cluster instance so multiple clusters can run on the same driver.- Parameters:
clusterId- of the cluster instance so multiple clusters can run on the same driver.
-
signalReady
Deprecated, for removal: This API element is subject to removal in a future version.UsesignalReady(long)instead.Signal the cluster component has concluded successfully and ready to start. -
signalReady
public void signalReady(long activityTimestamp) Signal the cluster component has concluded successfully and ready to start.- Parameters:
activityTimestamp- to be used.
-
signalFailedStart
public void signalFailedStart()Signal the cluster component has failed to conclude and cannot start. -
signalTerminated
public void signalTerminated()Signal the cluster component has been terminated. -
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 cluster component with volatile semantics.- Returns:
- the activity timestamp of the cluster component with volatile semantics.
-
encoder
public io.aeron.cluster.codecs.mark.MarkFileHeaderEncoder encoder()The encoder for writing theMarkFileheader.- Returns:
- the encoder for writing the
MarkFileheader.
-
decoder
public io.aeron.cluster.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
public static void saveExistingErrors(File markFile, AtomicBuffer errorBuffer, io.aeron.cluster.codecs.mark.ClusterComponentType type, PrintStream logger) Save the existing errors from aMarkFileto aPrintStreamfor logging.- Parameters:
markFile- which contains the error buffer.errorBuffer- which wraps the error log.type- type of the mark file being checked.logger- to which the existing errors will be printed.
-
checkHeaderLength
public static void checkHeaderLength(String aeronDirectory, String controlChannel, String ingressChannel, String serviceName, String authenticator) Check if the header length is sufficient for encoding the provided properties.- Parameters:
aeronDirectory- for the media driver.controlChannel- for the consensus module.ingressChannel- from the cluster clients.serviceName- for the application service.authenticator- for the application service.
-
markFilenameForService
The filename to be used for the mark file given a service id.- Parameters:
serviceId- of the service theClusterMarkFilerepresents.- Returns:
- the filename to be used for the mark file given a service id.
-
linkFilenameForService
The filename to be used for the link file given a service id.- Parameters:
serviceId- of the service theClusterMarkFilerepresents.- Returns:
- the filename to be used for the link file given a service id.
-
loadControlProperties
The control properties for communicating between the consensus module and the services.- Returns:
- the control properties for communicating between the consensus module and the services or
nullif mark file was already closed.
-
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
-
ClusterMarkFile(File, ClusterComponentType, int, EpochClock, long, int)instead.