virajjasani commented on code in PR #5995: URL: https://github.com/apache/hbase/pull/5995#discussion_r1693760005
########## hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AbstractCloseTableRegionsProcedure.java: ########## @@ -0,0 +1,147 @@ +/* + * 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 java.util.function.Consumer; +import org.apache.commons.lang3.mutable.MutableBoolean; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure; +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.generated.ProcedureProtos; + +/** + * Base class for unassigning table regions. + */ [email protected] +public abstract class AbstractCloseTableRegionsProcedure<TState extends Enum<?>> + extends AbstractStateMachineTableProcedure<TState> { + + private static final Logger LOG = + LoggerFactory.getLogger(AbstractCloseTableRegionsProcedure.class); + + protected TableName tableName; + + private RetryCounter retryCounter; + + protected AbstractCloseTableRegionsProcedure() { + } + + protected AbstractCloseTableRegionsProcedure(TableName tableName) { + this.tableName = tableName; + } + + @Override + public TableName getTableName() { + return tableName; + } + + @Override + public TableOperationType getTableOperationType() { + return TableOperationType.REGION_EDIT; + } + + private Flow schedule(MasterProcedureEnv env) throws ProcedureSuspendedException { + MutableBoolean submitted = new MutableBoolean(false); + int inTransitionCount = submitUnassignProcedure(env, p -> { + submitted.setTrue(); + addChildProcedure(p); + }); + if (inTransitionCount > 0 && submitted.isFalse()) { + // we haven't scheduled any unassign procedures and there are still regions in + // transition, sleep for a while and try again + if (retryCounter == null) { + retryCounter = ProcedureUtil.createRetryCounter(env.getMasterConfiguration()); + } + long backoffMillis = retryCounter.getBackoffTimeAndIncrementAttempts(); + LOG.info( + "There are still {} region(s) in transition for closing regions of table {}" + + " when executing {}, suspend {}secs and try again later", + inTransitionCount, tableName, getClass().getSimpleName(), backoffMillis / 1000); Review Comment: Nice, this will be helpful -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
