diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java index 5ec2a3ab76f..3b5e4f3b223 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java @@ -1232,7 +1232,7 @@ public final class ProtobufUtil { */ public static ClientProtos.Result toResult(final Result result) { if (result.getExists() != null) { - return toResult(result.getExists()); + return toResult(result.getExists(), result.isStale()); } Cell[] cells = result.rawCells(); @@ -1256,8 +1256,12 @@ public final class ProtobufUtil { * @param existence the client existence to send * @return the converted protocol buffer Result */ - public static ClientProtos.Result toResult(final boolean existence) { - return existence ? EMPTY_RESULT_PB_EXISTS_TRUE : EMPTY_RESULT_PB_EXISTS_FALSE; + public static ClientProtos.Result toResult(final boolean existence, boolean stale) { + if (stale){ + return existence ? EMPTY_RESULT_PB_EXISTS_TRUE_STALE : EMPTY_RESULT_PB_EXISTS_FALSE_STALE; + } else { + return existence ? EMPTY_RESULT_PB_EXISTS_TRUE : EMPTY_RESULT_PB_EXISTS_FALSE; + } } /** @@ -1268,7 +1272,7 @@ public final class ProtobufUtil { * @return the converted protocol buffer Result */ public static ClientProtos.Result toResultNoData(final Result result) { - if (result.getExists() != null) return toResult(result.getExists()); + if (result.getExists() != null) return toResult(result.getExists(), result.isStale()); int size = result.size(); if (size == 0) return result.isStale() ? EMPTY_RESULT_PB_STALE : EMPTY_RESULT_PB; ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index aef95d886a2..b89d886f3a0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -4725,7 +4725,8 @@ public class HRegion implements HeapSize { // , Writable{ } } List results = get(get, true); - return Result.create(results, get.isCheckExistenceOnly() ? !results.isEmpty() : null); + boolean stale = this.getRegionInfo().getReplicaId() != 0; + return Result.create(results, get.isCheckExistenceOnly() ? !results.isEmpty() : null, stale); } /* diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 84f986bb11f..d8f16962c7e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -2531,7 +2531,7 @@ public class HRegionServer extends HasThread implements return getRegionByEncodedName(regionName, encodedRegionName); } - protected HRegion getRegionByEncodedName(String encodedRegionName) + public HRegion getRegionByEncodedName(String encodedRegionName) throws NotServingRegionException { return getRegionByEncodedName(null, encodedRegionName); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java index e94c506ebee..599fd1c22f7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java @@ -1606,7 +1606,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler, } } if (existence != null){ - ClientProtos.Result pbr = ProtobufUtil.toResult(existence); + ClientProtos.Result pbr = + ProtobufUtil.toResult(existence, region.getRegionInfo().getReplicaId() != 0); builder.setResult(pbr); } else if (r != null) { ClientProtos.Result pbr = ProtobufUtil.toResult(r);