You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/02/24 12:16:20 UTC
[hbase] branch branch-2.0 updated: Revert "HBASE-21943 The usage of
RegionLocations.mergeRegionLocations is wrong for async client"
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 09e635c Revert "HBASE-21943 The usage of RegionLocations.mergeRegionLocations is wrong for async client"
09e635c is described below
commit 09e635c25393218b54ee5d3589397bbcc37d41c2
Author: zhangduo <zh...@apache.org>
AuthorDate: Sun Feb 24 20:15:02 2019 +0800
Revert "HBASE-21943 The usage of RegionLocations.mergeRegionLocations is wrong for async client"
This reverts commit 12ea0496b1e38a4085663714461b96d2fd107c1b.
---
.../hadoop/hbase/client/AsyncNonMetaRegionLocator.java | 5 +++--
.../hadoop/hbase/client/AsyncRegionLocatorHelper.java | 14 ++++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java
index 6920f5f..1fcfbb0 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java
@@ -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;
@@ -218,7 +219,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;
}
}
@@ -235,7 +236,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 {} " +
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java
index a60d96b..5c9c091 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java
@@ -123,6 +123,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;