Package org.apache.hadoop.ha
Class ShellCommandFencer
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.ha.ShellCommandFencer
- All Implemented Interfaces:
Configurable,FenceMethod
Fencing method that runs a shell command. It should be specified
in the fencing configuration like:
The string between '(' and ')' is passed directly to a bash shell (cmd.exe on Windows) and may not include any closing parentheses.
shell(/path/to/my/script.sh arg1 arg2 ...)
The string between '(' and ')' is passed directly to a bash shell (cmd.exe on Windows) and may not include any closing parentheses.
The shell command will be run with an environment set up to contain all of the current Hadoop configuration variables, with the '_' character replacing any '.' or '-' characters in the configuration keys.
If the shell command returns an exit code of 0, the fencing is determined to be successful. If it returns any other exit code, the fencing was not successful and the next fencing method in the list will be attempted.
Note: this fencing method does not implement any timeout. If timeouts are necessary, they should be implemented in the shell script itself (eg by forking a subshell to kill its parent in some number of seconds).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidVerify that the given fencing method's arguments are valid.booleantryFence(HAServiceTarget target, String args) Attempt to fence the target node.Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
-
Constructor Details
-
ShellCommandFencer
public ShellCommandFencer()
-
-
Method Details
-
checkArgs
Description copied from interface:FenceMethodVerify that the given fencing method's arguments are valid.- Specified by:
checkArgsin interfaceFenceMethod- Parameters:
args- the arguments provided in the configuration. This may be null if the operator did not configure any arguments.- Throws:
BadFencingConfigurationException- if the arguments are invalid
-
tryFence
Description copied from interface:FenceMethodAttempt to fence the target node.- Specified by:
tryFencein interfaceFenceMethod- Parameters:
target- the target of the service to fenceargs- the configured arguments, which were checked at startup byFenceMethod.checkArgs(String)- Returns:
- true if fencing was successful, false if unsuccessful or indeterminate
-