HBASE-25088 CatalogFamilyFormat/MetaTableAccessor.parseRegionInfoFromRegionName incorrectly setEndKey to regionId (#2462)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
0e6775c919
commit
6b93373a0a
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue