Package org.apache.hadoop.hbase.util
Class ConnectionCache
java.lang.Object
org.apache.hadoop.hbase.util.ConnectionCache
A utility to store user specific HConnections in memory. There is a chore to clean up connections
idle for too long. This class is used by REST server and Thrift server to support authentication
and impersonation.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ChoreService
private final org.apache.hadoop.conf.Configuration
private final Map<String,
ConnectionCache.ConnectionInfo> private final ThreadLocal<String>
private static final org.slf4j.Logger
private final org.apache.hadoop.security.UserGroupInformation
private final String
private final UserProvider
-
Constructor Summary
ConstructorDescriptionConnectionCache
(org.apache.hadoop.conf.Configuration conf, UserProvider userProvider, int cleanInterval, int maxIdleTime) -
Method Summary
Modifier and TypeMethodDescriptiongetAdmin()
Caller doesn't close the admin afterwards.Returns Cluster ID for the HBase cluster or null if there is an err making the connection.(package private) ConnectionCache.ConnectionInfo
Get the cached connection for the current user.Get the current thread local effective usergetRegionLocator
(byte[] tableName) Retrieve a regionLocator for the table.Caller closes the table afterwards.void
setEffectiveUser
(String user) Set the current thread local effective uservoid
shutdown()
Called when cache is no longer needed so that it can perform cleanup operationsboolean
Updates the access time for the current connection.
-
Field Details
-
LOG
-
connections
-
locker
-
realUserName
-
realUser
-
userProvider
-
conf
-
choreService
-
effectiveUserNames
-
-
Constructor Details
-
ConnectionCache
public ConnectionCache(org.apache.hadoop.conf.Configuration conf, UserProvider userProvider, int cleanInterval, int maxIdleTime) throws IOException - Throws:
IOException
-
-
Method Details
-
setEffectiveUser
Set the current thread local effective user -
getEffectiveUser
Get the current thread local effective user -
shutdown
Called when cache is no longer needed so that it can perform cleanup operations -
getAdmin
Caller doesn't close the admin afterwards. We need to manage it and close it properly.- Throws:
IOException
-
getTable
Caller closes the table afterwards.- Throws:
IOException
-
getRegionLocator
Retrieve a regionLocator for the table. The user should close the RegionLocator.- Throws:
IOException
-
getCurrentConnection
Get the cached connection for the current user. If none or timed out, create a new one.- Throws:
IOException
-
updateConnectionAccessTime
Updates the access time for the current connection. Used to keep Connections alive for long-lived scanners.- Returns:
- whether we successfully updated the last access time
-
getClusterId
Returns Cluster ID for the HBase cluster or null if there is an err making the connection.
-