From 9084f7efb32acdd67ee9b913a87843387254e539 Mon Sep 17 00:00:00 2001 From: Yu Li Date: Mon, 22 Apr 2019 12:58:22 +0800 Subject: [PATCH 1/3] HBASE-22283 Print row and table information when failed to get region location --- .../hbase/client/RpcRetryingCallerWithReadReplicas.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java index 4a31cff4a718..fa2cc37f7a13 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java @@ -42,6 +42,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos; +import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import static org.apache.hadoop.hbase.HConstants.PRIORITY_UNSET; @@ -320,6 +321,8 @@ static RegionLocations getRegionLocations(boolean useCache, int replicaId, throws RetriesExhaustedException, DoNotRetryIOException, InterruptedIOException { RegionLocations rl; + String errorMsg = "Cannot get the location for replica" + replicaId + " of region for " + + Bytes.toStringBinary(row) + " in " + tableName; try { if (useCache) { rl = cConnection.locateRegion(tableName, row, true, true, replicaId); @@ -329,10 +332,10 @@ static RegionLocations getRegionLocations(boolean useCache, int replicaId, } catch (DoNotRetryIOException | InterruptedIOException | RetriesExhaustedException e) { throw e; } catch (IOException e) { - throw new RetriesExhaustedException("Can't get the location for replica " + replicaId, e); + throw new RetriesExhaustedException(errorMsg, e); } if (rl == null) { - throw new RetriesExhaustedException("Can't get the location for replica " + replicaId); + throw new RetriesExhaustedException(errorMsg); } return rl; From 31485dcf2586b9c20977c9978559c36a91638bc1 Mon Sep 17 00:00:00 2001 From: Yu Li Date: Mon, 22 Apr 2019 15:54:00 +0800 Subject: [PATCH 2/3] Fix checkstyle error --- .../client/RpcRetryingCallerWithReadReplicas.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java index fa2cc37f7a13..100e13cd3435 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java @@ -18,6 +18,8 @@ package org.apache.hadoop.hbase.client; +import static org.apache.hadoop.hbase.HConstants.PRIORITY_UNSET; + import java.io.IOException; import java.io.InterruptedIOException; import java.util.Collections; @@ -34,18 +36,17 @@ import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.RegionLocations; import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.ipc.HBaseRpcController; +import org.apache.hadoop.hbase.ipc.RpcControllerFactory; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.hadoop.hbase.ipc.HBaseRpcController; -import org.apache.hadoop.hbase.ipc.RpcControllerFactory; + import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; - -import static org.apache.hadoop.hbase.HConstants.PRIORITY_UNSET; /** * Caller that goes to replica if the primary region does no answer within a configurable From fd8911d6537517e073db9f29d8b01842f1c57eff Mon Sep 17 00:00:00 2001 From: Yu Li Date: Tue, 23 Apr 2019 19:19:12 +0800 Subject: [PATCH 3/3] Resolve review comments --- .../hbase/client/RpcRetryingCallerWithReadReplicas.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java index 100e13cd3435..c82fcb89d4fe 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java @@ -322,8 +322,6 @@ static RegionLocations getRegionLocations(boolean useCache, int replicaId, throws RetriesExhaustedException, DoNotRetryIOException, InterruptedIOException { RegionLocations rl; - String errorMsg = "Cannot get the location for replica" + replicaId + " of region for " - + Bytes.toStringBinary(row) + " in " + tableName; try { if (useCache) { rl = cConnection.locateRegion(tableName, row, true, true, replicaId); @@ -333,10 +331,12 @@ static RegionLocations getRegionLocations(boolean useCache, int replicaId, } catch (DoNotRetryIOException | InterruptedIOException | RetriesExhaustedException e) { throw e; } catch (IOException e) { - throw new RetriesExhaustedException(errorMsg, e); + throw new RetriesExhaustedException("Cannot get the location for replica" + replicaId + + " of region for " + Bytes.toStringBinary(row) + " in " + tableName, e); } if (rl == null) { - throw new RetriesExhaustedException(errorMsg); + throw new RetriesExhaustedException("Cannot get the location for replica" + replicaId + + " of region for " + Bytes.toStringBinary(row) + " in " + tableName); } return rl;