[GitHub] [hbase] infraio commented on a change in pull request #1840: HBASE-24500 The behavior of RegionInfoBuilder.newBuilder(RegionInfo) …

2020-06-03 Thread GitBox


infraio commented on a change in pull request #1840:
URL: https://github.com/apache/hbase/pull/1840#discussion_r434471121



##
File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionInfoBuilder.java
##
@@ -302,30 +283,28 @@ public void testConvert() {
 HBaseProtos.RegionInfo info = HBaseProtos.RegionInfo.newBuilder()
   .setTableName(HBaseProtos.TableName.newBuilder()
 
.setQualifier(UnsafeByteOperations.unsafeWrap(tableName.getQualifier()))
-
.setNamespace(UnsafeByteOperations.unsafeWrap(tableName.getNamespace()))
-.build())
+
.setNamespace(UnsafeByteOperations.unsafeWrap(tableName.getNamespace())).build())
   .setStartKey(UnsafeByteOperations.unsafeWrap(startKey))
-  .setEndKey(UnsafeByteOperations.unsafeWrap(endKey))
-  .setSplit(split)
-  .setRegionId(regionId)
+  
.setEndKey(UnsafeByteOperations.unsafeWrap(endKey)).setSplit(split).setRegionId(regionId)
   .build();
 
 convertedRi = ProtobufUtil.toRegionInfo(info);
-RegionInfo expectedRi = RegionInfoBuilder.newBuilder(tableName)
-.setStartKey(startKey)
-.setEndKey(endKey)
-.setSplit(split)
-.setRegionId(regionId)
-.setReplicaId(0).build();
+RegionInfo expectedRi = 
RegionInfoBuilder.newBuilder(tableName).setStartKey(startKey)
+  
.setEndKey(endKey).setSplit(split).setRegionId(regionId).setReplicaId(0).build();
 
 assertEquals(expectedRi, convertedRi);
   }
 
-  // Duplicated method in TestRegionInfoDisplay too.
-  private HRegionInfo convert(RegionInfo ri) {
-HRegionInfo hri = new HRegionInfo(
-ri.getTable(), ri.getStartKey(), ri.getEndKey(), ri.isSplit(), 
ri.getRegionId());
-hri.setOffline(ri.isOffline());
-return hri;
+  @Test
+  public void testNewBuilderWithRegionInfo() {
+RegionInfo ri = RegionInfoBuilder.newBuilder(name.getTableName()).build();
+RegionInfo ri2 = RegionInfoBuilder.newBuilder(ri).build();
+assertEquals(ri, ri2);
+
+// make sure that the region name and encoded name are changed, see 
HBASE-24500 for more
+// details.

Review comment:
   As you said on the issue desc, set different startkey or endkey?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [hbase] infraio commented on a change in pull request #1840: HBASE-24500 The behavior of RegionInfoBuilder.newBuilder(RegionInfo) …

2020-06-03 Thread GitBox


infraio commented on a change in pull request #1840:
URL: https://github.com/apache/hbase/pull/1840#discussion_r434428788



##
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
##
@@ -3355,8 +3354,10 @@ public static String 
toLockJson(List lockedRes
 if (proto.hasOffline()) {
   rib.setOffline(proto.getOffline());
 }
-if (proto.hasRegionEncodedName()) {
-  rib.setEncodedName(proto.getRegionEncodedName());
+org.apache.hadoop.hbase.client.RegionInfo ri = rib.build();
+if (proto.hasRegionEncodedName() && 
!proto.getRegionEncodedName().equals(ri.getEncodedName())) {
+  LOG.warn("The converted region info is {}, but the encoded name in proto 
is {}", ri,

Review comment:
   When this happen?

##
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionInfoBuilder.java
##
@@ -115,14 +109,18 @@ public RegionInfoBuilder setOffline(boolean offLine) {
 return this;
   }
 
+  /**
+   * @deprecated Since 2.3.0, will be removed in 4.0.0. Calling this method 
will have no effect as
+   * the encoded name will be generated by region name.
+   */
+  @Deprecated

Review comment:
   This marked as IA.Private. Can remove this directly?

##
File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionInfoBuilder.java
##
@@ -302,30 +283,28 @@ public void testConvert() {
 HBaseProtos.RegionInfo info = HBaseProtos.RegionInfo.newBuilder()
   .setTableName(HBaseProtos.TableName.newBuilder()
 
.setQualifier(UnsafeByteOperations.unsafeWrap(tableName.getQualifier()))
-
.setNamespace(UnsafeByteOperations.unsafeWrap(tableName.getNamespace()))
-.build())
+
.setNamespace(UnsafeByteOperations.unsafeWrap(tableName.getNamespace())).build())
   .setStartKey(UnsafeByteOperations.unsafeWrap(startKey))
-  .setEndKey(UnsafeByteOperations.unsafeWrap(endKey))
-  .setSplit(split)
-  .setRegionId(regionId)
+  
.setEndKey(UnsafeByteOperations.unsafeWrap(endKey)).setSplit(split).setRegionId(regionId)
   .build();
 
 convertedRi = ProtobufUtil.toRegionInfo(info);
-RegionInfo expectedRi = RegionInfoBuilder.newBuilder(tableName)
-.setStartKey(startKey)
-.setEndKey(endKey)
-.setSplit(split)
-.setRegionId(regionId)
-.setReplicaId(0).build();
+RegionInfo expectedRi = 
RegionInfoBuilder.newBuilder(tableName).setStartKey(startKey)
+  
.setEndKey(endKey).setSplit(split).setRegionId(regionId).setReplicaId(0).build();
 
 assertEquals(expectedRi, convertedRi);
   }
 
-  // Duplicated method in TestRegionInfoDisplay too.
-  private HRegionInfo convert(RegionInfo ri) {
-HRegionInfo hri = new HRegionInfo(
-ri.getTable(), ri.getStartKey(), ri.getEndKey(), ri.isSplit(), 
ri.getRegionId());
-hri.setOffline(ri.isOffline());
-return hri;
+  @Test
+  public void testNewBuilderWithRegionInfo() {
+RegionInfo ri = RegionInfoBuilder.newBuilder(name.getTableName()).build();
+RegionInfo ri2 = RegionInfoBuilder.newBuilder(ri).build();
+assertEquals(ri, ri2);
+
+// make sure that the region name and encoded name are changed, see 
HBASE-24500 for more
+// details.

Review comment:
   Add more test case?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org