Package io.aeron.cluster
Class ClusterToolOperator
java.lang.Object
io.aeron.cluster.ClusterToolOperator
Actions for an operator tool to control cluster.
This class is used by
ClusterTool by Aeron but also allows to be used / extended by other tools.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSuccessful action return value = exist status. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClusterToolOperator(String toolChannel, int toolStreamId, long timeoutMs) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected intabort(File clusterDir, PrintStream out) Instruct the cluster to abort.protected voiddescribe(PrintStream out, ClusterMarkFile[] serviceMarkFiles) Print out the descriptors in theClusterMarkFiles.protected intdescribeClusterMarkFile(File clusterDir, PrintStream out) Print out the descriptors in theClusterMarkFiles.protected intdescribeLatestConsensusModuleSnapshot(File clusterDir, PrintStream out) Print out a summary of the state captured in the latest consensus module snapshot.protected intdescribeLatestConsensusModuleSnapshot(File clusterDir, PrintStream out, BiConsumer<Image, Aeron> postConsensusImageDescriber) Print out a summary of the state captured in the latest consensus module snapshot.protected interrors(File clusterDir, PrintStream out) Print out the errors in the error logs for the cluster components.protected RecordingLog.EntryfindLatestValidSnapshot(File clusterDir) Finds the latest valid snapshot from the log file.protected intinvalidateLatestSnapshot(File clusterDir, PrintStream out) Invalidate the latest snapshot so recovery will use an earlier one or log if no earlier one exists.protected intisLeader(File clusterDir, PrintStream out) Determine if the given node is a leader.protected booleanlistMembers(ClusterMembership clusterMembership, File clusterDir, long timeoutMs) List the current members of a cluster.protected intlistMembers(File clusterDir, PrintStream out) Print out a list of the current members of the cluster.protected ClusterNodeControlPropertiesloadControlProperties(File clusterDir) LoadClusterNodeControlPropertiesfrom the mark file.protected booleanmarkFileExists(File clusterDir) Does aClusterMarkFileexist in the cluster directory.protected intnextBackupQuery(File clusterDir, PrintStream out, long delayMs) Set the time of the next backup query for the cluster backup.protected longnextBackupQueryDeadlineMs(ClusterMarkFile markFile) Get the deadline time (MS) for the next cluster backup query.protected booleannextBackupQueryDeadlineMs(ClusterMarkFile markFile, long timeMs) Set the deadline time (MS) for the next cluster backup query.protected longnextBackupQueryDeadlineMs(File clusterDir) Get the deadline time (MS) for the next cluster backup query.protected booleannextBackupQueryDeadlineMs(File clusterDir, long timeMs) Set the deadline time (MS) for the next cluster backup query.protected intpid(File clusterDir, PrintStream out) Print out the PID of the cluster process.protected intprintNextBackupQuery(File clusterDir, PrintStream out) Print out the time of the next backup query.protected booleanqueryClusterMembers(ClusterMarkFile markFile, long timeoutMs, ClusterMembership clusterMembership) Query the membership of a cluster.protected booleanqueryClusterMembers(ClusterNodeControlProperties controlProperties, long timeoutMs, ClusterMembership clusterMembership) Query the membership of a cluster.protected intrecordingLog(File clusterDir, PrintStream out) Print out theRecordingLogfor the cluster.protected intrecoveryPlan(PrintStream out, File clusterDir, int serviceCount) Print out theRecordingLog.RecoveryPlanfor the cluster.protected intresume(File clusterDir, PrintStream out) Instruct the cluster to resume operation.protected intseedRecordingLogFromSnapshot(File clusterDir) Create a newRecordingLogbased on the latest valid snapshot whose term base and log positions are set to zero.protected intshutdown(File clusterDir, PrintStream out) Instruct the cluster to shut down.protected intsnapshot(File clusterDir, PrintStream out) Instruct the cluster to take a snapshot.protected intsortRecordingLog(File clusterDir) Re-order entries in theeRecordingLogfile on disc if they are not in a proper order.protected intsuspend(File clusterDir, PrintStream out) Instruct the cluster to suspend operation.protected longprotected Stringprotected int
-
Field Details
-
SUCCESS
public static final int SUCCESSSuccessful action return value = exist status.- See Also:
-
-
Constructor Details
-
ClusterToolOperator
Constructor.- Parameters:
toolChannel- channel to use.toolStreamId- stream id to use.timeoutMs- timeout in milliseconds.
-
-
Method Details
-
pid
Print out the PID of the cluster process.- Parameters:
out- to print the output to.clusterDir- where the cluster is running.- Returns:
- exit status.
-
recoveryPlan
Print out theRecordingLog.RecoveryPlanfor the cluster.- Parameters:
out- to print the output to.clusterDir- where the cluster is running.serviceCount- of services running in the containers.- Returns:
- exit status
-
recordingLog
Print out theRecordingLogfor the cluster.- Parameters:
clusterDir- where the cluster is running.out- to print the output to.- Returns:
- exit status
-
sortRecordingLog
Re-order entries in theeRecordingLogfile on disc if they are not in a proper order.- Parameters:
clusterDir- where the cluster is running.- Returns:
SUCCESSif file contents was changed orFAILUREif it was already in the correct order.
-
seedRecordingLogFromSnapshot
Create a newRecordingLogbased on the latest valid snapshot whose term base and log positions are set to zero. The original recording log file is backed up asrecording.log.bak.- Parameters:
clusterDir- where the cluster is running.- Returns:
- exit status
-
errors
Print out the errors in the error logs for the cluster components.- Parameters:
clusterDir- where the cluster is running.out- to print the output to.- Returns:
- exit status
-
listMembers
Print out a list of the current members of the cluster.- Parameters:
clusterDir- where the cluster is running.out- to print the output to.- Returns:
- exit status
-
printNextBackupQuery
Print out the time of the next backup query.- Parameters:
clusterDir- where the cluster backup is running.out- to print the output to.- Returns:
- exit status
-
nextBackupQuery
Set the time of the next backup query for the cluster backup.- Parameters:
clusterDir- where the cluster is running.out- to print the output to.delayMs- from the current time for the next backup query.- Returns:
- exit status
-
describe
Print out the descriptors in theClusterMarkFiles.- Parameters:
out- to print the output to.serviceMarkFiles- to query.
-
isLeader
Determine if the given node is a leader.- Parameters:
clusterDir- where the cluster is running.out- to print the output to.- Returns:
- 0 if the node is an active leader in a closed election, 1 if not, -1 if the mark file does not exist.
-
markFileExists
Does aClusterMarkFileexist in the cluster directory.- Parameters:
clusterDir- to check for if a mark file exists.- Returns:
- true if the cluster mark file exists.
-
listMembers
List the current members of a cluster.- Parameters:
clusterMembership- to populate.clusterDir- where the cluster is running.timeoutMs- to wait on the query completing.- Returns:
- true if successful.
-
queryClusterMembers
protected boolean queryClusterMembers(ClusterMarkFile markFile, long timeoutMs, ClusterMembership clusterMembership) Query the membership of a cluster.- Parameters:
markFile- for the cluster component.timeoutMs- to wait for the query.clusterMembership- to populate.- Returns:
- true if the query was successful.
-
queryClusterMembers
protected boolean queryClusterMembers(ClusterNodeControlProperties controlProperties, long timeoutMs, ClusterMembership clusterMembership) Query the membership of a cluster.- Parameters:
controlProperties- from aClusterMarkFile.timeoutMs- to wait for the query.clusterMembership- to populate.- Returns:
- true if the query was successful.
-
nextBackupQueryDeadlineMs
Get the deadline time (MS) for the next cluster backup query.- Parameters:
clusterDir- where the cluster component is running.- Returns:
- the deadline time (MS) for the next cluster backup query, or
Aeron.NULL_VALUEnot available.
-
nextBackupQueryDeadlineMs
Get the deadline time (MS) for the next cluster backup query.- Parameters:
markFile- for the cluster component.- Returns:
- the deadline time (MS) for the next cluster backup query, or
Aeron.NULL_VALUEnot available.
-
nextBackupQueryDeadlineMs
Set the deadline time (MS) for the next cluster backup query.- Parameters:
clusterDir- where the cluster component is running.timeMs- to set for the next deadline.- Returns:
- true if successful, otherwise false.
-
nextBackupQueryDeadlineMs
Set the deadline time (MS) for the next cluster backup query.- Parameters:
markFile- for the cluster component.timeMs- to set for the next deadline.- Returns:
- true if successful, otherwise false.
-
invalidateLatestSnapshot
Invalidate the latest snapshot so recovery will use an earlier one or log if no earlier one exists.- Parameters:
clusterDir- where the cluster component is running.out- to print the operation result.- Returns:
- SUCCESS if the latest snapshot was invalidated, else FAILURE
-
describeLatestConsensusModuleSnapshot
Print out a summary of the state captured in the latest consensus module snapshot.- Parameters:
clusterDir- where the cluster is running.out- where to print the operation result.- Returns:
- SUCCESS is the operation was successfully requested, else FAILURE
-
describeLatestConsensusModuleSnapshot
protected int describeLatestConsensusModuleSnapshot(File clusterDir, PrintStream out, BiConsumer<Image, Aeron> postConsensusImageDescriber) Print out a summary of the state captured in the latest consensus module snapshot.- Parameters:
clusterDir- where the cluster is running.out- where to print the operation result.postConsensusImageDescriber- describing of image after consensus module state- Returns:
- SUCCESS is the operation was successfully requested, else FAILURE
-
snapshot
Instruct the cluster to take a snapshot.- Parameters:
clusterDir- where the consensus module is running.out- to print the result of the operation.- Returns:
- SUCCESS is the operation was successfully requested, else FAILURE
-
suspend
Instruct the cluster to suspend operation.- Parameters:
clusterDir- where the consensus module is running.out- to print the result of the operation.- Returns:
- SUCCESS is the operation was successfully requested, else FAILURE
-
resume
Instruct the cluster to resume operation.- Parameters:
clusterDir- where the consensus module is running.out- to print the result of the operation.- Returns:
- SUCCESS is the operation was successfully requested, else FAILURE
-
shutdown
Instruct the cluster to shut down.- Parameters:
clusterDir- where the consensus module is running.out- to print the result of the operation.- Returns:
- SUCCESS is the operation was successfully requested, else FAILURE
-
abort
Instruct the cluster to abort.- Parameters:
clusterDir- where the consensus module is running.out- to print the result of the operation.- Returns:
- SUCCESS is the operation was successfully requested, else FAILURE
-
findLatestValidSnapshot
Finds the latest valid snapshot from the log file.- Parameters:
clusterDir- where the cluster node is running.- Returns:
- entry or
nullif not found.
-
loadControlProperties
LoadClusterNodeControlPropertiesfrom the mark file.- Parameters:
clusterDir- where the cluster node is running.- Returns:
- control properties.
-
describeClusterMarkFile
Print out the descriptors in theClusterMarkFiles.- Parameters:
clusterDir- where the cluster is running.out- to print the output to.- Returns:
- exit status
-
toolChannel
- Returns:
- channel to use.
-
toolStreamId
protected int toolStreamId()- Returns:
- stream id to use.
-
timeoutMs
protected long timeoutMs()- Returns:
- timeout in milliseconds to use.
-