public class ShellCommandFencer extends Configured implements FenceMethod
shell(/path/to/my/script.sh arg1 arg2 ...)
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 '.' 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 and Description |
---|
ShellCommandFencer() |
Modifier and Type | Method and Description |
---|---|
void |
checkArgs(String args)
Verify that the given fencing method's arguments are valid.
|
boolean |
tryFence(HAServiceTarget target,
String cmd)
Attempt to fence the target node.
|
getConf, setConf
public void checkArgs(String args) throws BadFencingConfigurationException
FenceMethod
checkArgs
in interface FenceMethod
args
- the arguments provided in the configuration. This may
be null if the operator did not configure any arguments.BadFencingConfigurationException
- if the arguments are invalidpublic boolean tryFence(HAServiceTarget target, String cmd)
FenceMethod
tryFence
in interface FenceMethod
target
- the address (host:ipcport) of the service to fencecmd
- the configured arguments, which were checked at startup by
FenceMethod.checkArgs(String)
Copyright © 2017 Apache Software Foundation. All Rights Reserved.