Skip to content

Commit f57dca5

Browse files
committed
HBASE-13198 Remove HConnectionManager (Mikhail Antonov)
1 parent 0d76654 commit f57dca5

File tree

35 files changed

+97
-632
lines changed

35 files changed

+97
-632
lines changed

bin/region_mover.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.apache.hadoop.hbase.client.Get
3030
import org.apache.hadoop.hbase.client.Scan
3131
import org.apache.hadoop.hbase.client.HTable
32-
import org.apache.hadoop.hbase.client.HConnectionManager
32+
import org.apache.hadoop.hbase.client.ConnectionFactory
3333
import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
3434
import org.apache.hadoop.hbase.filter.InclusiveStopFilter;
3535
import org.apache.hadoop.hbase.filter.FilterList;
@@ -243,7 +243,7 @@ def getConfiguration()
243243

244244
# Now get list of regions on targetServer
245245
def getRegions(config, servername)
246-
connection = HConnectionManager::getConnection(config);
246+
connection = ConnectionFactory::createConnection(config);
247247
return ProtobufUtil::getOnlineRegions(connection.getAdmin(ServerName.valueOf(servername)));
248248
end
249249

bin/region_status.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import org.apache.hadoop.hbase.HRegionInfo
5757
import org.apache.hadoop.hbase.MetaTableAccessor
5858
import org.apache.hadoop.hbase.HTableDescriptor
59-
import org.apache.hadoop.hbase.client.HConnectionManager
59+
import org.apache.hadoop.hbase.client.ConnectionFactory
6060

6161
# disable debug logging on this script for clarity
6262
log_level = org.apache.log4j.Level::ERROR
@@ -138,7 +138,7 @@
138138
if $tablename.nil?
139139
server_count = admin.getClusterStatus().getRegionsCount()
140140
else
141-
connection = HConnectionManager::getConnection(config);
141+
connection = ConnectionFactory::createConnection(config);
142142
server_count = MetaTableAccessor::allTableRegions(connection, $TableName).size()
143143
end
144144
print "Region Status: #{server_count} / #{meta_count}\n"

conf/log4j.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ log4j.logger.org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher=INFO
8282
#log4j.logger.org.apache.hadoop.dfs=DEBUG
8383
# Set this class to log INFO only otherwise its OTT
8484
# Enable this to get detailed connection error/retry logging.
85-
# log4j.logger.org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation=TRACE
85+
# log4j.logger.org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation=TRACE
8686

8787

8888
# Uncomment this line to enable tracing on _every_ RPC call (this can be a lot of output)
8989
#log4j.logger.org.apache.hadoop.ipc.HBaseServer.trace=DEBUG
9090

9191
# Uncomment the below if you want to remove logging of client region caching'
9292
# and scan of hbase:meta messages
93-
# log4j.logger.org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation=INFO
93+
# log4j.logger.org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation=INFO

hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
* Similarly, {@link Connection} also returns {@link Admin} and {@link RegionLocator}
5151
* implementations.
5252
*
53-
* This class replaces {@link HConnectionManager}, which is now deprecated.
5453
* @see Connection
5554
* @since 0.99.0
5655
*/

hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static ClusterConnection createConnectionInternal(Configuration conf) throws IOE
335335
* This is the recommended way to create HConnections.
336336
* {@code
337337
* ExecutorService pool = ...;
338-
* HConnection connection = HConnectionManager.createConnection(conf, pool);
338+
* HConnection connection = ConnectionManager.createConnection(conf, pool);
339339
* HTableInterface table = connection.getTable("mytable");
340340
* table.get(...);
341341
* ...
@@ -361,7 +361,7 @@ public static HConnection createConnection(Configuration conf, ExecutorService p
361361
* This is the recommended way to create HConnections.
362362
* {@code
363363
* ExecutorService pool = ...;
364-
* HConnection connection = HConnectionManager.createConnection(conf, pool);
364+
* HConnection connection = ConnectionManager.createConnection(conf, pool);
365365
* HTableInterface table = connection.getTable("mytable");
366366
* table.get(...);
367367
* ...
@@ -386,7 +386,7 @@ public static HConnection createConnection(Configuration conf, User user)
386386
* This is the recommended way to create HConnections.
387387
* {@code
388388
* ExecutorService pool = ...;
389-
* HConnection connection = HConnectionManager.createConnection(conf, pool);
389+
* HConnection connection = ConnectionManager.createConnection(conf, pool);
390390
* HTableInterface table = connection.getTable("mytable");
391391
* table.get(...);
392392
* ...
@@ -424,19 +424,6 @@ static ClusterConnection createConnection(final Configuration conf, final boolea
424424
return (ClusterConnection) ConnectionFactory.createConnection(conf, managed, pool, user);
425425
}
426426

427-
/**
428-
* Delete connection information for the instance specified by passed configuration.
429-
* If there are no more references to the designated connection connection, this method will
430-
* then close connection to the zookeeper ensemble and let go of all associated resources.
431-
*
432-
* @param conf configuration whose identity is used to find {@link HConnection} instance.
433-
* @deprecated connection caching is going away.
434-
*/
435-
@Deprecated
436-
public static void deleteConnection(Configuration conf) {
437-
deleteConnection(new HConnectionKey(conf), false);
438-
}
439-
440427
/**
441428
* Cleanup a known stale connection.
442429
* This will then close connection to the zookeeper ensemble and let go of all resources.
@@ -449,33 +436,6 @@ public static void deleteStaleConnection(HConnection connection) {
449436
deleteConnection(connection, true);
450437
}
451438

452-
/**
453-
* Delete information for all connections. Close or not the connection, depending on the
454-
* staleConnection boolean and the ref count. By default, you should use it with
455-
* staleConnection to true.
456-
* @deprecated connection caching is going away.
457-
*/
458-
@Deprecated
459-
public static void deleteAllConnections(boolean staleConnection) {
460-
synchronized (CONNECTION_INSTANCES) {
461-
Set<HConnectionKey> connectionKeys = new HashSet<HConnectionKey>();
462-
connectionKeys.addAll(CONNECTION_INSTANCES.keySet());
463-
for (HConnectionKey connectionKey : connectionKeys) {
464-
deleteConnection(connectionKey, staleConnection);
465-
}
466-
CONNECTION_INSTANCES.clear();
467-
}
468-
}
469-
470-
/**
471-
* Delete information for all connections..
472-
* @deprecated kept for backward compatibility, but the behavior is broken. HBASE-8983
473-
*/
474-
@Deprecated
475-
public static void deleteAllConnections() {
476-
deleteAllConnections(false);
477-
}
478-
479439
/**
480440
* @deprecated connection caching is going away.
481441
*/

hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
/**
3939
* A cluster connection. Knows how to find the master, locate regions out on the cluster,
4040
* keeps a cache of locations and then knows how to re-calibrate after they move. You need one
41-
* of these to talk to your HBase cluster. {@link HConnectionManager} manages instances of this
41+
* of these to talk to your HBase cluster. {@link ConnectionFactory} manages instances of this
4242
* class. See it for how to get one of these.
4343
*
4444
* <p>This is NOT a connection to a particular server but to ALL servers in the cluster. Individual
@@ -49,11 +49,12 @@
4949
* HConnection instances can be shared. Sharing
5050
* is usually what you want because rather than each HConnection instance
5151
* having to do its own discovery of regions out on the cluster, instead, all
52-
* clients get to share the one cache of locations. {@link HConnectionManager} does the
52+
* clients get to share the one cache of locations. {@link ConnectionManager} does the
5353
* sharing for you if you go by it getting connections. Sharing makes cleanup of
54-
* HConnections awkward. See {@link HConnectionManager} for cleanup discussion.
54+
* HConnections awkward. See {@link ConnectionFactory} for cleanup discussion.
5555
*
56-
* @see HConnectionManager
56+
* @see ConnectionManager
57+
* @see ConnectionFactory
5758
* @deprecated in favor of {@link Connection} and {@link ConnectionFactory}
5859
*/
5960
@InterfaceAudience.Public
@@ -79,7 +80,7 @@ public interface HConnection extends Connection {
7980
* This is a lightweight operation, pooling or caching of the returned HTableInterface
8081
* is neither required nor desired.
8182
* Note that the HConnection needs to be unmanaged
82-
* (created with {@link HConnectionManager#createConnection(Configuration)}).
83+
* (created with {@link ConnectionFactory#createConnection(Configuration)}).
8384
* @param tableName
8485
* @return an HTable to use for interactions with this table
8586
*/
@@ -92,7 +93,7 @@ public interface HConnection extends Connection {
9293
* This is a lightweight operation, pooling or caching of the returned HTableInterface
9394
* is neither required nor desired.
9495
* Note that the HConnection needs to be unmanaged
95-
* (created with {@link HConnectionManager#createConnection(Configuration)}).
96+
* (created with {@link ConnectionFactory#createConnection(Configuration)}).
9697
* @param tableName
9798
* @return an HTable to use for interactions with this table
9899
*/
@@ -105,7 +106,7 @@ public interface HConnection extends Connection {
105106
* This is a lightweight operation, pooling or caching of the returned HTableInterface
106107
* is neither required nor desired.
107108
* Note that the HConnection needs to be unmanaged
108-
* (created with {@link HConnectionManager#createConnection(Configuration)}).
109+
* (created with {@link ConnectionFactory#createConnection(Configuration)}).
109110
* @param tableName
110111
* @return an HTable to use for interactions with this table
111112
*/
@@ -119,7 +120,7 @@ public interface HConnection extends Connection {
119120
* This is a lightweight operation, pooling or caching of the returned HTableInterface
120121
* is neither required nor desired.
121122
* Note that the HConnection needs to be unmanaged
122-
* (created with {@link HConnectionManager#createConnection(Configuration)}).
123+
* (created with {@link ConnectionFactory#createConnection(Configuration)}).
123124
* @param tableName
124125
* @param pool The thread pool to use for batch operations, null to use a default pool.
125126
* @return an HTable to use for interactions with this table
@@ -133,7 +134,7 @@ public interface HConnection extends Connection {
133134
* This is a lightweight operation, pooling or caching of the returned HTableInterface
134135
* is neither required nor desired.
135136
* Note that the HConnection needs to be unmanaged
136-
* (created with {@link HConnectionManager#createConnection(Configuration)}).
137+
* (created with {@link ConnectionFactory#createConnection(Configuration)}).
137138
* @param tableName
138139
* @param pool The thread pool to use for batch operations, null to use a default pool.
139140
* @return an HTable to use for interactions with this table
@@ -147,7 +148,7 @@ public interface HConnection extends Connection {
147148
* This is a lightweight operation, pooling or caching of the returned HTableInterface
148149
* is neither required nor desired.
149150
* Note that the HConnection needs to be unmanaged
150-
* (created with {@link HConnectionManager#createConnection(Configuration)}).
151+
* (created with {@link ConnectionFactory#createConnection(Configuration)}).
151152
* @param tableName
152153
* @param pool The thread pool to use for batch operations, null to use a default pool.
153154
* @return an HTable to use for interactions with this table
@@ -163,7 +164,7 @@ public interface HConnection extends Connection {
163164
* required nor desired.
164165
*
165166
* RegionLocator needs to be unmanaged
166-
* (created with {@link HConnectionManager#createConnection(Configuration)}).
167+
* (created with {@link ConnectionFactory#createConnection(Configuration)}).
167168
*
168169
* @param tableName Name of the table who's region is to be examined
169170
* @return A RegionLocator instance

0 commit comments

Comments
 (0)