hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bryanduxb...@apache.org
Subject svn commit: r636983 - /hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Date Fri, 14 Mar 2008 03:44:07 GMT
Author: bryanduxbury
Date: Thu Mar 13 20:44:06 2008
New Revision: 636983

URL: http://svn.apache.org/viewvc?rev=636983&view=rev
Log:
HBASE-510 HConnectionManger.listTables returns empty list if exception (though there may be
many tables present)
-Added retry logic to listTables

Modified:
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=636983&r1=636982&r2=636983&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java Thu
Mar 13 20:44:06 2008
@@ -256,47 +256,51 @@
 
       // scan over the each meta region
       do {
-        try{
-          // turn the start row into a location
-          metaLocation = locateRegion(META_TABLE_NAME, startRow);
+        for (int triesSoFar = 0; triesSoFar < numRetries; triesSoFar++) {
+          try{
+            // turn the start row into a location
+            metaLocation = locateRegion(META_TABLE_NAME, startRow);
 
-          // connect to the server hosting the .META. region
-          server = getHRegionConnection(metaLocation.getServerAddress());
+            // connect to the server hosting the .META. region
+            server = getHRegionConnection(metaLocation.getServerAddress());
 
-          // open a scanner over the meta region
-          scannerId = server.openScanner(
-            metaLocation.getRegionInfo().getRegionName(),
-            new Text[]{COL_REGIONINFO}, startRow, LATEST_TIMESTAMP, null);
+            // open a scanner over the meta region
+            scannerId = server.openScanner(
+              metaLocation.getRegionInfo().getRegionName(),
+              new Text[]{COL_REGIONINFO}, startRow, LATEST_TIMESTAMP, null);
           
-          // iterate through the scanner, accumulating unique table names
-          while (true) {
-            RowResult values = server.next(scannerId);
-            if (values == null || values.size() == 0) {
-              break;
-            }
+            // iterate through the scanner, accumulating unique table names
+            while (true) {
+              RowResult values = server.next(scannerId);
+              if (values == null || values.size() == 0) {
+                break;
+              }
             
-            HRegionInfo info = 
-              Writables.getHRegionInfo(values.get(COL_REGIONINFO));
+              HRegionInfo info = 
+                Writables.getHRegionInfo(values.get(COL_REGIONINFO));
 
-            // Only examine the rows where the startKey is zero length   
-            if (info.getStartKey().getLength() == 0) {
-              uniqueTables.add(info.getTableDesc());
+              // Only examine the rows where the startKey is zero length   
+              if (info.getStartKey().getLength() == 0) {
+                uniqueTables.add(info.getTableDesc());
+              }
             }
-          }
-          
-          server.close(scannerId);
-          scannerId = -1L;
           
-          // advance the startRow to the end key of the current region
-          startRow = metaLocation.getRegionInfo().getEndKey();          
-        } catch (IOException e) {
-          // Retry once.
-          metaLocation = relocateRegion(META_TABLE_NAME, startRow);
-          continue;
-        }
-        finally {
-          if (scannerId != -1L && server != null) {
             server.close(scannerId);
+            scannerId = -1L;
+          
+            // advance the startRow to the end key of the current region
+            startRow = metaLocation.getRegionInfo().getEndKey();
+            // break out of retry loop
+            break;
+          } catch (IOException e) {
+            // Retry once.
+            metaLocation = relocateRegion(META_TABLE_NAME, startRow);
+            continue;
+          }
+          finally {
+            if (scannerId != -1L && server != null) {
+              server.close(scannerId);
+            }
           }
         }
       } while (startRow.compareTo(LAST_ROW) != 0);



Mime
View raw message