Umeshkumar9414 commented on code in PR #5903:
URL: https://github.com/apache/hbase/pull/5903#discussion_r1609221184


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CloseExcessRegionReplicasProcedure.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.master.procedure;
+
+import java.io.IOException;
+import org.apache.commons.lang3.mutable.MutableBoolean;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.procedure2.ProcedureStateSerializer;
+import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException;
+import org.apache.hadoop.hbase.procedure2.ProcedureUtil;
+import org.apache.hadoop.hbase.procedure2.ProcedureYieldException;
+import org.apache.hadoop.hbase.util.RetryCounter;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
+import 
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.CloseExcessRegionReplicasProcedureState;
+import 
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.CloseExcessRegionReplicasProcedureStateData;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;
+
+/**
+ * Procedure for close excess region replicas.
+ */
+@InterfaceAudience.Private
+public class CloseExcessRegionReplicasProcedure
+  extends 
AbstractStateMachineTableProcedure<CloseExcessRegionReplicasProcedureState> {
+
+  private static final Logger LOG =
+    LoggerFactory.getLogger(CloseExcessRegionReplicasProcedure.class);
+
+  private TableName tableName;
+  private int newReplicaCount;
+
+  private RetryCounter retryCounter;
+
+  public CloseExcessRegionReplicasProcedure() {
+  }
+
+  public CloseExcessRegionReplicasProcedure(TableName tableName, int 
newReplicaCount) {
+    this.tableName = tableName;
+    this.newReplicaCount = newReplicaCount;
+  }
+
+  @Override
+  public TableName getTableName() {
+    return tableName;
+  }
+
+  @Override
+  public TableOperationType getTableOperationType() {
+    return TableOperationType.REGION_EDIT;
+  }
+
+  @Override
+  protected Flow executeFromState(MasterProcedureEnv env,
+    CloseExcessRegionReplicasProcedureState state)
+    throws ProcedureSuspendedException, ProcedureYieldException, 
InterruptedException {
+    LOG.trace("{} execute state={}", this, state);
+    switch (state) {
+      case CLOSE_EXCESS_REGION_REPLICAS_SCHEDULE:
+        MutableBoolean submitted = new MutableBoolean(false);
+        int inTransitionCount = env.getAssignmentManager()
+          .submitUnassignProcedureForClosingExcessRegionReplicas(tableName, 
newReplicaCount, p -> {
+            submitted.setTrue();
+            addChildProcedure(p);
+          });
+        if (inTransitionCount > 0 && submitted.isFalse()) {

Review Comment:
   there might be a case where we have scheduled unassign procedures for some 
regions and some are in transition. Are we changing the state back to 
CLOSE_EXCESS_REGION_REPLICAS_SCHEDULE from CLOSE_EXCESS_REGION_REPLICAS_CONFIRM 
for this 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.

To unsubscribe, e-mail: issues-unsubscr...@hbase.apache.org

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

Reply via email to