Return-Path: Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: (qmail 93414 invoked from network); 16 Mar 2011 19:07:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Mar 2011 19:07:37 -0000 Received: (qmail 76183 invoked by uid 500); 16 Mar 2011 19:07:37 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 76157 invoked by uid 500); 16 Mar 2011 19:07:37 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 76126 invoked by uid 99); 16 Mar 2011 19:07:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Mar 2011 19:07:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Mar 2011 19:07:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A542223888CD; Wed, 16 Mar 2011 19:07:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1082262 - in /hbase/branches/0.90: CHANGES.txt src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Date: Wed, 16 Mar 2011 19:07:13 -0000 To: commits@hbase.apache.org From: nspiegelberg@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110316190713.A542223888CD@eris.apache.org> Author: nspiegelberg Date: Wed Mar 16 19:07:13 2011 New Revision: 1082262 URL: http://svn.apache.org/viewvc?rev=1082262&view=rev Log: HBASE-3653 Parallelize Server Requests on HBase Client Modified: hbase/branches/0.90/CHANGES.txt hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Modified: hbase/branches/0.90/CHANGES.txt URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1082262&r1=1082261&r2=1082262&view=diff ============================================================================== --- hbase/branches/0.90/CHANGES.txt (original) +++ hbase/branches/0.90/CHANGES.txt Wed Mar 16 19:07:13 2011 @@ -54,6 +54,7 @@ Release 0.90.2 - February 9th, 2011 HBASE-3600 Update our jruby to 1.6.0 HBASE-3440 Clean out load_table.rb and make sure all roads lead to completebulkload tool (Vidhyashankar Venkataraman via Stack) + HBASE-3653 Parallelize Server Requests on HBase Client Release 0.90.1 - February 9th, 2011 Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1082262&r1=1082261&r2=1082262&view=diff ============================================================================== --- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original) +++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Wed Mar 16 19:07:13 2011 @@ -247,6 +247,7 @@ public class HConnectionManager { private final Map servers = new ConcurrentHashMap(); + private final ConcurrentHashMap connectionLock = new ConcurrentHashMap(); /** * Map of table to table {@link HRegionLocation}s. The table key is made @@ -948,21 +949,30 @@ 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, this.rpcTimeout, this.rpcTimeout); - } catch (RemoteException e) { - LOG.warn("RemoteException connecting to RS", e); - // Throw what the RemoteException was carrying. - 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) { + LOG.warn("RemoteException connecting to RS", e); + // Throw what the RemoteException was carrying. + throw RemoteExceptionHandler.decodeRemoteException(e); + } } - this.servers.put(regionServer.toString(), server); } } return server;