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 Summary
ConstructorsConstructorDescriptionMembershipNamenodeResolver(org.apache.hadoop.conf.Configuration conf, StateStoreService store) -
Method Summary
Modifier and TypeMethodDescriptionGet a list of all namespaces that are disabled.List<? extends FederationNamenodeContext>Returns a prioritized list of the most recent cached registration entries for a single block pool ID.List<? extends FederationNamenodeContext>getNamenodesForNameserviceId(String nsId, boolean listObserversFirst) Returns a prioritized list of the most recent cached registration entries for a single nameservice ID.Get a list of all namespaces that are registered and active in the federation.booleanloadCache(boolean force) Load the cache from the State Store.booleanregisterNamenode(NamenodeStatusReport report) Register a namenode in the State Store.voidrotateCache(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.voidsetRouterId(String router) Assign a unique identifier for the parent router service.voidupdateActiveNamenode(String nsId, InetSocketAddress address) Report a successful, active NN address for a nameservice or blockPool.voidupdateUnavailableNamenode(String nsId, InetSocketAddress address) Report a failed, unavailable NN address for a nameservice or blockPool.
-
Constructor Details
-
MembershipNamenodeResolver
public MembershipNamenodeResolver(org.apache.hadoop.conf.Configuration conf, StateStoreService store) throws IOException - Throws:
IOException
-
-
Method Details
-
loadCache
public boolean loadCache(boolean force) Description copied from interface:StateStoreCacheLoad the cache from the State Store. Called by the cache update service when the data has been reloaded.- Specified by:
loadCachein interfaceStateStoreCache- Parameters:
force- If we force the load.- Returns:
- If the cache was loaded successfully.
-
updateActiveNamenode
Description copied from interface:ActiveNamenodeResolverReport a successful, active NN address for a nameservice or blockPool.- Specified by:
updateActiveNamenodein interfaceActiveNamenodeResolver- 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:ActiveNamenodeResolverReturns 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
- The most recent OBSERVER NN
- The most recent ACTIVE NN
- The most recent STANDBY NN
- The most recent UNAVAILABLE NN
- Specified by:
getNamenodesForNameserviceIdin interfaceActiveNamenodeResolver- 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:ActiveNamenodeResolverReturns 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:
getNamenodesForBlockPoolIdin interfaceActiveNamenodeResolver- Parameters:
bpId- Block pool identifier for the nameservice.- Returns:
- Prioritized list of namenode contexts.
- Throws:
IOException- If the state store cannot be accessed.
-
registerNamenode
Description copied from interface:ActiveNamenodeResolverRegister a namenode in the State Store.- Specified by:
registerNamenodein interfaceActiveNamenodeResolver- 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
Description copied from interface:ActiveNamenodeResolverGet a list of all namespaces that are registered and active in the federation.- Specified by:
getNamespacesin interfaceActiveNamenodeResolver- Returns:
- List of name spaces in the federation
- Throws:
IOException- Throws exception if the namespace list is not available.
-
getDisabledNamespaces
Description copied from interface:ActiveNamenodeResolverGet a list of all namespaces that are disabled.- Specified by:
getDisabledNamespacesin interfaceActiveNamenodeResolver- Returns:
- List of name spaces identifier in the federation
- Throws:
IOException- If the disabled list is not available.
-
setRouterId
Description copied from interface:ActiveNamenodeResolverAssign a unique identifier for the parent router service. Required to report the status to the namenode resolver.- Specified by:
setRouterIdin interfaceActiveNamenodeResolver- 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:
rotateCachein interfaceActiveNamenodeResolver- Parameters:
nsId- name service id.namenode- namenode contexts.listObserversFirst- Observer read case, observer NN will be ranked first.
-