Class HAServiceTarget

java.lang.Object
org.apache.hadoop.ha.HAServiceTarget

@Public @Evolving public abstract class HAServiceTarget extends Object
Represents a target of the client side HA administration commands.
  • Constructor Details

    • HAServiceTarget

      public HAServiceTarget()
  • Method Details

    • getAddress

      public abstract InetSocketAddress getAddress()
      Returns:
      the IPC address of the target node.
    • getHealthMonitorAddress

      public InetSocketAddress getHealthMonitorAddress()
      Returns an optional separate RPC server address for health checks at the target node. If defined, then this address is used by the health monitor for the HAServiceProtocol.monitorHealth() and HAServiceProtocol.getServiceStatus() calls. This can be useful for separating out these calls onto separate RPC handlers to protect against resource exhaustion in the main RPC handler pool. If null (which is the default implementation), then all RPC calls go to the address defined by getAddress().
      Returns:
      IPC address of the lifeline RPC server on the target node, or null if no lifeline RPC server is used
    • getZKFCAddress

      public abstract InetSocketAddress getZKFCAddress()
      Returns:
      the IPC address of the ZKFC on the target node
    • getFencer

      public abstract org.apache.hadoop.ha.NodeFencer getFencer()
      Returns:
      a Fencer implementation configured for this target node
    • checkFencingConfigured

      public abstract void checkFencingConfigured() throws BadFencingConfigurationException
      Throws:
      BadFencingConfigurationException - if the fencing configuration appears to be invalid. This is divorced from the above getFencer() method so that the configuration can be checked during the pre-flight phase of failover.
    • getProxy

      public HAServiceProtocol getProxy(Configuration conf, int timeoutMs) throws IOException
      Parameters:
      timeoutMs - timeout in milliseconds.
      conf - Configuration.
      Returns:
      a proxy to connect to the target HA Service.
      Throws:
      IOException - raised on errors performing I/O.
    • setTransitionTargetHAStatus

      public void setTransitionTargetHAStatus(HAServiceProtocol.HAServiceState status)
    • getTransitionTargetHAStatus

      public HAServiceProtocol.HAServiceState getTransitionTargetHAStatus()
    • getHealthMonitorProxy

      public HAServiceProtocol getHealthMonitorProxy(Configuration conf, int timeoutMs) throws IOException
      Returns a proxy to connect to the target HA service for health monitoring. If getHealthMonitorAddress() is implemented to return a non-null address, then this proxy will connect to that address. Otherwise, the returned proxy defaults to using getAddress(), which means this method's behavior is identical to getProxy(Configuration, int).
      Parameters:
      conf - configuration.
      timeoutMs - timeout in milliseconds
      Returns:
      a proxy to connect to the target HA service for health monitoring
      Throws:
      IOException - if there is an error
    • getHealthMonitorProxy

      public HAServiceProtocol getHealthMonitorProxy(Configuration conf, int timeoutMs, int retries) throws IOException
      Throws:
      IOException
    • getZKFCProxy

      public org.apache.hadoop.ha.ZKFCProtocol getZKFCProxy(Configuration conf, int timeoutMs) throws IOException
      Parameters:
      conf - configuration.
      timeoutMs - timeout in milliseconds.
      Returns:
      a proxy to the ZKFC which is associated with this HA service.
      Throws:
      IOException - raised on errors performing I/O.
    • getFencingParameters

      public final Map<String,String> getFencingParameters()
    • addFencingParameters

      protected void addFencingParameters(Map<String,String> ret)
      Hook to allow subclasses to add any parameters they would like to expose to fencing implementations/scripts. Fencing methods are free to use this map as they see fit -- notably, the shell script implementation takes each entry, prepends 'target_', substitutes '_' for '.' and '-', and adds it to the environment of the script. Subclass implementations should be sure to delegate to the superclass implementation as well as adding their own keys.
      Parameters:
      ret - map which can be mutated to pass parameters to the fencer
    • isAutoFailoverEnabled

      public boolean isAutoFailoverEnabled()
      Returns:
      true if auto failover should be considered enabled
    • supportObserver

      public boolean supportObserver()
      Returns:
      true if this target supports the Observer state, false otherwise.