You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by vj...@apache.org on 2020/10/05 10:26:59 UTC
[hbase] branch branch-2.3 updated: HBASE-25147 : Serialize
regionNames in ReopenTableRegionsProcedure
This is an automated email from the ASF dual-hosted git repository.
vjasani pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.3 by this push:
new 5abb36b HBASE-25147 : Serialize regionNames in ReopenTableRegionsProcedure
5abb36b is described below
commit 5abb36b578be7be4f0fe574b5e6de99d573bd606
Author: Viraj Jasani <vj...@apache.org>
AuthorDate: Mon Oct 5 15:37:34 2020 +0530
HBASE-25147 : Serialize regionNames in ReopenTableRegionsProcedure
Closes #2494
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../src/main/protobuf/MasterProcedure.proto | 1 +
.../procedure/ReopenTableRegionsProcedure.java | 24 +++++++++++++++++++---
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/hbase-protocol-shaded/src/main/protobuf/MasterProcedure.proto b/hbase-protocol-shaded/src/main/protobuf/MasterProcedure.proto
index de33345..573eac8 100644
--- a/hbase-protocol-shaded/src/main/protobuf/MasterProcedure.proto
+++ b/hbase-protocol-shaded/src/main/protobuf/MasterProcedure.proto
@@ -465,6 +465,7 @@ enum ReopenTableRegionsState {
message ReopenTableRegionsStateData {
required TableName table_name = 1;
repeated RegionLocation region = 2;
+ repeated bytes region_names = 3;
}
enum InitMetaState {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ReopenTableRegionsProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ReopenTableRegionsProcedure.java
index 7bf834c..1489f98 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ReopenTableRegionsProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ReopenTableRegionsProcedure.java
@@ -37,6 +37,7 @@ import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.hbase.thirdparty.com.google.protobuf.ByteString;
import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
@@ -57,19 +58,19 @@ public class ReopenTableRegionsProcedure
// Specify specific regions of a table to reopen.
// if specified null, all regions of the table will be reopened.
- private final List<byte[]> regionNames;
+ private List<byte[]> regionNames;
private List<HRegionLocation> regions = Collections.emptyList();
private RetryCounter retryCounter;
public ReopenTableRegionsProcedure() {
- regionNames = null;
+ regionNames = Collections.emptyList();
}
public ReopenTableRegionsProcedure(TableName tableName) {
this.tableName = tableName;
- this.regionNames = null;
+ this.regionNames = Collections.emptyList();
}
public ReopenTableRegionsProcedure(final TableName tableName,
@@ -224,6 +225,17 @@ public class ReopenTableRegionsProcedure
ReopenTableRegionsStateData.Builder builder = ReopenTableRegionsStateData.newBuilder()
.setTableName(ProtobufUtil.toProtoTableName(tableName));
regions.stream().map(ProtobufUtil::toRegionLocation).forEachOrdered(builder::addRegion);
+ if (CollectionUtils.isNotEmpty(regionNames)) {
+ // As of this writing, wrapping this statement withing if condition is only required
+ // for backward compatibility as we used to have 'regionNames' as null for cases
+ // where all regions of given table should be reopened. Now, we have kept emptyList()
+ // for 'regionNames' to indicate all regions of given table should be reopened unless
+ // 'regionNames' contains at least one specific region, in which case only list of regions
+ // that 'regionNames' contain should be reopened, not all regions of given table.
+ // Now, we don't need this check since we are not dealing with null 'regionNames' and hence,
+ // guarding by this if condition can be removed in HBase 4.0.0.
+ regionNames.stream().map(ByteString::copyFrom).forEachOrdered(builder::addRegionNames);
+ }
serializer.serialize(builder.build());
}
@@ -234,5 +246,11 @@ public class ReopenTableRegionsProcedure
tableName = ProtobufUtil.toTableName(data.getTableName());
regions = data.getRegionList().stream().map(ProtobufUtil::toRegionLocation)
.collect(Collectors.toList());
+ if (CollectionUtils.isNotEmpty(data.getRegionNamesList())) {
+ regionNames = data.getRegionNamesList().stream().map(ByteString::toByteArray)
+ .collect(Collectors.toList());
+ } else {
+ regionNames = Collections.emptyList();
+ }
}
}