You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by br...@apache.org on 2008/03/14 04:43:46 UTC
svn commit: r636982 -
/hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HConnectionManager.java
Author: bryanduxbury
Date: Thu Mar 13 20:43:45 2008
New Revision: 636982
URL: http://svn.apache.org/viewvc?rev=636982&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/branches/0.1/src/java/org/apache/hadoop/hbase/HConnectionManager.java
Modified: hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HConnectionManager.java?rev=636982&r1=636981&r2=636982&view=diff
==============================================================================
--- hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HConnectionManager.java (original)
+++ hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HConnectionManager.java Thu Mar 13 20:43:45 2008
@@ -250,54 +250,58 @@
// scan over the each meta region
do {
- 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());
-
- // open a scanner over the meta region
- scannerId = server.openScanner(
- metaLocation.getRegionInfo().getRegionName(),
- COLUMN_FAMILY_ARRAY, startRow, LATEST_TIMESTAMP,
- null);
-
- // iterate through the scanner, accumulating unique table names
- while (true) {
- HbaseMapWritable values = server.next(scannerId);
- if (values == null || values.size() == 0) {
- break;
- }
- for (Map.Entry<Writable, Writable> e: values.entrySet()) {
- HStoreKey key = (HStoreKey) e.getKey();
- if (key.getColumn().equals(COL_REGIONINFO)) {
- HRegionInfo info = new HRegionInfo();
- info = (HRegionInfo) Writables.getWritable(
- ((ImmutableBytesWritable) e.getValue()).get(), info);
-
- // Only examine the rows where the startKey is zero length
- if (info.getStartKey().getLength() == 0) {
- uniqueTables.add(info.getTableDesc());
+ 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());
+
+ // open a scanner over the meta region
+ scannerId = server.openScanner(
+ metaLocation.getRegionInfo().getRegionName(),
+ COLUMN_FAMILY_ARRAY, startRow, LATEST_TIMESTAMP,
+ null);
+
+ // iterate through the scanner, accumulating unique table names
+ while (true) {
+ HbaseMapWritable values = server.next(scannerId);
+ if (values == null || values.size() == 0) {
+ break;
+ }
+ for (Map.Entry<Writable, Writable> e: values.entrySet()) {
+ HStoreKey key = (HStoreKey) e.getKey();
+ if (key.getColumn().equals(COL_REGIONINFO)) {
+ HRegionInfo info = new HRegionInfo();
+ info = (HRegionInfo) Writables.getWritable(
+ ((ImmutableBytesWritable) e.getValue()).get(), info);
+
+ // 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.close(scannerId);
+ scannerId = -1L;
+
+ // advance the startRow to the end key of the current region
+ startRow = metaLocation.getRegionInfo().getEndKey();
+ // break out of the retry loop
+ break;
+ } catch (IOException e) {
+ // Retry once.
+ metaLocation = relocateRegion(META_TABLE_NAME, startRow);
+ continue;
}
+ finally {
+ if (scannerId != -1L) {
+ server.close(scannerId);
+ }
+ }
}
} while (startRow.compareTo(LAST_ROW) != 0);