Class ConnectionContext
java.lang.Object
org.apache.hadoop.hdfs.server.federation.router.ConnectionContext
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:
ClientProtocolNamenodeProtocol
-
Constructor Summary
ConstructorsConstructorDescriptionConnectionContext(org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo<?> connection, org.apache.hadoop.conf.Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidclose(boolean force) Close a connection.org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo<?>Get the connection client.booleanisActive()Check if the connection is active.booleanCheck if the connection is/was active recently.booleanisClosed()Check if the connection is closed.booleanisIdle()Check if the connection is idle.booleanisUsable()Check if the connection can be used.voidrelease()Release this connection.toString()
-
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
-