HBASE-22328 NPE in RegionReplicaReplicationEndpoint
This commit is contained in:
parent
6855d58379
commit
a95eb6559d
|
@ -151,21 +151,23 @@ public class RegionReplicaReplicationEndpoint extends HBaseReplicationEndpoint {
|
||||||
private void getRegionLocations(CompletableFuture<RegionLocations> future,
|
private void getRegionLocations(CompletableFuture<RegionLocations> future,
|
||||||
TableDescriptor tableDesc, byte[] encodedRegionName, byte[] row, boolean reload) {
|
TableDescriptor tableDesc, byte[] encodedRegionName, byte[] row, boolean reload) {
|
||||||
FutureUtils.addListener(connection.getRegionLocations(tableDesc.getTableName(), row, reload),
|
FutureUtils.addListener(connection.getRegionLocations(tableDesc.getTableName(), row, reload),
|
||||||
(r, e) -> {
|
(locs, e) -> {
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
future.completeExceptionally(e);
|
future.completeExceptionally(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if we are not loading from cache, just return
|
// if we are not loading from cache, just return
|
||||||
if (reload) {
|
if (reload) {
|
||||||
future.complete(r);
|
future.complete(locs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// check if the number of region replicas is correct, and also the primary region name
|
// check if the number of region replicas is correct, and also the primary region name
|
||||||
// matches
|
// matches, and also there is no null elements in the returned RegionLocations
|
||||||
if (r.size() == tableDesc.getRegionReplication() && Bytes.equals(
|
if (locs.size() == tableDesc.getRegionReplication() &&
|
||||||
r.getDefaultRegionLocation().getRegion().getEncodedNameAsBytes(), encodedRegionName)) {
|
locs.size() == locs.numNonNullElements() &&
|
||||||
future.complete(r);
|
Bytes.equals(locs.getDefaultRegionLocation().getRegion().getEncodedNameAsBytes(),
|
||||||
|
encodedRegionName)) {
|
||||||
|
future.complete(locs);
|
||||||
} else {
|
} else {
|
||||||
// reload again as the information in cache maybe stale
|
// reload again as the information in cache maybe stale
|
||||||
getRegionLocations(future, tableDesc, encodedRegionName, row, true);
|
getRegionLocations(future, tableDesc, encodedRegionName, row, true);
|
||||||
|
|
Loading…
Reference in New Issue