HBASE-6326 Avoid nested retry loops in HConnectionManager
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1357756 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
68da494198
commit
34e96f5b32
|
@ -900,18 +900,18 @@ public class HConnectionManager {
|
||||||
public HRegionLocation locateRegion(final byte [] tableName,
|
public HRegionLocation locateRegion(final byte [] tableName,
|
||||||
final byte [] row)
|
final byte [] row)
|
||||||
throws IOException{
|
throws IOException{
|
||||||
return locateRegion(tableName, row, true);
|
return locateRegion(tableName, row, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HRegionLocation relocateRegion(final byte [] tableName,
|
public HRegionLocation relocateRegion(final byte [] tableName,
|
||||||
final byte [] row)
|
final byte [] row)
|
||||||
throws IOException{
|
throws IOException{
|
||||||
return locateRegion(tableName, row, false);
|
return locateRegion(tableName, row, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HRegionLocation locateRegion(final byte [] tableName,
|
private HRegionLocation locateRegion(final byte [] tableName,
|
||||||
final byte [] row, boolean useCache)
|
final byte [] row, boolean useCache, boolean retry)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (this.closed) throw new IOException(toString() + " closed");
|
if (this.closed) throw new IOException(toString() + " closed");
|
||||||
if (tableName == null || tableName.length == 0) {
|
if (tableName == null || tableName.length == 0) {
|
||||||
|
@ -940,11 +940,11 @@ public class HConnectionManager {
|
||||||
}
|
}
|
||||||
} else if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
|
} else if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
|
||||||
return locateRegionInMeta(HConstants.ROOT_TABLE_NAME, tableName, row,
|
return locateRegionInMeta(HConstants.ROOT_TABLE_NAME, tableName, row,
|
||||||
useCache, metaRegionLock);
|
useCache, metaRegionLock, retry);
|
||||||
} else {
|
} else {
|
||||||
// Region not in the cache - have to go to the meta RS
|
// Region not in the cache - have to go to the meta RS
|
||||||
return locateRegionInMeta(HConstants.META_TABLE_NAME, tableName, row,
|
return locateRegionInMeta(HConstants.META_TABLE_NAME, tableName, row,
|
||||||
useCache, userRegionLock);
|
useCache, userRegionLock, retry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1014,7 +1014,7 @@ public class HConnectionManager {
|
||||||
*/
|
*/
|
||||||
private HRegionLocation locateRegionInMeta(final byte [] parentTable,
|
private HRegionLocation locateRegionInMeta(final byte [] parentTable,
|
||||||
final byte [] tableName, final byte [] row, boolean useCache,
|
final byte [] tableName, final byte [] row, boolean useCache,
|
||||||
Object regionLockObject)
|
Object regionLockObject, boolean retry)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
HRegionLocation location;
|
HRegionLocation location;
|
||||||
// If we are supposed to be using the cache, look in the cache to see if
|
// If we are supposed to be using the cache, look in the cache to see if
|
||||||
|
@ -1025,14 +1025,14 @@ public class HConnectionManager {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int localNumRetries = retry ? numRetries : 1;
|
||||||
// build the key of the meta region we should be looking for.
|
// 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
|
// the extra 9's on the end are necessary to allow "exact" matches
|
||||||
// without knowing the precise region names.
|
// without knowing the precise region names.
|
||||||
byte [] metaKey = HRegionInfo.createRegionName(tableName, row,
|
byte [] metaKey = HRegionInfo.createRegionName(tableName, row,
|
||||||
HConstants.NINES, false);
|
HConstants.NINES, false);
|
||||||
for (int tries = 0; true; tries++) {
|
for (int tries = 0; true; tries++) {
|
||||||
if (tries >= numRetries) {
|
if (tries >= localNumRetries) {
|
||||||
throw new NoServerForRegionException("Unable to find region for "
|
throw new NoServerForRegionException("Unable to find region for "
|
||||||
+ Bytes.toStringBinary(row) + " after " + numRetries + " tries.");
|
+ Bytes.toStringBinary(row) + " after " + numRetries + " tries.");
|
||||||
}
|
}
|
||||||
|
@ -1040,7 +1040,7 @@ public class HConnectionManager {
|
||||||
HRegionLocation metaLocation = null;
|
HRegionLocation metaLocation = null;
|
||||||
try {
|
try {
|
||||||
// locate the root or meta region
|
// locate the root or meta region
|
||||||
metaLocation = locateRegion(parentTable, metaKey);
|
metaLocation = locateRegion(parentTable, metaKey, true, false);
|
||||||
// If null still, go around again.
|
// If null still, go around again.
|
||||||
if (metaLocation == null) continue;
|
if (metaLocation == null) continue;
|
||||||
ClientProtocol server =
|
ClientProtocol server =
|
||||||
|
@ -1891,7 +1891,7 @@ public class HConnectionManager {
|
||||||
final Row row = aAction.getAction();
|
final Row row = aAction.getAction();
|
||||||
|
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
final HRegionLocation loc = hci.locateRegion(this.tableName, row.getRow(), true);
|
final HRegionLocation loc = hci.locateRegion(this.tableName, row.getRow());
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
throw new IOException("No location found, aborting submit.");
|
throw new IOException("No location found, aborting submit.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue