This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 353f922 HBASE-22236 AsyncNonMetaRegionLocator should not cache
HRegionLocation with null location
353f922 is described below
commit 353f9226c3ba2637ddf365e53a9eb6862c7cb3af
Author: zhangduo <[email protected]>
AuthorDate: Sat Apr 20 07:55:34 2019 +0800
HBASE-22236 AsyncNonMetaRegionLocator should not cache HRegionLocation with
null location
---
.../java/org/apache/hadoop/hbase/RegionLocations.java | 17 ++++++++++++++++-
.../hadoop/hbase/client/AsyncNonMetaRegionLocator.java | 4 ++++
.../hadoop/hbase/client/AsyncRegionLocatorHelper.java | 3 ++-
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git
a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java
index f98bf03..e119ebb 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java
@@ -19,7 +19,6 @@
package org.apache.hadoop.hbase;
import java.util.Collection;
-
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
import org.apache.hadoop.hbase.util.Bytes;
@@ -186,6 +185,22 @@ public class RegionLocations {
}
/**
+ * Set the element to null if its getServerName method returns null. Returns
null if all the
+ * elements are removed.
+ */
+ public RegionLocations removeElementsWithNullLocation() {
+ HRegionLocation[] newLocations = new HRegionLocation[locations.length];
+ boolean hasNonNullElement = false;
+ for (int i = 0; i < locations.length; i++) {
+ if (locations[i] != null && locations[i].getServerName() != null) {
+ hasNonNullElement = true;
+ newLocations[i] = locations[i];
+ }
+ }
+ return hasNonNullElement ? new RegionLocations(newLocations) : null;
+ }
+
+ /**
* Merges this RegionLocations list with the given list assuming
* same range, and keeping the most up to date version of the
* HRegionLocation entries from either list according to seqNum. If seqNums
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 bbb84d0..069a324 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
@@ -314,6 +314,10 @@ class AsyncNonMetaRegionLocator {
LOG.debug("The fetched location of '{}', row='{}', locateType={} is {}",
tableName,
Bytes.toStringBinary(req.row), req.locateType, locs);
}
+ // remove HRegionLocation with null location, i.e, getServerName returns
null.
+ if (locs != null) {
+ locs = locs.removeElementsWithNullLocation();
+ }
// the default region location should always be presented when fetching
from meta, otherwise
// let's fail the request.
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 2836e4b..5f4bc9f 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
@@ -76,7 +76,8 @@ final class AsyncRegionLocatorHelper {
RegionMovedException rme = (RegionMovedException) cause;
HRegionLocation newLoc =
new HRegionLocation(loc.getRegion(), rme.getServerName(),
rme.getLocationSeqNum());
- LOG.debug("Try updating {} with the new location {} constructed by {}",
loc, newLoc, rme);
+ LOG.debug("Try updating {} with the new location {} constructed by {}",
loc, newLoc,
+ rme.toString());
addToCache.accept(newLoc);
} else {
LOG.debug("Try removing {} from cache", loc);