@InterfaceAudience.Private public class TransitRegionStateProcedure extends AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionStateTransitionState>
unassign(MasterProcedureEnv, RegionInfo) and
reopen(MasterProcedureEnv, RegionInfo), you do not need to specify a target server, and
for assign(MasterProcedureEnv, RegionInfo, ServerName) and
move(MasterProcedureEnv, RegionInfo, ServerName), if you want to you can provide a
target server. And for move(MasterProcedureEnv, RegionInfo, ServerName), if you do not
specify a targetServer, we will select one randomly.
The typical state transition for assigning a region is:
GET_ASSIGN_CANDIDATE ------> OPEN -----> CONFIRM_OPENEDNotice that, if there are failures we may go back to the
GET_ASSIGN_CANDIDATE state to
try again.
The typical state transition for unassigning a region is:
CLOSE -----> CONFIRM_CLOSEDHere things go a bit different, if there are failures, especially that if there is a server crash, we will go to the
GET_ASSIGN_CANDIDATE state to bring the region online first, and
then go through the normal way to unassign it.
The typical state transition for reopening/moving a region is:
CLOSE -----> CONFIRM_CLOSED -----> GET_ASSIGN_CANDIDATE ------> OPEN -----> CONFIRM_OPENEDThe retry logic is the same with the above assign/unassign. Notice that, although we allow specify a target server, it just acts as a candidate, we do not guarantee that the region will finally be on the target server. If this is important for you, you should check whether the region is on the target server after the procedure is finished. When you want to schedule a TRSP, please check whether there is still one for this region, and the check should be under the RegionStateNode lock. We will remove the TRSP from a RegionStateNode when we are done, see the code in
reportTransition method below. There
could be at most one TRSP for a give region.| Modifier and Type | Class and Description |
|---|---|
static class |
TransitRegionStateProcedure.TransitionType |
StateMachineProcedure.FlowProcedure.LockStateTableProcedureInterface.TableOperationTypeNO_PROC_ID, NO_TIMEOUT| Modifier | Constructor and Description |
|---|---|
|
TransitRegionStateProcedure() |
protected |
TransitRegionStateProcedure(MasterProcedureEnv env,
RegionInfo hri,
ServerName assignCandidate,
boolean forceNewPlan,
TransitRegionStateProcedure.TransitionType type) |
acquireLock, checkTableModifiable, getRegion, getTableName, holdLock, releaseLock, setFailure, setRegioncheckOnline, getUser, getWALRegionDir, preflightChecks, releaseSyncLatch, setUserabort, addChildProcedure, failIfAborted, getCurrentState, getCurrentStateId, getCycles, isRollbackSupported, isYieldAfterExecutionStep, isYieldBeforeExecuteFromState, rollback, setNextState, toStringStateaddStackIndex, afterReplay, beforeReplay, bypass, compareTo, completionCleanup, doExecute, doRollback, elapsedTime, getChildrenLatch, getException, getLastUpdate, getNonceKey, getOwner, getParentProcId, getProcId, getProcIdHashCode, getProcName, getResult, getRootProcedureId, getRootProcId, getStackIndexes, getState, getSubmittedTime, getTimeout, getTimeoutTimestamp, hasChildren, hasException, hasLock, hasOwner, hasParent, hasTimeout, haveSameParent, incChildrenLatch, isBypass, isFailed, isFinished, isInitializing, isLockedWhenLoading, isRunnable, isSuccess, isWaiting, removeStackIndex, setAbortFailure, setChildrenLatch, setFailure, setFailure, setLastUpdate, setNonceKey, setOwner, setOwner, setParentProcId, setProcId, setResult, setRootProcId, setStackIndexes, setState, setSubmittedTime, setTimeout, shouldWaitClientAck, skipPersistence, toString, toStringClass, toStringDetails, toStringSimpleSB, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecutedpublic TransitRegionStateProcedure()
protected TransitRegionStateProcedure(MasterProcedureEnv env, RegionInfo hri, ServerName assignCandidate, boolean forceNewPlan, TransitRegionStateProcedure.TransitionType type)
public TableProcedureInterface.TableOperationType getTableOperationType()
TableProcedureInterfacegetTableOperationType in interface TableProcedureInterfacegetTableOperationType in class AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionStateTransitionState>protected boolean waitInitialized(MasterProcedureEnv env)
protected Procedure[] execute(MasterProcedureEnv env) throws ProcedureSuspendedException, ProcedureYieldException, InterruptedException
protected StateMachineProcedure.Flow executeFromState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionStateTransitionState state) throws ProcedureSuspendedException, ProcedureYieldException, InterruptedException
protected boolean setTimeoutFailure(MasterProcedureEnv env)
setTimeoutFailure in class Procedure<MasterProcedureEnv>public void reportTransition(MasterProcedureEnv env, RegionStateNode regionNode, ServerName serverName, org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode code, long seqId, long procId) throws IOException
IOExceptionpublic void serverCrashed(MasterProcedureEnv env, RegionStateNode regionNode, ServerName serverName) throws IOException
IOExceptionprotected void rollbackState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionStateTransitionState state) throws IOException, InterruptedException
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionStateTransitionState getState(int stateId)
protected int getStateId(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionStateTransitionState state)
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionStateTransitionState getInitialState()
protected void serializeStateData(ProcedureStateSerializer serializer) throws IOException
protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException
protected ProcedureMetrics getProcedureMetrics(MasterProcedureEnv env)
getProcedureMetrics in class Procedure<MasterProcedureEnv>public void toStringClassDetails(StringBuilder sb)
public static TransitRegionStateProcedure assign(MasterProcedureEnv env, RegionInfo region, @Nullable ServerName targetServer)
public static TransitRegionStateProcedure assign(MasterProcedureEnv env, RegionInfo region, boolean forceNewPlan, @Nullable ServerName targetServer)
public static TransitRegionStateProcedure unassign(MasterProcedureEnv env, RegionInfo region)
public static TransitRegionStateProcedure reopen(MasterProcedureEnv env, RegionInfo region)
public static TransitRegionStateProcedure move(MasterProcedureEnv env, RegionInfo region, @Nullable ServerName targetServer)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.