From e15f36cdde3850b68d62159b213f50adf778a728 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 14 Nov 2013 05:01:29 +0000 Subject: [PATCH] HBASE-9710 Use the region name, not the encoded name, when region is not on current server git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1541820 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/hbase/regionserver/HRegionServer.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 acdee1f8025..fdadfc28de9 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 @@ -2584,10 +2584,15 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa protected HRegion getRegion(final byte[] regionName) throws NotServingRegionException { String encodedRegionName = HRegionInfo.encodeRegionName(regionName); - return getRegionByEncodedName(encodedRegionName); + return getRegionByEncodedName(regionName, encodedRegionName); } protected HRegion getRegionByEncodedName(String encodedRegionName) + throws NotServingRegionException { + return getRegionByEncodedName(null, encodedRegionName); + } + + protected HRegion getRegionByEncodedName(byte[] regionName, String encodedRegionName) throws NotServingRegionException { HRegion region = this.onlineRegions.get(encodedRegionName); if (region == null) { @@ -2596,10 +2601,12 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa throw new RegionMovedException(moveInfo.getServerName(), moveInfo.getSeqNum()); } Boolean isOpening = this.regionsInTransitionInRS.get(Bytes.toBytes(encodedRegionName)); + String regionNameStr = regionName == null? + encodedRegionName: Bytes.toStringBinary(regionName); if (isOpening != null && isOpening.booleanValue()) { - throw new RegionOpeningException("Region is being opened: " + encodedRegionName); + throw new RegionOpeningException("Region " + regionNameStr + " is opening"); } - throw new NotServingRegionException("Region is not online: " + encodedRegionName); + throw new NotServingRegionException("Region " + regionNameStr + " is not online"); } return region; } @@ -3965,7 +3972,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa */ protected HRegion getRegion( final RegionSpecifier regionSpecifier) throws IOException { - return getRegionByEncodedName( + return getRegionByEncodedName(regionSpecifier.getValue().toByteArray(), ProtobufUtil.getRegionEncodedName(regionSpecifier)); }