Revert "HBASE-21943 The usage of RegionLocations.mergeRegionLocations is wrong for async client"

This reverts commit 3ccc6fec6c.
This commit is contained in:
zhangduo 2019-02-24 20:14:27 +08:00
parent 1568aad302
commit d47d64c6e3
2 changed files with 17 additions and 2 deletions

View File

@ -23,6 +23,7 @@ import static org.apache.hadoop.hbase.TableName.META_TABLE_NAME;
import static org.apache.hadoop.hbase.client.AsyncRegionLocatorHelper.canUpdateOnError;
import static org.apache.hadoop.hbase.client.AsyncRegionLocatorHelper.createRegionLocations;
import static org.apache.hadoop.hbase.client.AsyncRegionLocatorHelper.isGood;
import static org.apache.hadoop.hbase.client.AsyncRegionLocatorHelper.mergeRegionLocations;
import static org.apache.hadoop.hbase.client.AsyncRegionLocatorHelper.removeRegionLocation;
import static org.apache.hadoop.hbase.client.ConnectionUtils.createClosestRowAfter;
import static org.apache.hadoop.hbase.client.ConnectionUtils.isEmptyStopRow;
@ -217,7 +218,7 @@ class AsyncNonMetaRegionLocator {
if (loc1.getSeqNum() != loc2.getSeqNum()) {
return false;
}
if (!Objects.equal(loc1.getServerName(), loc2.getServerName())) {
if (Objects.equal(loc1.getServerName(), loc2.getServerName())) {
return false;
}
}
@ -234,7 +235,7 @@ class AsyncNonMetaRegionLocator {
if (oldLocs == null) {
return true;
}
RegionLocations mergedLocs = oldLocs.mergeLocations(locs);
RegionLocations mergedLocs = mergeRegionLocations(locs, oldLocs);
if (isEqual(mergedLocs, oldLocs)) {
// the merged one is the same with the old one, give up
LOG.trace("Will not add {} to cache because the old value {} " +

View File

@ -129,6 +129,20 @@ final class AsyncRegionLocatorHelper {
}
}
/**
* Create a new {@link RegionLocations} which is the merging result for the given two
* {@link RegionLocations}.
* <p/>
* All the {@link RegionLocations} in async locator related class are immutable because we want to
* access them concurrently, so here we need to create a new one, instead of calling
* {@link RegionLocations#mergeLocations(RegionLocations)} directly.
*/
static RegionLocations mergeRegionLocations(RegionLocations newLocs, RegionLocations oldLocs) {
RegionLocations locs = new RegionLocations(newLocs.getRegionLocations());
locs.mergeLocations(oldLocs);
return locs;
}
static boolean isGood(RegionLocations locs, int replicaId) {
if (locs == null) {
return false;