Package org.apache.hadoop.ha
Class SshFenceByTcpPort
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.ha.SshFenceByTcpPort
- All Implemented Interfaces:
Configurable,FenceMethod
This fencing implementation sshes to the target node and uses
fuser to kill the process listening on the service's
TCP port. This is more accurate than using "jps" since it doesn't
require parsing, and will work even if there are multiple service
processes running on the same machine.It returns a successful status code if:
fuserindicates it successfully killed a process, ornc -zindicates that nothing is listening on the target port
This fencing mechanism is configured as following in the fencing method
list:
sshfence([[username][:ssh-port]])
where the optional argument specifies the username and port to use
with ssh.
In order to achieve passwordless SSH, the operator must also configure
dfs.ha.fencing.ssh.private-key-files to point to an
SSH key that has passphrase-less access to the given username and host.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidVerify that the argument, if given, in the conf is parseable.booleantryFence(HAServiceTarget target, String argsStr) Attempt to fence the target node.Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
-
Constructor Details
-
SshFenceByTcpPort
public SshFenceByTcpPort()
-
-
Method Details
-
checkArgs
Verify that the argument, if given, in the conf is parseable.- Specified by:
checkArgsin interfaceFenceMethod- Parameters:
argStr- 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
public boolean tryFence(HAServiceTarget target, String argsStr) throws BadFencingConfigurationException Description copied from interface:FenceMethodAttempt to fence the target node.- Specified by:
tryFencein interfaceFenceMethod- Parameters:
target- the target of the service to fenceargsStr- the configured arguments, which were checked at startup byFenceMethod.checkArgs(String)- Returns:
- true if fencing was successful, false if unsuccessful or indeterminate
- Throws:
BadFencingConfigurationException- if the configuration was determined to be invalid only at runtime
-