Package io.aeron.cluster
Class ClusterTool
java.lang.Object
io.aeron.cluster.ClusterTool
Tool for control and investigating the state of a cluster node.
Usage: ClusterTool <cluster-dir> <command> [options]
describe: prints out all descriptors in the mark file.
pid: prints PID of cluster component.
recovery-plan: [service count] prints recovery plan of cluster component.
recording-log: prints recording log of cluster component.
sort-recording-log: reorders entries in the recording log to match the order in memory.
seed-recording-log-from-snapshot: creates a new recording log based on the latest valid snapshot.
errors: prints Aeron and cluster component error logs.
list-members: prints leader memberId and active members.
backup-query: [delay] get, or set, time of next backup query.
invalidate-latest-snapshot: marks the latest snapshot as a invalid so the previous is loaded.
snapshot: triggers a snapshot on the leader.
standby-snapshot: triggers a snapshot on cluster standby nodes.
suspend: suspends appending to the log.
resume: resumes reading from the log.
shutdown: initiates an orderly stop of the cluster with a snapshot.
abort: stops the cluster without a snapshot.
describe-latest-cm-snapshot: prints the contents of the latest valid consensus module snapshot.
is-leader: returns zero if the cluster node is leader, non-zero if not
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDelay in nanoseconds to be applied to an operation such as when the new cluster backup query will occur.static final StringChannel used for archive replays.static final StringDefault channel used for archive replays.static final StringProperty name for setting the channel used for archive replays.static final intStream id used for archive replays.static final intDefault stream id used for archive replays.static final StringProperty name for setting the stream id used for archive replays.static final StringTimeout in nanoseconds for the tool to wait while trying to perform an operation.static final longTimeout in milliseconds used by the tool for operations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanabort(File clusterDir, PrintStream out) Instruct the cluster to abort.static Map<String,ClusterToolCommand> commands()Cluster Tool commands map.static voiddescribe(PrintStream out, ClusterMarkFile[] serviceMarkFiles) Print out the descriptors in theClusterMarkFiles.static voiddescribe(PrintStream out, File clusterDir) Print out the descriptors in theClusterMarkFiles.static booleandescribeLatestConsensusModuleSnapshot(PrintStream out, File clusterDir) Print out a summary of the state captured in the latest consensus module snapshot.static booleandescribeLatestConsensusModuleSnapshot(PrintStream out, File clusterDir, BiConsumer<Image, Aeron> postConsensusImageDescriber) Print out a summary of the state captured in the latest consensus module snapshot.static voiderrors(PrintStream out, File clusterDir) Print out the errors in the error logs for the cluster components.static booleaninvalidateLatestSnapshot(PrintStream out, File clusterDir) Invalidate the latest snapshot so recovery will use an earlier one or log if no earlier one exists.static intisLeader(PrintStream out, File clusterDir) Determine if a given node is a leader.static booleanlistMembers(ClusterMembership clusterMembership, File clusterDir, long timeoutMs) List the current members of a cluster.static voidlistMembers(PrintStream out, File clusterDir) Print out a list of the current members of the cluster.static voidMain method for launching the process.static booleanmarkFileExists(File clusterDir) Does aClusterMarkFileexist in the cluster directory.static voidnextBackupQuery(PrintStream out, File clusterDir, long delayMs) Set the time of the next backup query for the cluster backup.static longnextBackupQueryDeadlineMs(ClusterMarkFile markFile) Get the deadline time (MS) for the next cluster backup query.static booleannextBackupQueryDeadlineMs(ClusterMarkFile markFile, long timeMs) Set the deadline time (MS) for the next cluster backup query.static longnextBackupQueryDeadlineMs(File clusterDir) Get the deadline time (MS) for the next cluster backup query.static booleannextBackupQueryDeadlineMs(File clusterDir, long timeMs) Set the deadline time (MS) for the next cluster backup query.static voidpid(PrintStream out, File clusterDir) Print out the PID of the cluster process.static voidprintNextBackupQuery(PrintStream out, File clusterDir) Print out the time of the next backup query.static booleanqueryClusterMembers(ClusterMarkFile markFile, long timeoutMs, ClusterMembership clusterMembership) Query the membership of a cluster.static booleanqueryClusterMembers(ClusterNodeControlProperties controlProperties, long timeoutMs, ClusterMembership clusterMembership) Query the membership of a cluster.static voidrecordingLog(PrintStream out, File clusterDir) Print out theRecordingLogfor the cluster.static voidrecoveryPlan(PrintStream out, File clusterDir, int serviceCount) Print out theRecordingLog.RecoveryPlanfor the cluster.static booleanresume(File clusterDir, PrintStream out) Instruct the cluster to resume operation.static voidseedRecordingLogFromSnapshot(File clusterDir) Create a newRecordingLogbased on the latest valid snapshot whose term base and log positions are set to zero.static booleanshutdown(File clusterDir, PrintStream out) Instruct the cluster to shut down.static booleansnapshot(File clusterDir, PrintStream out) Instruct the cluster to take a snapshot.static booleansortRecordingLog(File clusterDir) Re-order entries in theeRecordingLogfile on disc if they are not in a proper order.static booleansuspend(File clusterDir, PrintStream out) Instruct the cluster to suspend operation.
-
Field Details
-
AERON_CLUSTER_TOOL_TIMEOUT_PROP_NAME
Timeout in nanoseconds for the tool to wait while trying to perform an operation.- See Also:
-
AERON_CLUSTER_TOOL_DELAY_PROP_NAME
Delay in nanoseconds to be applied to an operation such as when the new cluster backup query will occur.- See Also:
-
AERON_CLUSTER_TOOL_REPLAY_CHANNEL_PROP_NAME
Property name for setting the channel used for archive replays.- See Also:
-
AERON_CLUSTER_TOOL_REPLAY_CHANNEL_DEFAULT
Default channel used for archive replays.- See Also:
-
AERON_CLUSTER_TOOL_REPLAY_CHANNEL
Channel used for archive replays. -
AERON_CLUSTER_TOOL_REPLAY_STREAM_ID_PROP_NAME
Property name for setting the stream id used for archive replays.- See Also:
-
AERON_CLUSTER_TOOL_REPLAY_STREAM_ID_DEFAULT
public static final int AERON_CLUSTER_TOOL_REPLAY_STREAM_ID_DEFAULTDefault stream id used for archive replays.- See Also:
-
AERON_CLUSTER_TOOL_REPLAY_STREAM_ID
public static final int AERON_CLUSTER_TOOL_REPLAY_STREAM_IDStream id used for archive replays. -
TIMEOUT_MS
public static final long TIMEOUT_MSTimeout in milliseconds used by the tool for operations.
-
-
Constructor Details
-
ClusterTool
public ClusterTool()
-
-
Method Details
-
main
Main method for launching the process.- Parameters:
args- passed to the process.
-
describe
Print out the descriptors in theClusterMarkFiles.- Parameters:
out- to print the output to.clusterDir- where the cluster is running.
-
pid
Print out the PID of the cluster process.- Parameters:
out- to print the output to.clusterDir- where the cluster is running.
-
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.
-
recordingLog
Print out theRecordingLogfor the cluster.- Parameters:
out- to print the output to.clusterDir- where the cluster is running.
-
sortRecordingLog
Re-order entries in theeRecordingLogfile on disc if they are not in a proper order.- Parameters:
clusterDir- where the cluster is running.- Returns:
trueif file contents was changed orfalseif 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.
-
errors
Print out the errors in the error logs for the cluster components.- Parameters:
out- to print the output to.clusterDir- where the cluster is running.
-
listMembers
Print out a list of the current members of the cluster.- Parameters:
out- to print the output to.clusterDir- where the cluster is running.
-
printNextBackupQuery
Print out the time of the next backup query.- Parameters:
out- to print the output to.clusterDir- where the cluster backup is running.
-
nextBackupQuery
Set the time of the next backup query for the cluster backup.- Parameters:
out- to print the output to.clusterDir- where the cluster is running.delayMs- from the current time for the next backup query.
-
describe
Print out the descriptors in theClusterMarkFiles.- Parameters:
out- to print the output to.serviceMarkFiles- to query.
-
isLeader
Determine if a given node is a leader.- Parameters:
out- to print the output to.clusterDir- where the cluster is running.- 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
public static boolean listMembers(ClusterMembership clusterMembership, File clusterDir, long timeoutMs) 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
public static 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
public static 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:
out- to print the operation result.clusterDir- where the cluster component is running.- Returns:
- true if the latest snapshot was invalidated.
-
describeLatestConsensusModuleSnapshot
Print out a summary of the state captured in the latest consensus module snapshot.- Parameters:
out- to print the operation result.clusterDir- where the cluster is running.- Returns:
trueif the snapshot was successfully describedfalseotherwise.
-
describeLatestConsensusModuleSnapshot
public static boolean describeLatestConsensusModuleSnapshot(PrintStream out, File clusterDir, BiConsumer<Image, Aeron> postConsensusImageDescriber) Print out a summary of the state captured in the latest consensus module snapshot.- Parameters:
out- to print the operation result.clusterDir- where the cluster is running.postConsensusImageDescriber- describe the data after the snapshot used for extensions.- Returns:
trueif the snapshot was successfully describedfalseotherwise.
-
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:
- true is the operation was successfully requested.
-
suspend
Instruct the cluster to suspend operation.- Parameters:
clusterDir- where the consensus module is running.out- to print the result of the operation.- Returns:
- true is the operation was successfully requested.
-
resume
Instruct the cluster to resume operation.- Parameters:
clusterDir- where the consensus module is running.out- to print the result of the operation.- Returns:
- true is the operation was successfully requested.
-
shutdown
Instruct the cluster to shut down.- Parameters:
clusterDir- where the consensus module is running.out- to print the result of the operation.- Returns:
- true is the operation was successfully requested.
-
abort
Instruct the cluster to abort.- Parameters:
clusterDir- where the consensus module is running.out- to print the result of the operation.- Returns:
- true is the operation was successfully requested.
-
commands
Cluster Tool commands map. This is to allow other tools to simply extend ClusterToolNote that the map is cloned and both key and value are Java immutable objects.
- Returns:
- a clone of Cluster Tool commands map
-