public class RouterRpcClient
extends java.lang.Object
Provides routers to invoke remote ClientProtocol methods and handle retries/failover.
| Constructor | Description |
|---|---|
RouterRpcClient(org.apache.hadoop.conf.Configuration conf,
Router router,
ActiveNamenodeResolver resolver,
RouterRpcMonitor monitor,
org.apache.hadoop.hdfs.server.federation.router.RouterStateIdContext routerStateIdContext) |
Create a router RPC client to manage remote procedure calls to NNs.
|
| Modifier and Type | Method | Description |
|---|---|---|
java.lang.Long |
getAcceptedPermitForNs(java.lang.String ns) |
|
java.lang.String |
getAcceptedPermitsPerNsJSON() |
JSON representation of the accepted permits for each nameservice.
|
java.lang.String |
getAsyncCallerPoolJson() |
JSON representation of the async caller thread pool.
|
java.lang.String |
getJSON() |
JSON representation of the connection pool.
|
ActiveNamenodeResolver |
getNamenodeResolver() |
Get the active namenode resolver used by this client.
|
int |
getNumActiveConnections() |
Total number of available sockets between the router and NNs.
|
int |
getNumActiveConnectionsRecently() |
Total number of active sockets between the router and NNs.
|
int |
getNumConnectionPools() |
Total number of open connection pools to a NN.
|
int |
getNumConnections() |
Total number of available sockets between the router and NNs.
|
int |
getNumCreatingConnections() |
Number of connections between the router and NNs being created sockets.
|
int |
getNumIdleConnections() |
Total number of idle sockets between the router and NNs.
|
java.lang.Long |
getRejectedPermitForNs(java.lang.String ns) |
|
java.lang.String |
getRejectedPermitsPerNsJSON() |
JSON representation of the rejected permits for each nameservice.
|
RouterRpcFairnessPolicyController |
getRouterRpcFairnessPolicyController() |
|
<T extends RemoteLocationContext> |
invokeAll(java.util.Collection<T> locations,
RemoteMethod method) |
Invoke method in all locations and return success if any succeeds.
|
<T extends RemoteLocationContext,R> |
invokeConcurrent(java.util.Collection<T> locations,
RemoteMethod method) |
Invoke multiple concurrent proxy calls to different clients.
|
<T extends RemoteLocationContext,R> |
invokeConcurrent(java.util.Collection<T> locations,
RemoteMethod method,
boolean requireResponse,
boolean standby) |
Invoke multiple concurrent proxy calls to different clients.
|
<T extends RemoteLocationContext,R> |
invokeConcurrent(java.util.Collection<T> locations,
RemoteMethod method,
boolean requireResponse,
boolean standby,
long timeOutMs,
java.lang.Class<R> clazz) |
Invokes multiple concurrent proxy calls to different clients.
|
<T extends RemoteLocationContext,R> |
invokeConcurrent(java.util.Collection<T> locations,
RemoteMethod method,
boolean requireResponse,
boolean standby,
java.lang.Class<R> clazz) |
Invokes multiple concurrent proxy calls to different clients.
|
<T extends RemoteLocationContext,R> |
invokeConcurrent(java.util.Collection<T> locations,
RemoteMethod method,
boolean standby,
long timeOutMs,
java.lang.Class<R> clazz) |
Invokes multiple concurrent proxy calls to different clients.
|
<T extends RemoteLocationContext,R> |
invokeConcurrent(java.util.Collection<T> locations,
RemoteMethod method,
java.lang.Class<R> clazz) |
Invoke multiple concurrent proxy calls to different clients.
|
java.lang.Object |
invokeMethod(org.apache.hadoop.security.UserGroupInformation ugi,
java.util.List<? extends FederationNamenodeContext> namenodes,
boolean useObserver,
java.lang.Class<?> protocol,
java.lang.reflect.Method method,
java.lang.Object... params) |
Invokes a method against the ClientProtocol proxy server.
|
<T> T |
invokeSequential(java.util.List<? extends RemoteLocationContext> locations,
RemoteMethod remoteMethod) |
Invokes sequential proxy calls to different locations.
|
<T> T |
invokeSequential(java.util.List<? extends RemoteLocationContext> locations,
RemoteMethod remoteMethod,
java.lang.Class<T> expectedResultClass,
java.lang.Object expectedResultValue) |
Invokes sequential proxy calls to different locations.
|
<R extends RemoteLocationContext,T> |
invokeSequential(RemoteMethod remoteMethod,
java.util.List<R> locations,
java.lang.Class<T> expectedResultClass,
java.lang.Object expectedResultValue) |
Invokes sequential proxy calls to different locations.
|
java.lang.Object |
invokeSingle(java.lang.String nsId,
RemoteMethod method) |
Invokes a ClientProtocol method against the specified namespace.
|
<T> T |
invokeSingle(java.lang.String nsId,
RemoteMethod method,
java.lang.Class<T> clazz) |
Invokes a remote method against the specified namespace.
|
<T> T |
invokeSingle(org.apache.hadoop.hdfs.protocol.ExtendedBlock extendedBlock,
RemoteMethod method,
java.lang.Class<T> clazz) |
Invokes a remote method against the specified extendedBlock.
|
<T> T |
invokeSingle(org.apache.hadoop.hdfs.protocol.ExtendedBlock block,
RemoteMethod method,
java.util.List<RemoteLocation> locations,
java.lang.Class<T> clazz) |
Invokes a ClientProtocol method.
|
<T> T |
invokeSingle(RemoteLocationContext location,
RemoteMethod remoteMethod,
java.lang.Class<T> clazz) |
Invokes a single proxy call for a single location.
|
java.lang.Object |
invokeSingleBlockPool(java.lang.String bpId,
RemoteMethod method) |
Invokes a ClientProtocol method.
|
static boolean |
isUnavailableException(java.io.IOException ioe) |
Check if the exception comes from an unavailable subcluster.
|
java.lang.String |
refreshFairnessPolicyController(org.apache.hadoop.conf.Configuration conf) |
Refreshes/changes the fairness policy controller implementation if possible
and returns the controller class name.
|
void |
shutdown() |
Shutdown the client.
|
public RouterRpcClient(org.apache.hadoop.conf.Configuration conf,
Router router,
ActiveNamenodeResolver resolver,
RouterRpcMonitor monitor,
org.apache.hadoop.hdfs.server.federation.router.RouterStateIdContext routerStateIdContext)
conf - Hdfs Configuration.router - A router using this RPC client.resolver - A NN resolver to determine the currently active NN in HA.monitor - Optional performance monitor.routerStateIdContext - the router state context object to hold the state ids for all
namespaces.public ActiveNamenodeResolver getNamenodeResolver()
public void shutdown()
public int getNumConnections()
public int getNumActiveConnections()
public int getNumIdleConnections()
public int getNumActiveConnectionsRecently()
public int getNumConnectionPools()
public int getNumCreatingConnections()
public java.lang.String getJSON()
public java.lang.String getAsyncCallerPoolJson()
public java.lang.String getRejectedPermitsPerNsJSON()
public java.lang.String getAcceptedPermitsPerNsJSON()
@VisibleForTesting
public java.lang.Object invokeMethod(org.apache.hadoop.security.UserGroupInformation ugi,
java.util.List<? extends FederationNamenodeContext> namenodes,
boolean useObserver,
java.lang.Class<?> protocol,
java.lang.reflect.Method method,
java.lang.Object... params)
throws java.net.ConnectException,
org.apache.hadoop.ipc.StandbyException,
java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
ugi - User group information.namenodes - A prioritized list of namenodes within the same
nameservice.useObserver - Whether to use observer namenodes.protocol - the protocol of the connection.method - Remote ClientProtocol method to invoke.params - Variable list of parameters matching the method.java.net.ConnectException - If it cannot connect to any Namenode.org.apache.hadoop.ipc.StandbyException - If all Namenodes are in Standby.java.io.IOException - If it cannot invoke the method.public static boolean isUnavailableException(java.io.IOException ioe)
ioe - IOException to check.public <T> T invokeSingle(org.apache.hadoop.hdfs.protocol.ExtendedBlock block,
RemoteMethod method,
java.util.List<RemoteLocation> locations,
java.lang.Class<T> clazz)
throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
T - The type of the remote method return.block - Block used to determine appropriate nameservice.method - The remote method and parameters to invoke.locations - The remote locations will be used.clazz - Class for the return type.java.io.IOException - If the invoke generated an error.public java.lang.Object invokeSingleBlockPool(java.lang.String bpId,
RemoteMethod method)
throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
bpId - Block pool identifier.method - The remote method and parameters to invoke.java.io.IOException - If the invoke generated an error.public java.lang.Object invokeSingle(java.lang.String nsId,
RemoteMethod method)
throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
nsId - Target namespace for the method.method - The remote method and parameters to invoke.java.io.IOException - If the invoke generated an error.public <T> T invokeSingle(java.lang.String nsId,
RemoteMethod method,
java.lang.Class<T> clazz)
throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
T - The type of the remote method return.nsId - Target namespace for the method.method - The remote method and parameters to invoke.clazz - Class for the return type.java.io.IOException - If the invoke generated an error.public <T> T invokeSingle(org.apache.hadoop.hdfs.protocol.ExtendedBlock extendedBlock,
RemoteMethod method,
java.lang.Class<T> clazz)
throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
T - The type of the remote method return.extendedBlock - Target extendedBlock for the method.method - The remote method and parameters to invoke.clazz - Class for the return type.java.io.IOException - If the invoke generated an error.public <T> T invokeSingle(RemoteLocationContext location, RemoteMethod remoteMethod, java.lang.Class<T> clazz) throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
T - The type of the remote method return.location - RemoteLocation to invoke.remoteMethod - The remote method and parameters to invoke.clazz - Class for the return type.java.io.IOException - If the invoke generated an error.public <T> T invokeSequential(java.util.List<? extends RemoteLocationContext> locations, RemoteMethod remoteMethod) throws java.io.IOException
T - The type of the remote method return.locations - List of locations/nameservices to call concurrently.remoteMethod - The remote method and parameters to invoke.java.io.IOException - if the success condition is not met and one of the RPC
calls generated a remote exception.public <T> T invokeSequential(java.util.List<? extends RemoteLocationContext> locations, RemoteMethod remoteMethod, java.lang.Class<T> expectedResultClass, java.lang.Object expectedResultValue) throws java.io.IOException
T - The type of the remote method return.locations - List of locations/nameservices to call concurrently.remoteMethod - The remote method and parameters to invoke.expectedResultClass - In order to be considered a positive result, the
return type must be of this class.expectedResultValue - In order to be considered a positive result, the
return value must equal the value of this object.java.io.IOException - if the success condition is not met, return the first
remote exception generated.public <R extends RemoteLocationContext,T> RemoteResult invokeSequential(RemoteMethod remoteMethod, java.util.List<R> locations, java.lang.Class<T> expectedResultClass, java.lang.Object expectedResultValue) throws java.io.IOException
R - The type of the remote location.T - The type of the remote method return.remoteMethod - The remote method and parameters to invoke.locations - List of locations/nameservices to call concurrently.expectedResultClass - In order to be considered a positive result, the
return type must be of this class.expectedResultValue - In order to be considered a positive result, the
return value must equal the value of this object.java.io.IOException - if the success condition is not met, return the first
remote exception generated.public <T extends RemoteLocationContext> boolean invokeAll(java.util.Collection<T> locations, RemoteMethod method) throws java.io.IOException
T - The type of the remote location.locations - List of remote locations to call concurrently.method - The remote method and parameters to invoke.java.io.IOException - If any of the calls return an exception.public <T extends RemoteLocationContext,R> void invokeConcurrent(java.util.Collection<T> locations, RemoteMethod method) throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
T - The type of the remote location.R - The type of the remote method return.locations - List of remote locations to call concurrently.method - The remote method and parameters to invoke.java.io.IOException - If all the calls throw an exception.public <T extends RemoteLocationContext,R> java.util.Map<T,R> invokeConcurrent(java.util.Collection<T> locations, RemoteMethod method, java.lang.Class<R> clazz) throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
T - The type of the remote location.R - The type of the remote method return.locations - List of remote locations to call concurrently.method - The remote method and parameters to invoke.clazz - Type of the remote return type.java.io.IOException - If all the calls throw an exception.public <T extends RemoteLocationContext,R> void invokeConcurrent(java.util.Collection<T> locations, RemoteMethod method, boolean requireResponse, boolean standby) throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
T - The type of the remote location.R - The type of the remote method return.locations - List of remote locations to call concurrently.method - The remote method and parameters to invoke.requireResponse - If true an exception will be thrown if all calls do
not complete. If false exceptions are ignored and all data results
successfully received are returned.standby - If the requests should go to the standby namenodes too.java.io.IOException - If all the calls throw an exception.public <T extends RemoteLocationContext,R> java.util.Map<T,R> invokeConcurrent(java.util.Collection<T> locations, RemoteMethod method, boolean requireResponse, boolean standby, java.lang.Class<R> clazz) throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
T - The type of the remote location.R - The type of the remote method return.locations - List of remote locations to call concurrently.method - The remote method and parameters to invoke.requireResponse - If true an exception will be thrown if all calls do
not complete. If false exceptions are ignored and all data results
successfully received are returned.standby - If the requests should go to the standby namenodes too.clazz - Type of the remote return type.java.io.IOException - If requiredResponse=true and any of the calls throw an
exception.public <T extends RemoteLocationContext,R> java.util.Map<T,R> invokeConcurrent(java.util.Collection<T> locations, RemoteMethod method, boolean requireResponse, boolean standby, long timeOutMs, java.lang.Class<R> clazz) throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
T - The type of the remote location.R - The type of the remote method return.locations - List of remote locations to call concurrently.method - The remote method and parameters to invoke.requireResponse - If true an exception will be thrown if all calls do
not complete. If false exceptions are ignored and all data results
successfully received are returned.standby - If the requests should go to the standby namenodes too.timeOutMs - Timeout for each individual call.clazz - Type of the remote return type.java.io.IOException - If requiredResponse=true and any of the calls throw an
exception.public <T extends RemoteLocationContext,R> java.util.List<RemoteResult<T,R>> invokeConcurrent(java.util.Collection<T> locations, RemoteMethod method, boolean standby, long timeOutMs, java.lang.Class<R> clazz) throws java.io.IOException
Re-throws exceptions generated by the remote RPC call as either RemoteException or IOException.
T - The type of the remote location.R - The type of the remote method returnlocations - List of remote locations to call concurrently.method - The remote method and parameters to invoke.standby - If the requests should go to the standby namenodes too.timeOutMs - Timeout for each individual call.clazz - Type of the remote return type.java.io.IOException - If there are errors invoking the method.public RouterRpcFairnessPolicyController getRouterRpcFairnessPolicyController()
public java.lang.Long getRejectedPermitForNs(java.lang.String ns)
public java.lang.Long getAcceptedPermitForNs(java.lang.String ns)
public java.lang.String refreshFairnessPolicyController(org.apache.hadoop.conf.Configuration conf)
conf - ConfigurationCopyright © 2008–2025 Apache Software Foundation. All rights reserved.