Class ConnectionManager
java.lang.Object
org.apache.hadoop.hdfs.server.federation.router.ConnectionManager
Implements a pool of connections for the
Router to be able to open
many connections to many Namenodes.-
Constructor Summary
ConstructorsConstructorDescriptionConnectionManager(org.apache.hadoop.conf.Configuration config) ConnectionManager(org.apache.hadoop.conf.Configuration config, RouterStateIdContext routerStateIdContext) Creates a proxy client connection pool manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stop the connection manager by closing all the pools.voidgetConnection(org.apache.hadoop.security.UserGroupInformation ugi, String nnAddress, Class<?> protocol, String nsId) Fetches the next available proxy client in the pool.getJSON()Get a JSON representation of the connection pool.intGet number of active connections.intGet number of recently active connections.intGet the number of connection pools.intGet number of open connections.intGet the number of connections to be created.intGet number of idle connections.voidstart()Start the connection manager.
-
Constructor Details
-
ConnectionManager
public ConnectionManager(org.apache.hadoop.conf.Configuration config) -
ConnectionManager
public ConnectionManager(org.apache.hadoop.conf.Configuration config, RouterStateIdContext routerStateIdContext) Creates a proxy client connection pool manager.- Parameters:
config- Configuration for the connections.routerStateIdContext- Federated namespace context for router.
-
-
Method Details
-
start
public void start()Start the connection manager. -
close
public void close()Stop the connection manager by closing all the pools. -
closeConnectionCreator
@VisibleForTesting public void closeConnectionCreator() -
getConnection
public ConnectionContext getConnection(org.apache.hadoop.security.UserGroupInformation ugi, String nnAddress, Class<?> protocol, String nsId) throws IOException Fetches the next available proxy client in the pool. Each client connection is reserved for a single user and cannot be reused until free.- Parameters:
ugi- User group information.nnAddress- Namenode address for the connection.protocol- Protocol for the connection.nsId- Nameservice identity.- Returns:
- Proxy client to connect to nnId as UGI.
- Throws:
IOException- If the connection cannot be obtained.
-
getNumConnectionPools
public int getNumConnectionPools()Get the number of connection pools.- Returns:
- Number of connection pools.
-
getNumConnections
public int getNumConnections()Get number of open connections.- Returns:
- Number of open connections.
-
getNumActiveConnections
public int getNumActiveConnections()Get number of active connections.- Returns:
- Number of active connections.
-
getNumIdleConnections
public int getNumIdleConnections()Get number of idle connections.- Returns:
- Number of active connections.
-
getNumActiveConnectionsRecently
public int getNumActiveConnectionsRecently()Get number of recently active connections.- Returns:
- Number of recently active connections.
-
getNumCreatingConnections
public int getNumCreatingConnections()Get the number of connections to be created.- Returns:
- Number of connections to be created.
-
getJSON
Get a JSON representation of the connection pool.- Returns:
- JSON representation of all the connection pools.
-