Class ConnectionManager

java.lang.Object
org.apache.hadoop.hdfs.server.federation.router.ConnectionManager

public class ConnectionManager extends Object
Implements a pool of connections for the Router to be able to open many connections to many Namenodes.
  • 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

      public String getJSON()
      Get a JSON representation of the connection pool.
      Returns:
      JSON representation of all the connection pools.