Package org.apache.hadoop.ha
Class HAAdmin
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.ha.HAAdmin
- All Implemented Interfaces:
Configurable,Tool
A command-line tool for making calls in the HAServiceProtocol.
For example,. this can be used to force a service to standby or active
mode, or to trigger a health-check.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUsageInfo class holds args and help details. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PrintStreamOutput stream for errors, for use in testsprotected static final Stringprotected static final StringUndocumented flag which allows an administrator to use manual failover state transitions even when auto-failover is enabled.protected PrintStreamprotected static final Map<String,HAAdmin.UsageInfo> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanEnsure that we are allowed to manually manage the HA state of the target service.protected booleancheckParameterValidity(String[] argv) protected booleancheckParameterValidity(String[] argv, Map<String, HAAdmin.UsageInfo> helpEntries) protected booleanprotected HAServiceProtocol.StateChangeRequestInfoprotected intprotected HAServiceProtocol.RequestSourceprotected StringgetServiceAddr(String serviceId) Return the serviceId as is, we are assuming it was given as a service address of form <host:ipcport>.protected Collection<String>getTargetIds(String targetNodeToActivate) protected Stringprotected intInitiate a graceful failover by talking to the target node's ZKFC.protected intprotected inthelp(String[] argv, Map<String, HAAdmin.UsageInfo> helpEntries) protected org.apache.commons.cli.CommandLineprotected org.apache.commons.cli.CommandLineparseOpts(String cmdName, org.apache.commons.cli.Options opts, String[] argv, Map<String, HAAdmin.UsageInfo> helpEntries) protected voidprintUsage(PrintStream pStr) protected voidprintUsage(PrintStream pStr, String cmd) protected voidprintUsage(PrintStream pStr, String cmd, Map<String, HAAdmin.UsageInfo> helpEntries) protected voidprintUsage(PrintStream pStr, Map<String, HAAdmin.UsageInfo> helpEntries) protected abstract HAServiceTargetresolveTarget(String string) intExecute the command with the given arguments.protected intvoidsetConf(Configuration conf) Set the configuration to be used by this object.protected voidsetRequestSource(HAServiceProtocol.RequestSource requestSource) Methods inherited from class org.apache.hadoop.conf.Configured
getConfMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.conf.Configurable
getConf
-
Field Details
-
FORCEACTIVE
- See Also:
-
FORCEMANUAL
Undocumented flag which allows an administrator to use manual failover state transitions even when auto-failover is enabled. This is an unsafe operation, which is why it is not documented in the usage below.- See Also:
-
USAGE
-
errOut
Output stream for errors, for use in tests -
out
-
-
Constructor Details
-
HAAdmin
protected HAAdmin() -
HAAdmin
-
-
Method Details
-
getRequestSource
-
setRequestSource
-
resolveTarget
-
getTargetIds
-
getUsageString
-
printUsage
-
printUsage
-
printUsage
-
printUsage
-
checkManualStateManagementOK
Ensure that we are allowed to manually manage the HA state of the target service. If automatic failover is configured, then the automatic failover controllers should be doing state management, and it is generally an error to use the HAAdmin command line to do so.- Parameters:
target- the target to check- Returns:
- true if manual state management is allowed
-
createReqInfo
-
gracefulFailoverThroughZKFCs
Initiate a graceful failover by talking to the target node's ZKFC. This sends an RPC to the ZKFC, which coordinates the failover.- Parameters:
toNode- the node to fail to- Returns:
- status code (0 for success)
- Throws:
IOException- if failover does not succeed
-
getServiceAddr
Return the serviceId as is, we are assuming it was given as a service address of form <host:ipcport>.- Parameters:
serviceId- serviceId.- Returns:
- service addr.
-
setConf
Description copied from interface:ConfigurableSet the configuration to be used by this object.- Specified by:
setConfin interfaceConfigurable- Overrides:
setConfin classConfigured- Parameters:
conf- configuration to be used
-
run
Description copied from interface:ToolExecute the command with the given arguments. -
checkParameterValidity
-
checkParameterValidity
-
runCmd
- Throws:
Exception
-
getAllServiceState
protected int getAllServiceState() -
confirmForceManual
- Throws:
IOException
-
parseOpts
protected org.apache.commons.cli.CommandLine parseOpts(String cmdName, org.apache.commons.cli.Options opts, String[] argv, Map<String, HAAdmin.UsageInfo> helpEntries) -
parseOpts
-
help
-
help
-