HBASE-510 HConnectionManger.listTables returns empty list if exception (though there may be many tables present)
-Added retry logic to listTables git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@636983 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ea64897fe
commit
97d4b9fd3c
|
@ -256,47 +256,51 @@ public class HConnectionManager implements HConstants {
|
||||||
|
|
||||||
// scan over the each meta region
|
// scan over the each meta region
|
||||||
do {
|
do {
|
||||||
try{
|
for (int triesSoFar = 0; triesSoFar < numRetries; triesSoFar++) {
|
||||||
// turn the start row into a location
|
try{
|
||||||
metaLocation = locateRegion(META_TABLE_NAME, startRow);
|
// turn the start row into a location
|
||||||
|
metaLocation = locateRegion(META_TABLE_NAME, startRow);
|
||||||
|
|
||||||
// connect to the server hosting the .META. region
|
// connect to the server hosting the .META. region
|
||||||
server = getHRegionConnection(metaLocation.getServerAddress());
|
server = getHRegionConnection(metaLocation.getServerAddress());
|
||||||
|
|
||||||
// open a scanner over the meta region
|
// open a scanner over the meta region
|
||||||
scannerId = server.openScanner(
|
scannerId = server.openScanner(
|
||||||
metaLocation.getRegionInfo().getRegionName(),
|
metaLocation.getRegionInfo().getRegionName(),
|
||||||
new Text[]{COL_REGIONINFO}, startRow, LATEST_TIMESTAMP, null);
|
new Text[]{COL_REGIONINFO}, startRow, LATEST_TIMESTAMP, null);
|
||||||
|
|
||||||
// iterate through the scanner, accumulating unique table names
|
// iterate through the scanner, accumulating unique table names
|
||||||
while (true) {
|
while (true) {
|
||||||
RowResult values = server.next(scannerId);
|
RowResult values = server.next(scannerId);
|
||||||
if (values == null || values.size() == 0) {
|
if (values == null || values.size() == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRegionInfo info =
|
HRegionInfo info =
|
||||||
Writables.getHRegionInfo(values.get(COL_REGIONINFO));
|
Writables.getHRegionInfo(values.get(COL_REGIONINFO));
|
||||||
|
|
||||||
// Only examine the rows where the startKey is zero length
|
// Only examine the rows where the startKey is zero length
|
||||||
if (info.getStartKey().getLength() == 0) {
|
if (info.getStartKey().getLength() == 0) {
|
||||||
uniqueTables.add(info.getTableDesc());
|
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);
|
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);
|
} while (startRow.compareTo(LAST_ROW) != 0);
|
||||||
|
|
Loading…
Reference in New Issue