@InterfaceAudience.Private class ConnectionManager extends Object
HConnection
s.Modifier and Type | Class and Description |
---|---|
(package private) static class |
ConnectionManager.HConnectionImplementation
Encapsulates connection to zookeeper and regionservers.
|
(package private) static class |
ConnectionManager.NoNonceGenerator
Dummy nonce generator for disabled nonces.
|
(package private) static class |
ConnectionManager.ServerErrorTracker
The record of errors for servers.
|
Modifier and Type | Field and Description |
---|---|
private static String |
CLIENT_NONCES_ENABLED_KEY |
(package private) static Map<HConnectionKey,ConnectionManager.HConnectionImplementation> |
CONNECTION_INSTANCES |
(package private) static org.apache.commons.logging.Log |
LOG |
static int |
MAX_CACHED_CONNECTION_INSTANCES |
private static NonceGenerator |
nonceGenerator
Global nonceGenerator shared per client.Currently there's no reason to limit its scope.
|
private static Object |
nonceGeneratorCreateLock
The nonce generator lock.
|
private static String |
RESOLVE_HOSTNAME_ON_FAIL_KEY |
static String |
RETRIES_BY_SERVER_KEY |
Modifier | Constructor and Description |
---|---|
private |
ConnectionManager() |
Modifier and Type | Method and Description |
---|---|
static HConnection |
createConnection(org.apache.hadoop.conf.Configuration conf)
Create a new HConnection instance using the passed
conf instance. |
(package private) static HConnection |
createConnection(org.apache.hadoop.conf.Configuration conf,
boolean managed)
Deprecated.
|
(package private) static ClusterConnection |
createConnection(org.apache.hadoop.conf.Configuration conf,
boolean managed,
ExecutorService pool,
User user)
Deprecated.
|
static HConnection |
createConnection(org.apache.hadoop.conf.Configuration conf,
ExecutorService pool)
Create a new HConnection instance using the passed
conf instance. |
static HConnection |
createConnection(org.apache.hadoop.conf.Configuration conf,
ExecutorService pool,
User user)
Create a new HConnection instance using the passed
conf instance. |
static HConnection |
createConnection(org.apache.hadoop.conf.Configuration conf,
User user)
Create a new HConnection instance using the passed
conf instance. |
(package private) static ClusterConnection |
createConnectionInternal(org.apache.hadoop.conf.Configuration conf) |
static void |
deleteAllConnections()
Deprecated.
kept for backward compatibility, but the behavior is broken. HBASE-8983
|
static void |
deleteAllConnections(boolean staleConnection)
Deprecated.
|
static void |
deleteConnection(org.apache.hadoop.conf.Configuration conf)
Deprecated.
|
private static void |
deleteConnection(HConnection connection,
boolean staleConnection)
Deprecated.
|
private static void |
deleteConnection(HConnectionKey connectionKey,
boolean staleConnection)
Deprecated.
|
static void |
deleteStaleConnection(HConnection connection)
Deprecated.
|
static <T> T |
execute(HConnectable<T> connectable)
This convenience method invokes the given
HConnectable.connect(org.apache.hadoop.hbase.client.HConnection)
implementation using a HConnection instance that lasts just for the
duration of the invocation. |
static HConnection |
getConnection(org.apache.hadoop.conf.Configuration conf)
Deprecated.
|
(package private) static ClusterConnection |
getConnectionInternal(org.apache.hadoop.conf.Configuration conf) |
(package private) static NonceGenerator |
injectNonceGeneratorForTesting(ClusterConnection conn,
NonceGenerator cnm) |
static final org.apache.commons.logging.Log LOG
public static final String RETRIES_BY_SERVER_KEY
private static final String CLIENT_NONCES_ENABLED_KEY
private static final String RESOLVE_HOSTNAME_ON_FAIL_KEY
static final Map<HConnectionKey,ConnectionManager.HConnectionImplementation> CONNECTION_INSTANCES
public static final int MAX_CACHED_CONNECTION_INSTANCES
private static volatile NonceGenerator nonceGenerator
private static Object nonceGeneratorCreateLock
static NonceGenerator injectNonceGeneratorForTesting(ClusterConnection conn, NonceGenerator cnm)
conn
- The connection for which to replace the generator.cnm
- Replaces the nonce generator used, for testing.@Deprecated public static HConnection getConnection(org.apache.hadoop.conf.Configuration conf) throws IOException
conf
configuration instance.
If no current connection exists, method creates a new connection and keys it using
connection-specific properties from the passed Configuration
; see
HConnectionKey
.conf
- configurationconf
ZooKeeperConnectionException
IOException
static ClusterConnection getConnectionInternal(org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public static HConnection createConnection(org.apache.hadoop.conf.Configuration conf) throws IOException
conf
instance.
Note: This bypasses the usual HConnection life cycle management done by
getConnection(Configuration)
. The caller is responsible for
calling Connection.close()
on the returned connection instance.
This is the recommended way to create HConnections.
HConnection connection = ConnectionManagerInternal.createConnection(conf);
HTableInterface table = connection.getTable("mytable");
table.get(...);
...
table.close();
connection.close();
conf
- configurationconf
ZooKeeperConnectionException
IOException
static ClusterConnection createConnectionInternal(org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public static HConnection createConnection(org.apache.hadoop.conf.Configuration conf, ExecutorService pool) throws IOException
conf
instance.
Note: This bypasses the usual HConnection life cycle management done by
getConnection(Configuration)
. The caller is responsible for
calling Connection.close()
on the returned connection instance.
This is the recommended way to create HConnections.
ExecutorService pool = ...;
HConnection connection = HConnectionManager.createConnection(conf, pool);
HTableInterface table = connection.getTable("mytable");
table.get(...);
...
table.close();
connection.close();
conf
- configurationpool
- the thread pool to use for batch operation in HTables used via this HConnectionconf
ZooKeeperConnectionException
IOException
public static HConnection createConnection(org.apache.hadoop.conf.Configuration conf, User user) throws IOException
conf
instance.
Note: This bypasses the usual HConnection life cycle management done by
getConnection(Configuration)
. The caller is responsible for
calling Connection.close()
on the returned connection instance.
This is the recommended way to create HConnections.
ExecutorService pool = ...;
HConnection connection = HConnectionManager.createConnection(conf, pool);
HTableInterface table = connection.getTable("mytable");
table.get(...);
...
table.close();
connection.close();
conf
- configurationuser
- the user the connection is forconf
ZooKeeperConnectionException
IOException
public static HConnection createConnection(org.apache.hadoop.conf.Configuration conf, ExecutorService pool, User user) throws IOException
conf
instance.
Note: This bypasses the usual HConnection life cycle management done by
getConnection(Configuration)
. The caller is responsible for
calling Connection.close()
on the returned connection instance.
This is the recommended way to create HConnections.
ExecutorService pool = ...;
HConnection connection = HConnectionManager.createConnection(conf, pool);
HTableInterface table = connection.getTable("mytable");
table.get(...);
...
table.close();
connection.close();
conf
- configurationpool
- the thread pool to use for batch operation in HTables used via this HConnectionuser
- the user the connection is forconf
ZooKeeperConnectionException
IOException
@Deprecated static HConnection createConnection(org.apache.hadoop.conf.Configuration conf, boolean managed) throws IOException
IOException
@Deprecated static ClusterConnection createConnection(org.apache.hadoop.conf.Configuration conf, boolean managed, ExecutorService pool, User user) throws IOException
IOException
@Deprecated public static void deleteConnection(org.apache.hadoop.conf.Configuration conf)
conf
- configuration whose identity is used to find HConnection
instance.@Deprecated public static void deleteStaleConnection(HConnection connection)
connection
- @Deprecated public static void deleteAllConnections(boolean staleConnection)
@Deprecated public static void deleteAllConnections()
@Deprecated private static void deleteConnection(HConnection connection, boolean staleConnection)
@Deprecated private static void deleteConnection(HConnectionKey connectionKey, boolean staleConnection)
@InterfaceAudience.Private public static <T> T execute(HConnectable<T> connectable) throws IOException
HConnectable.connect(org.apache.hadoop.hbase.client.HConnection)
implementation using a HConnection
instance that lasts just for the
duration of the invocation.T
- the return type of the connect methodconnectable
- the HConnectable
instanceIOException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.