Class ConnectionContext

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

public class ConnectionContext extends Object
Context to track a connection in a ConnectionPool. When a client uses a connection, it increments a counter to mark it as active. Once the client is done with the connection, it decreases the counter. It also takes care of closing the connection once is not active. The protocols currently used are:
  • ClientProtocol
  • NamenodeProtocol
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConnectionContext(org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo<?> connection, org.apache.hadoop.conf.Configuration conf)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    close(boolean force)
    Close a connection.
    org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo<?>
    Get the connection client.
    boolean
    Check if the connection is active.
    boolean
    Check if the connection is/was active recently.
    boolean
    Check if the connection is closed.
    boolean
    Check if the connection is idle.
    boolean
    Check if the connection can be used.
    void
    Release this connection.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ConnectionContext

      public ConnectionContext(org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo<?> connection, org.apache.hadoop.conf.Configuration conf)
  • Method Details

    • isActive

      public boolean isActive()
      Check if the connection is active.
      Returns:
      True if the connection is active.
    • isActiveRecently

      public boolean isActiveRecently()
      Check if the connection is/was active recently.
      Returns:
      True if the connection is active or was active in the past period of time.
    • isClosed

      public boolean isClosed()
      Check if the connection is closed.
      Returns:
      If the connection is closed.
    • isUsable

      public boolean isUsable()
      Check if the connection can be used. It checks if the connection is used by another thread or already closed.
      Returns:
      True if the connection can be used.
    • isIdle

      public boolean isIdle()
      Check if the connection is idle. It checks if the connection is not used by another thread.
      Returns:
      True if the connection is not used by another thread.
    • getClient

      public org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo<?> getClient()
      Get the connection client.
      Returns:
      Connection client.
    • release

      public void release()
      Release this connection.
    • close

      public void close(boolean force)
      Close a connection. Only idle connections can be closed since the RPC proxy would be shut down immediately.
      Parameters:
      force - whether the connection should be closed anyway.
    • close

      public void close()
    • toString

      public String toString()
      Overrides:
      toString in class Object