@InterfaceAudience.Private public class MoveRegionProcedure extends AbstractStateMachineRegionProcedure<MasterProcedureProtos.MoveRegionState>
Throws exception on construction if determines context hostile to move (cluster going down or master is shutting down or table is disabled).
StateMachineProcedure.Flow
Procedure.LockState
TableProcedureInterface.TableOperationType
stateCount
NO_PROC_ID, NO_TIMEOUT
Constructor and Description |
---|
MoveRegionProcedure() |
MoveRegionProcedure(MasterProcedureEnv env,
RegionPlan plan,
boolean check) |
Modifier and Type | Method and Description |
---|---|
boolean |
abort(MasterProcedureEnv env)
The abort() call is asynchronous and each procedure must decide how to deal
with it, if they want to be abortable.
|
protected void |
deserializeStateData(ProcedureStateSerializer serializer)
Called on store load to allow the user to decode the previously serialized
state.
|
protected StateMachineProcedure.Flow |
executeFromState(MasterProcedureEnv env,
MasterProcedureProtos.MoveRegionState state)
called to perform a single step of the specified 'state' of the procedure
|
protected MasterProcedureProtos.MoveRegionState |
getInitialState()
Return the initial state object that will be used for the first call to executeFromState().
|
protected RegionPlan |
getPlan() |
protected MasterProcedureProtos.MoveRegionState |
getState(int stateId)
Convert an ordinal (or state id) to an Enum (or more descriptive) state object.
|
protected int |
getStateId(MasterProcedureProtos.MoveRegionState state)
Convert the Enum (or more descriptive) state object to an ordinal (or state id).
|
TableName |
getTableName() |
TableProcedureInterface.TableOperationType |
getTableOperationType()
Given an operation type we can take decisions about what to do with pending operations.
|
protected void |
rollbackState(MasterProcedureEnv env,
MasterProcedureProtos.MoveRegionState state)
called to perform the rollback of the specified state
|
protected void |
serializeStateData(ProcedureStateSerializer serializer)
The user-level code of the procedure may have some state to
persist (e.g.
|
void |
toStringClassDetails(StringBuilder sb)
Extend the toString() information with the procedure details
e.g.
|
protected boolean |
waitInitialized(MasterProcedureEnv env)
The
Procedure.doAcquireLock(Object, ProcedureStore) will be split into two steps, first, it will
call us to determine whether we need to wait for initialization, second, it will call
Procedure.acquireLock(Object) to actually handle the lock for this procedure. |
acquireLock, checkTableModifiable, getRegion, holdLock, releaseLock, setFailure, setRegion
checkOnline, getUser, getWALRegionDir, preflightChecks, releaseSyncLatch, setUser
addChildProcedure, execute, failIfAborted, getCurrentState, getCurrentStateId, getCycles, isEofState, isRollbackSupported, isYieldAfterExecutionStep, isYieldBeforeExecuteFromState, rollback, setNextState, toStringState
addStackIndex, afterReplay, beforeReplay, bypass, compareTo, completionCleanup, doExecute, doRollback, elapsedTime, getChildrenLatch, getException, getLastUpdate, getNonceKey, getOwner, getParentProcId, getProcedureMetrics, 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, setTimeoutFailure, shouldWaitClientAck, skipPersistence, toString, toStringClass, toStringDetails, toStringSimpleSB, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecuted
public MoveRegionProcedure()
public MoveRegionProcedure(MasterProcedureEnv env, RegionPlan plan, boolean check) throws HBaseIOException
check
- whether we should do some checks in the constructor. We will skip the checks if we
are reopening a region as this may fail the whole procedure and cause stuck. We will
do the check later when actually executing the procedure so not a big problem.IOException
- If the cluster is offline or master is stopping or if table is disabled or
non-existent.HBaseIOException
protected RegionPlan getPlan()
protected StateMachineProcedure.Flow executeFromState(MasterProcedureEnv env, MasterProcedureProtos.MoveRegionState state) throws InterruptedException
StateMachineProcedure
executeFromState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MoveRegionState>
state
- state to executeInterruptedException
protected void rollbackState(MasterProcedureEnv env, MasterProcedureProtos.MoveRegionState state) throws IOException
StateMachineProcedure
rollbackState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MoveRegionState>
state
- state to rollbackIOException
- temporary failure, the rollback will retry laterpublic boolean abort(MasterProcedureEnv env)
Procedure
NOTE: abort() is not like Thread.interrupt(). It is just a notification that allows the procedure implementor abort.
abort
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MoveRegionState>
public void toStringClassDetails(StringBuilder sb)
Procedure
toStringClassDetails
in class AbstractStateMachineRegionProcedure<MasterProcedureProtos.MoveRegionState>
sb
- the string builder to use to append the proc specific informationprotected MasterProcedureProtos.MoveRegionState getInitialState()
StateMachineProcedure
getInitialState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MoveRegionState>
protected int getStateId(MasterProcedureProtos.MoveRegionState state)
StateMachineProcedure
getStateId
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MoveRegionState>
state
- the state enum objectprotected MasterProcedureProtos.MoveRegionState getState(int stateId)
StateMachineProcedure
getState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MoveRegionState>
stateId
- the ordinal() of the state enum (or state id)public TableName getTableName()
getTableName
in interface TableProcedureInterface
getTableName
in class AbstractStateMachineRegionProcedure<MasterProcedureProtos.MoveRegionState>
public TableProcedureInterface.TableOperationType getTableOperationType()
TableProcedureInterface
getTableOperationType
in interface TableProcedureInterface
getTableOperationType
in class AbstractStateMachineRegionProcedure<MasterProcedureProtos.MoveRegionState>
protected void serializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
serializeStateData
in class AbstractStateMachineRegionProcedure<MasterProcedureProtos.MoveRegionState>
serializer
- stores the serializable stateIOException
protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
deserializeStateData
in class AbstractStateMachineRegionProcedure<MasterProcedureProtos.MoveRegionState>
serializer
- contains the serialized stateIOException
protected boolean waitInitialized(MasterProcedureEnv env)
Procedure
Procedure.doAcquireLock(Object, ProcedureStore)
will be split into two steps, first, it will
call us to determine whether we need to wait for initialization, second, it will call
Procedure.acquireLock(Object)
to actually handle the lock for this procedure.
This is because that when master restarts, we need to restore the lock state for all the
procedures to not break the semantic if Procedure.holdLock(Object)
is true. But the
ProcedureExecutor
will be started before the master finish initialization(as it is part
of the initialization!), so we need to split the code into two steps, and when restore, we just
restore the lock part and ignore the waitInitialized part. Otherwise there will be dead lock.waitInitialized
in class AbstractStateMachineTableProcedure<MasterProcedureProtos.MoveRegionState>
Copyright © 2007–2019 Cloudera. All rights reserved.