public class SshFenceByTcpPort extends Configured implements FenceMethod
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:
fuser indicates it successfully killed a process, or
nc -z indicates 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 and Description |
|---|
SshFenceByTcpPort() |
| Modifier and Type | Method and Description |
|---|---|
void |
checkArgs(String argStr)
Verify that the argument, if given, in the conf is parseable.
|
boolean |
tryFence(HAServiceTarget target,
String argsStr)
Attempt to fence the target node.
|
getConf, setConfpublic void checkArgs(String argStr) throws BadFencingConfigurationException
checkArgs in interface FenceMethodargStr - 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 argsStr) throws BadFencingConfigurationException
FenceMethodtryFence in interface FenceMethodtarget - the target of the service to fenceargsStr - the configured arguments, which were checked at startup by
FenceMethod.checkArgs(String)BadFencingConfigurationException - if the configuration was
determined to be invalid only at runtimeCopyright © 2008–2022 Apache Software Foundation. All rights reserved.