You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ns...@apache.org on 2011/10/11 04:13:57 UTC
svn commit: r1181499 -
/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Author: nspiegelberg
Date: Tue Oct 11 02:13:56 2011
New Revision: 1181499
URL: http://svn.apache.org/viewvc?rev=1181499&view=rev
Log:
Parallelize Server Requests on HBase Client
Summary:
Vastly improves HBCK performance on the dark launch. Although we
are parallelizing getRegionAssignment() calls, getHRegionConnection()
gets a big lock. Cache misses can be expensive on heavily-loaded servers
because they need to setup a proxy connection. This hurts cache hits on a
cache miss & serializes all
cache misses. We should parallelize both situations.
Test Plan:
- bin/hbase hbck
- mvn test
Reviewed By: kannan
Reviewers: jgray, dhruba, kannan, kranganathan
CC: kannan
Tasks:
#510832: Reduce HBCK Latency
Revert Plan:
OK
Differential Revision: 222374
Modified:
hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1181499&r1=1181498&r2=1181499&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Tue Oct 11 02:13:56 2011
@@ -292,6 +292,7 @@ public class HConnectionManager {
// Known region HServerAddress.toString() -> HRegionInterface
private final Map<String, HRegionInterface> servers =
new ConcurrentHashMap<String, HRegionInterface>();
+ private final ConcurrentHashMap<String, String> connectionLock = new ConcurrentHashMap<String, String>();
// Used by master and region servers during safe mode only
private volatile HRegionLocation rootRegionLocation;
@@ -1024,19 +1025,28 @@ public class HConnectionManager {
getMaster();
}
HRegionInterface server;
- synchronized (this.servers) {
- // See if we already have a connection
- server = this.servers.get(regionServer.toString());
- if (server == null) { // Get a connection
- try {
- server = (HRegionInterface)HBaseRPC.waitForProxy(
- serverInterfaceClass, HBaseRPCProtocolVersion.versionID,
- regionServer.getInetSocketAddress(), this.conf,
- this.maxRPCAttempts, (int)this.rpcTimeout, this.rpcTimeout);
- } catch (RemoteException e) {
- throw RemoteExceptionHandler.decodeRemoteException(e);
+ String rsName = regionServer.toString();
+ // See if we already have a connection (common case)
+ server = this.servers.get(rsName);
+ if (server == null) {
+ // create a unique lock for this RS (if necessary)
+ this.connectionLock.putIfAbsent(rsName, rsName);
+ // get the RS lock
+ synchronized (this.connectionLock.get(rsName)) {
+ // do one more lookup in case we were stalled above
+ server = this.servers.get(rsName);
+ if (server == null) {
+ try {
+ // definitely a cache miss. establish an RPC for this RS
+ server = (HRegionInterface) HBaseRPC.waitForProxy(
+ serverInterfaceClass, HBaseRPCProtocolVersion.versionID,
+ regionServer.getInetSocketAddress(), this.conf,
+ this.maxRPCAttempts, this.rpcTimeout, this.rpcTimeout);
+ this.servers.put(rsName, server);
+ } catch (RemoteException e) {
+ throw RemoteExceptionHandler.decodeRemoteException(e);
+ }
}
- this.servers.put(regionServer.toString(), server);
}
}
return server;