diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java index 7cf6bb13831..fc4ebc489f9 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java @@ -329,12 +329,7 @@ public class MetaTableAccessor { long regionId = Long.parseLong(Bytes.toString(fields[2])); int replicaId = fields.length > 3 ? Integer.parseInt(Bytes.toString(fields[3]), 16) : 0; return RegionInfoBuilder.newBuilder(TableName.valueOf(fields[0])) - .setStartKey(fields[1]) - .setEndKey(fields[2]) - .setSplit(false) - .setRegionId(regionId) - .setReplicaId(replicaId) - .build(); + .setStartKey(fields[1]).setRegionId(regionId).setReplicaId(replicaId).build(); } /** diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java index 20e0edd4ebb..fae0ebc6a67 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java @@ -404,6 +404,29 @@ public class TestMetaTableAccessor { MetaTableAccessor.parseReplicaIdFromServerColumn(Bytes.toBytes(column6))); } + /** + * The info we can get from the regionName is: table name, start key, regionId, replicaId. + */ + @Test + public void testParseRegionInfoFromRegionName() throws IOException { + RegionInfo originalRegionInfo = RegionInfoBuilder.newBuilder( + TableName.valueOf(name.getMethodName())).setRegionId(999999L) + .setStartKey(Bytes.toBytes("2")).setEndKey(Bytes.toBytes("3")) + .setReplicaId(1).build(); + RegionInfo newParsedRegionInfo = MetaTableAccessor + .parseRegionInfoFromRegionName(originalRegionInfo.getRegionName()); + assertEquals("Parse TableName error", originalRegionInfo.getTable(), + newParsedRegionInfo.getTable()); + assertEquals("Parse regionId error", originalRegionInfo.getRegionId(), + newParsedRegionInfo.getRegionId()); + assertTrue("Parse startKey error", Bytes.equals(originalRegionInfo.getStartKey(), + newParsedRegionInfo.getStartKey())); + assertEquals("Parse replicaId error", originalRegionInfo.getReplicaId(), + newParsedRegionInfo.getReplicaId()); + assertTrue("We can't parse endKey from regionName only", + Bytes.equals(HConstants.EMPTY_END_ROW, newParsedRegionInfo.getEndKey())); + } + @Test public void testMetaReaderGetColumnMethods() { assertArrayEquals(HConstants.SERVER_QUALIFIER, MetaTableAccessor.getServerColumn(0));