Class MembershipNamenodeResolver

java.lang.Object
org.apache.hadoop.hdfs.server.federation.resolver.MembershipNamenodeResolver
All Implemented Interfaces:
ActiveNamenodeResolver, StateStoreCache

public class MembershipNamenodeResolver extends Object implements ActiveNamenodeResolver, StateStoreCache
Implements a cached lookup of the most recently active namenode for a particular nameservice. Relies on the StateStoreService to discover available nameservices and namenodes.
  • Constructor Details

  • Method Details

    • loadCache

      public boolean loadCache(boolean force)
      Description copied from interface: StateStoreCache
      Load the cache from the State Store. Called by the cache update service when the data has been reloaded.
      Specified by:
      loadCache in interface StateStoreCache
      Parameters:
      force - If we force the load.
      Returns:
      If the cache was loaded successfully.
    • updateUnavailableNamenode

      public void updateUnavailableNamenode(String nsId, InetSocketAddress address) throws IOException
      Description copied from interface: ActiveNamenodeResolver
      Report a failed, unavailable NN address for a nameservice or blockPool.
      Specified by:
      updateUnavailableNamenode in interface ActiveNamenodeResolver
      Parameters:
      nsId - Nameservice identifier.
      address - The address the failed responded to the command.
      Throws:
      IOException - If the state store cannot be accessed.
    • updateActiveNamenode

      public void updateActiveNamenode(String nsId, InetSocketAddress address) throws IOException
      Description copied from interface: ActiveNamenodeResolver
      Report a successful, active NN address for a nameservice or blockPool.
      Specified by:
      updateActiveNamenode in interface ActiveNamenodeResolver
      Parameters:
      nsId - Nameservice identifier.
      address - The address the successful responded to the command.
      Throws:
      IOException - If the state store cannot be accessed.
    • getNamenodesForNameserviceId

      public List<? extends FederationNamenodeContext> getNamenodesForNameserviceId(String nsId, boolean listObserversFirst) throws IOException
      Description copied from interface: ActiveNamenodeResolver
      Returns a prioritized list of the most recent cached registration entries for a single nameservice ID. Returns an empty list if none are found. In the case of not observerRead Returns entries in preference of :
      • The most recent ACTIVE NN
      • The most recent OBSERVER NN
      • The most recent STANDBY NN
      • The most recent UNAVAILABLE NN
      In the case of observerRead Returns entries in preference of :
      • The most recent OBSERVER NN
      • The most recent ACTIVE NN
      • The most recent STANDBY NN
      • The most recent UNAVAILABLE NN
      Specified by:
      getNamenodesForNameserviceId in interface ActiveNamenodeResolver
      Parameters:
      nsId - Nameservice identifier.
      listObserversFirst - Observer read case, observer NN will be ranked first
      Returns:
      Prioritized list of namenode contexts.
      Throws:
      IOException - If the state store cannot be accessed.
    • getNamenodesForBlockPoolId

      public List<? extends FederationNamenodeContext> getNamenodesForBlockPoolId(String bpId) throws IOException
      Description copied from interface: ActiveNamenodeResolver
      Returns a prioritized list of the most recent cached registration entries for a single block pool ID. Returns an empty list if none are found. Returns entries in preference of:
      • The most recent ACTIVE NN
      • The most recent OBSERVER NN
      • The most recent STANDBY NN
      • The most recent UNAVAILABLE NN
      Specified by:
      getNamenodesForBlockPoolId in interface ActiveNamenodeResolver
      Parameters:
      bpId - Block pool identifier for the nameservice.
      Returns:
      Prioritized list of namenode contexts.
      Throws:
      IOException - If the state store cannot be accessed.
    • registerNamenode

      public boolean registerNamenode(NamenodeStatusReport report) throws IOException
      Description copied from interface: ActiveNamenodeResolver
      Register a namenode in the State Store.
      Specified by:
      registerNamenode in interface ActiveNamenodeResolver
      Parameters:
      report - Namenode status report.
      Returns:
      True if the node was registered and successfully committed to the data store.
      Throws:
      IOException - Throws exception if the namenode could not be registered.
    • getNamespaces

      public Set<FederationNamespaceInfo> getNamespaces() throws IOException
      Description copied from interface: ActiveNamenodeResolver
      Get a list of all namespaces that are registered and active in the federation.
      Specified by:
      getNamespaces in interface ActiveNamenodeResolver
      Returns:
      List of name spaces in the federation
      Throws:
      IOException - Throws exception if the namespace list is not available.
    • getDisabledNamespaces

      public Set<String> getDisabledNamespaces() throws IOException
      Description copied from interface: ActiveNamenodeResolver
      Get a list of all namespaces that are disabled.
      Specified by:
      getDisabledNamespaces in interface ActiveNamenodeResolver
      Returns:
      List of name spaces identifier in the federation
      Throws:
      IOException - If the disabled list is not available.
    • setRouterId

      public void setRouterId(String router)
      Description copied from interface: ActiveNamenodeResolver
      Assign a unique identifier for the parent router service. Required to report the status to the namenode resolver.
      Specified by:
      setRouterId in interface ActiveNamenodeResolver
      Parameters:
      router - Unique string identifier for the router.
    • rotateCache

      public void rotateCache(String nsId, FederationNamenodeContext namenode, boolean listObserversFirst)
      Rotate cache, make the current namenode have the lowest priority, to ensure that the current namenode will not be accessed first next time.
      Specified by:
      rotateCache in interface ActiveNamenodeResolver
      Parameters:
      nsId - name service id.
      namenode - namenode contexts.
      listObserversFirst - Observer read case, observer NN will be ranked first.