org.apache.hadoop.ha
Class SshFenceByTcpPort

java.lang.Object
  extended by org.apache.hadoop.conf.Configured
      extended by org.apache.hadoop.ha.SshFenceByTcpPort
All Implemented Interfaces:
Configurable, FenceMethod

public class SshFenceByTcpPort
extends Configured
implements 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:

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
SshFenceByTcpPort()
           
 
Method Summary
 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.
 
Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SshFenceByTcpPort

public SshFenceByTcpPort()
Method Detail

checkArgs

public void checkArgs(String argStr)
               throws BadFencingConfigurationException
Verify that the argument, if given, in the conf is parseable.

Specified by:
checkArgs in interface FenceMethod
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: FenceMethod
Attempt to fence the target node.

Specified by:
tryFence in interface FenceMethod
argsStr - the configured arguments, which were checked at startup by FenceMethod.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


Copyright © 2012 Apache Software Foundation. All Rights Reserved.