Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 813A0DC00 for ; Thu, 5 Jul 2012 17:26:15 +0000 (UTC) Received: (qmail 12068 invoked by uid 500); 5 Jul 2012 17:26:15 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 12032 invoked by uid 500); 5 Jul 2012 17:26:15 -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 12012 invoked by uid 99); 5 Jul 2012 17:26:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jul 2012 17:26:15 +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; Thu, 05 Jul 2012 17:26:12 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 28D4F2388847 for ; Thu, 5 Jul 2012 17:25:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1357752 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Date: Thu, 05 Jul 2012 17:25:52 -0000 To: commits@hbase.apache.org From: larsh@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120705172552.28D4F2388847@eris.apache.org> Author: larsh Date: Thu Jul 5 17:25:51 2012 New Revision: 1357752 URL: http://svn.apache.org/viewvc?rev=1357752&view=rev Log: HBASE-6326 Avoid nested retry loops in HConnectionManager Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1357752&r1=1357751&r2=1357752&view=diff ============================================================================== --- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original) +++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Thu Jul 5 17:25:51 2012 @@ -807,17 +807,17 @@ public class HConnectionManager { public HRegionLocation locateRegion(final byte [] tableName, final byte [] row) throws IOException{ - return locateRegion(tableName, row, true); + return locateRegion(tableName, row, true, true); } public HRegionLocation relocateRegion(final byte [] tableName, final byte [] row) throws IOException{ - return locateRegion(tableName, row, false); + return locateRegion(tableName, row, false, true); } private HRegionLocation locateRegion(final byte [] tableName, - final byte [] row, boolean useCache) + final byte [] row, boolean useCache, boolean retry) throws IOException { if (this.closed) throw new IOException(toString() + " closed"); if (tableName == null || tableName.length == 0) { @@ -839,11 +839,11 @@ public class HConnectionManager { } } else if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) { return locateRegionInMeta(HConstants.ROOT_TABLE_NAME, tableName, row, - useCache, metaRegionLock); + useCache, metaRegionLock, retry); } else { // Region not in the cache - have to go to the meta RS return locateRegionInMeta(HConstants.META_TABLE_NAME, tableName, row, - useCache, userRegionLock); + useCache, userRegionLock, retry); } } @@ -913,7 +913,7 @@ public class HConnectionManager { */ private HRegionLocation locateRegionInMeta(final byte [] parentTable, final byte [] tableName, final byte [] row, boolean useCache, - Object regionLockObject) + Object regionLockObject, boolean retry) throws IOException { HRegionLocation location; // If we are supposed to be using the cache, look in the cache to see if @@ -925,13 +925,14 @@ public class HConnectionManager { } } + int localNumRetries = retry ? numRetries : 1; // build the key of the meta region we should be looking for. // the extra 9's on the end are necessary to allow "exact" matches // without knowing the precise region names. byte [] metaKey = HRegionInfo.createRegionName(tableName, row, HConstants.NINES, false); for (int tries = 0; true; tries++) { - if (tries >= numRetries) { + if (tries >= localNumRetries) { throw new NoServerForRegionException("Unable to find region for " + Bytes.toStringBinary(row) + " after " + numRetries + " tries."); } @@ -939,7 +940,7 @@ public class HConnectionManager { HRegionLocation metaLocation = null; try { // locate the root or meta region - metaLocation = locateRegion(parentTable, metaKey); + metaLocation = locateRegion(parentTable, metaKey, true, false); // If null still, go around again. if (metaLocation == null) continue; HRegionInterface server = @@ -1488,7 +1489,7 @@ public class HConnectionManager { for (int i = 0; i < workingList.size(); i++) { Row row = workingList.get(i); if (row != null) { - HRegionLocation loc = locateRegion(tableName, row.getRow(), true); + HRegionLocation loc = locateRegion(tableName, row.getRow()); byte[] regionName = loc.getRegionInfo().getRegionName(); MultiAction actions = actionsByServer.get(loc);