Class NamenodeHeartbeatService

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.hdfs.server.federation.router.PeriodicService
org.apache.hadoop.hdfs.server.federation.router.NamenodeHeartbeatService
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.service.Service

public class NamenodeHeartbeatService extends PeriodicService
The Router periodically checks the state of a Namenode (usually on the same server) and reports their high availability (HA) state and load/space status to the StateStoreService . Note that this is an optional role as a Router can be independent of any subcluster.

For performance with Namenode HA, the Router uses the high availability state information in the State Store to forward the request to the Namenode that is most likely to be active.

Note that this service can be embedded into the Namenode itself to simplify the operation.

  • Constructor Details

    • NamenodeHeartbeatService

      public NamenodeHeartbeatService(ActiveNamenodeResolver resolver, String nsId, String nnId)
      Create a new Namenode status updater.
      Parameters:
      resolver - Namenode resolver service to handle NN registration.
      nsId - Identifier of the nameservice.
      nnId - Identifier of the namenode in HA.
    • NamenodeHeartbeatService

      public NamenodeHeartbeatService(ActiveNamenodeResolver resolver, String nsId, String nnId, String resolvedHost)
      Create a new Namenode status updater.
      Parameters:
      resolver - Namenode resolver service to handle NN registration.
      nsId - Identifier of the nameservice.
      nnId - Identifier of the namenode in HA.
      resolvedHost - resolvedHostname for this specific namenode.
  • Method Details

    • serviceInit

      protected void serviceInit(org.apache.hadoop.conf.Configuration configuration) throws Exception
      Overrides:
      serviceInit in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • periodicInvoke

      public void periodicInvoke()
      Description copied from class: PeriodicService
      Method that the service will run periodically.
      Specified by:
      periodicInvoke in class PeriodicService
    • getNamenodeStatusReport

      protected NamenodeStatusReport getNamenodeStatusReport()
      Get the status report for the Namenode monitored by this heartbeater.
      Returns:
      Namenode status report.
    • getNamenodeDesc

      public String getNamenodeDesc()
      Get the description of the Namenode to monitor.
      Returns:
      Description of the Namenode to monitor.
    • serviceStop

      protected void serviceStop() throws Exception
      Overrides:
      serviceStop in class PeriodicService
      Throws:
      Exception