Class Router
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.hdfs.server.common.TokenVerifier<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>,org.apache.hadoop.service.Service
For the federated interface, the Router receives a client request, checks the
State Store for the correct subcluster, and forwards the request to the
active Namenode of that subcluster. The reply from the Namenode then flows in
the opposite direction. The Routers are stateless and can be behind a load
balancer. HDFS clients connect to the router using the same interfaces as are
used to communicate with a namenode, namely the ClientProtocol RPC interface
and the WebHdfs HTTP interface exposed by the router. RouterRpcServer
RouterHttpServer
For NameNode heartbeat, 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 State Store. Note that this is an
optional role as a Router can be independent of any subcluster.
StateStoreService NamenodeHeartbeatService
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.service.CompositeService
org.apache.hadoop.service.CompositeService.CompositeServiceShutdownHookNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
Fields inherited from class org.apache.hadoop.service.CompositeService
STOP_ONLY_STARTED_SERVICES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected RouterAdminServerCreate a new router admin server to handle the router admin interface.protected RouterHttpServerCreate an HTTP server for this Router.Create a new status updater for the local Namenode.protected NamenodeHeartbeatServicecreateNamenodeHeartbeatService(String nsId, String nnId) Create a heartbeat monitor for a particular Namenode.protected NamenodeHeartbeatServicecreateNamenodeHeartbeatService(String nsId, String nnId, String resolvedHost) protected Collection<NamenodeHeartbeatService>Create each of the services that will monitor a Namenode.Create a new Router RPC server to proxy ClientProtocol requests.Get router admin server.Get the current Admin socket address for the router.Get the current HTTP socket address for the router.Get the federation metrics.Get the namenode metrics.Get the namenode resolver for a subcluster.Get route quota manager.Get the metrics system for the Router Client.Unique ID for the router, typically the hostname:port string for the router's RPC server.Get the metrics system for the Router.Get the status of the router.Get the state store interface for the router heartbeats.Get the Router RPC server.Get the current RPC socket address for the router.longGet the start date of the Router.Get the State Store service.Get the subcluster resolver for files.booleanCheck if the quota system is enabled in Router.booleanisRouterState(RouterServiceState routerState) Compare router state.protected voidserviceInit(org.apache.hadoop.conf.Configuration configuration) protected voidprotected voidprotected voidsetAdminServerAddress(InetSocketAddress address) Set the current Admin socket for the router.voidsetConf(org.apache.hadoop.conf.Configuration conf) Set router configuration.voidsetRouterId(String id) Sets a unique ID for this router.protected voidsetRpcServerAddress(InetSocketAddress address) Set the current RPC socket for the router.voidshutDown()Shutdown the router.voidupdateRouterState(RouterServiceState newState) Update the router state and heartbeat to the state store.voidverifyToken(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier tokenId, byte[] password) Methods inherited from class org.apache.hadoop.service.CompositeService
addIfService, addService, getServices, removeServiceMethods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
-
Constructor Details
-
Router
public Router()
-
-
Method Details
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
shutDown
public void shutDown()Shutdown the router. -
createRpcServer
Create a new Router RPC server to proxy ClientProtocol requests.- Returns:
- New Router RPC Server.
- Throws:
IOException- If the router RPC server was not started.
-
getRpcServer
Get the Router RPC server.- Returns:
- Router RPC server.
-
setRpcServerAddress
Set the current RPC socket for the router.- Parameters:
address- RPC address.
-
getRpcServerAddress
Get the current RPC socket address for the router.- Returns:
- InetSocketAddress
-
createAdminServer
Create a new router admin server to handle the router admin interface.- Returns:
- RouterAdminServer
- Throws:
IOException- If the admin server was not successfully started.
-
setAdminServerAddress
Set the current Admin socket for the router.- Parameters:
address- Admin RPC address.
-
getAdminServerAddress
Get the current Admin socket address for the router.- Returns:
- InetSocketAddress Admin address.
-
createHttpServer
Create an HTTP server for this Router.- Returns:
- HTTP server for this Router.
-
getHttpServerAddress
Get the current HTTP socket address for the router.- Returns:
- InetSocketAddress HTTP address.
-
verifyToken
public void verifyToken(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier tokenId, byte[] password) throws IOException - Specified by:
verifyTokenin interfaceorg.apache.hadoop.hdfs.server.common.TokenVerifier<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>- Throws:
IOException
-
createNamenodeHeartbeatServices
Create each of the services that will monitor a Namenode.- Returns:
- List of heartbeat services.
-
createLocalNamenodeHeartbeatService
Create a new status updater for the local Namenode.- Returns:
- Updater of the status for the local Namenode.
-
createNamenodeHeartbeatService
Create a heartbeat monitor for a particular Namenode.- Parameters:
nsId- Identifier of the nameservice to monitor.nnId- Identifier of the namenode (HA) to monitor.- Returns:
- Updater of the status for the specified Namenode.
-
createNamenodeHeartbeatService
protected NamenodeHeartbeatService createNamenodeHeartbeatService(String nsId, String nnId, String resolvedHost) -
updateRouterState
Update the router state and heartbeat to the state store.- Parameters:
newState- The new router state.
-
getRouterState
Get the status of the router.- Returns:
- Status of the router.
-
isRouterState
Compare router state.- Parameters:
routerState- the router service state.- Returns:
- true if the given router state is same as the state maintained by the router object.
-
getStateStore
Get the State Store service.- Returns:
- State Store service.
-
getRouterMetrics
Get the metrics system for the Router.- Returns:
- Router metrics.
-
getRouterClientMetrics
Get the metrics system for the Router Client.- Returns:
- Router Client metrics.
-
getMetrics
Get the federation metrics.- Returns:
- Federation metrics.
-
getNamenodeMetrics
Get the namenode metrics.- Returns:
- the namenode metrics.
- Throws:
IOException- if the namenode metrics are not initialized.
-
getSubclusterResolver
Get the subcluster resolver for files.- Returns:
- Subcluster resolver for files.
-
getNamenodeResolver
Get the namenode resolver for a subcluster.- Returns:
- The namenode resolver for a subcluster.
-
getRouterStateManager
Get the state store interface for the router heartbeats.- Returns:
- RouterStore state store API handle.
-
getStartTime
public long getStartTime()Get the start date of the Router.- Specified by:
getStartTimein interfaceorg.apache.hadoop.service.Service- Overrides:
getStartTimein classorg.apache.hadoop.service.AbstractService- Returns:
- Start date of the router.
-
getRouterId
Unique ID for the router, typically the hostname:port string for the router's RPC server. This ID may be null on router startup before the RPC server has bound to a port.- Returns:
- Router identifier.
-
setRouterId
Sets a unique ID for this router.- Parameters:
id- Identifier of the Router.
-
isQuotaEnabled
public boolean isQuotaEnabled()Check if the quota system is enabled in Router.- Returns:
- True if the quota system is enabled in Router.
-
getQuotaManager
Get route quota manager.- Returns:
- RouterQuotaManager Quota manager.
-
getAdminServer
Get router admin server.- Returns:
- Null if admin is not enabled.
-
setConf
@VisibleForTesting public void setConf(org.apache.hadoop.conf.Configuration conf) Set router configuration.- Parameters:
conf- the configuration.
-