java.io.Closeable, java.lang.AutoCloseable, org.apache.hadoop.hdfs.server.common.TokenVerifier<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>, org.apache.hadoop.service.Service@Private
@Evolving
public class Router
extends org.apache.hadoop.service.CompositeService
implements org.apache.hadoop.hdfs.server.common.TokenVerifier<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>
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
| Constructor | Description |
|---|---|
Router() |
| Modifier and Type | Method | Description |
|---|---|---|
protected RouterAdminServer |
createAdminServer() |
Create a new router admin server to handle the router admin interface.
|
protected RouterHttpServer |
createHttpServer() |
Create an HTTP server for this Router.
|
NamenodeHeartbeatService |
createLocalNamenodeHeartbeatService() |
Create a new status updater for the local Namenode.
|
protected NamenodeHeartbeatService |
createNamenodeHeartbeatService(java.lang.String nsId,
java.lang.String nnId) |
Create a heartbeat monitor for a particular Namenode.
|
protected NamenodeHeartbeatService |
createNamenodeHeartbeatService(java.lang.String nsId,
java.lang.String nnId,
java.lang.String resolvedHost) |
|
protected java.util.Collection<NamenodeHeartbeatService> |
createNamenodeHeartbeatServices() |
Create each of the services that will monitor a Namenode.
|
protected RouterRpcServer |
createRpcServer() |
Create a new Router RPC server to proxy ClientProtocol requests.
|
RouterAdminServer |
getAdminServer() |
Get router admin server.
|
java.net.InetSocketAddress |
getAdminServerAddress() |
Get the current Admin socket address for the router.
|
java.net.InetSocketAddress |
getHttpServerAddress() |
Get the current HTTP socket address for the router.
|
RBFMetrics |
getMetrics() |
Get the federation metrics.
|
NamenodeBeanMetrics |
getNamenodeMetrics() |
Get the namenode metrics.
|
ActiveNamenodeResolver |
getNamenodeResolver() |
Get the namenode resolver for a subcluster.
|
RouterQuotaManager |
getQuotaManager() |
Get route quota manager.
|
RouterClientMetrics |
getRouterClientMetrics() |
Get the metrics system for the Router Client.
|
java.lang.String |
getRouterId() |
Unique ID for the router, typically the hostname:port string for the
router's RPC server.
|
RouterMetrics |
getRouterMetrics() |
Get the metrics system for the Router.
|
RouterServiceState |
getRouterState() |
Get the status of the router.
|
RouterStore |
getRouterStateManager() |
Get the state store interface for the router heartbeats.
|
RouterRpcServer |
getRpcServer() |
Get the Router RPC server.
|
java.net.InetSocketAddress |
getRpcServerAddress() |
Get the current RPC socket address for the router.
|
long |
getStartTime() |
Get the start date of the Router.
|
StateStoreService |
getStateStore() |
Get the State Store service.
|
FileSubclusterResolver |
getSubclusterResolver() |
Get the subcluster resolver for files.
|
boolean |
isQuotaEnabled() |
Check if the quota system is enabled in Router.
|
boolean |
isRouterState(RouterServiceState routerState) |
Compare router state.
|
protected void |
serviceInit(org.apache.hadoop.conf.Configuration configuration) |
|
protected void |
serviceStart() |
|
protected void |
serviceStop() |
|
protected void |
setAdminServerAddress(java.net.InetSocketAddress address) |
Set the current Admin socket for the router.
|
void |
setConf(org.apache.hadoop.conf.Configuration conf) |
Set router configuration.
|
void |
setRouterId(java.lang.String id) |
Sets a unique ID for this router.
|
protected void |
setRpcServerAddress(java.net.InetSocketAddress address) |
Set the current RPC socket for the router.
|
void |
shutDown() |
Shutdown the router.
|
void |
updateRouterState(RouterServiceState newState) |
Update the router state and heartbeat to the state store.
|
void |
verifyToken(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier tokenId,
byte[] password) |
addIfService, addService, getServices, removeServiceclose, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStopprotected void serviceInit(org.apache.hadoop.conf.Configuration configuration)
throws java.lang.Exception
serviceInit in class org.apache.hadoop.service.CompositeServicejava.lang.Exceptionprotected void serviceStart()
throws java.lang.Exception
serviceStart in class org.apache.hadoop.service.CompositeServicejava.lang.Exceptionprotected void serviceStop()
throws java.lang.Exception
serviceStop in class org.apache.hadoop.service.CompositeServicejava.lang.Exceptionpublic void shutDown()
protected RouterRpcServer createRpcServer() throws java.io.IOException
java.io.IOException - If the router RPC server was not started.public RouterRpcServer getRpcServer()
protected void setRpcServerAddress(java.net.InetSocketAddress address)
address - RPC address.public java.net.InetSocketAddress getRpcServerAddress()
protected RouterAdminServer createAdminServer() throws java.io.IOException
java.io.IOException - If the admin server was not successfully started.protected void setAdminServerAddress(java.net.InetSocketAddress address)
address - Admin RPC address.public java.net.InetSocketAddress getAdminServerAddress()
protected RouterHttpServer createHttpServer()
public java.net.InetSocketAddress getHttpServerAddress()
public void verifyToken(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier tokenId,
byte[] password)
throws java.io.IOException
verifyToken in interface org.apache.hadoop.hdfs.server.common.TokenVerifier<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>java.io.IOExceptionprotected java.util.Collection<NamenodeHeartbeatService> createNamenodeHeartbeatServices()
@VisibleForTesting public NamenodeHeartbeatService createLocalNamenodeHeartbeatService()
protected NamenodeHeartbeatService createNamenodeHeartbeatService(java.lang.String nsId, java.lang.String nnId)
nsId - Identifier of the nameservice to monitor.nnId - Identifier of the namenode (HA) to monitor.protected NamenodeHeartbeatService createNamenodeHeartbeatService(java.lang.String nsId, java.lang.String nnId, java.lang.String resolvedHost)
public void updateRouterState(RouterServiceState newState)
newState - The new router state.public RouterServiceState getRouterState()
public boolean isRouterState(RouterServiceState routerState)
routerState - the router service state.public StateStoreService getStateStore()
public RouterMetrics getRouterMetrics()
public RouterClientMetrics getRouterClientMetrics()
public RBFMetrics getMetrics()
public NamenodeBeanMetrics getNamenodeMetrics() throws java.io.IOException
java.io.IOException - if the namenode metrics are not initialized.public FileSubclusterResolver getSubclusterResolver()
public ActiveNamenodeResolver getNamenodeResolver()
public RouterStore getRouterStateManager()
public long getStartTime()
getStartTime in interface org.apache.hadoop.service.ServicegetStartTime in class org.apache.hadoop.service.AbstractServicepublic java.lang.String getRouterId()
public void setRouterId(java.lang.String id)
id - Identifier of the Router.public boolean isQuotaEnabled()
public RouterQuotaManager getQuotaManager()
public RouterAdminServer getAdminServer()
@VisibleForTesting public void setConf(org.apache.hadoop.conf.Configuration conf)
conf - the configuration.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.