@InterfaceAudience.Private public class MergeTableRegionsProcedure extends AbstractStateMachineTableProcedure<MasterProcedureProtos.MergeTableRegionsState>
Throws exception on construction if determines context hostile to merge (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 |
---|
MergeTableRegionsProcedure() |
MergeTableRegionsProcedure(MasterProcedureEnv env,
RegionInfo[] regionsToMerge,
boolean forcible) |
MergeTableRegionsProcedure(MasterProcedureEnv env,
RegionInfo regionToMergeA,
RegionInfo regionToMergeB) |
MergeTableRegionsProcedure(MasterProcedureEnv env,
RegionInfo regionToMergeA,
RegionInfo regionToMergeB,
boolean forcible) |
Modifier and Type | Method and Description |
---|---|
protected 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 Procedure.LockState |
acquireLock(MasterProcedureEnv env)
The user should override this method if they need a lock on an Entity.
|
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.MergeTableRegionsState state)
called to perform a single step of the specified 'state' of the procedure
|
protected MasterProcedureProtos.MergeTableRegionsState |
getInitialState()
Return the initial state object that will be used for the first call to executeFromState().
|
RegionInfo |
getMergedRegion() |
protected ProcedureMetrics |
getProcedureMetrics(MasterProcedureEnv env)
Override this method to provide procedure specific counters for submitted count, failed
count and time histogram.
|
protected MasterProcedureProtos.MergeTableRegionsState |
getState(int stateId)
Convert an ordinal (or state id) to an Enum (or more descriptive) state object.
|
protected int |
getStateId(MasterProcedureProtos.MergeTableRegionsState 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 boolean |
holdLock(MasterProcedureEnv env)
Used to keep the procedure lock even when the procedure is yielding or suspended.
|
protected boolean |
isRollbackSupported(MasterProcedureProtos.MergeTableRegionsState state)
Used by the default implementation of abort() to know if the current state can be aborted
and rollback can be triggered.
|
protected void |
releaseLock(MasterProcedureEnv env)
The user should override this method, and release lock if necessary.
|
protected void |
rollbackState(MasterProcedureEnv env,
MasterProcedureProtos.MergeTableRegionsState state)
To rollback
MergeTableRegionsProcedure , two AssignProcedures are asynchronously
submitted for each region to be merged (rollback doesn't wait on the completion of the
AssignProcedures) . |
protected void |
serializeStateData(ProcedureStateSerializer serializer)
The user-level code of the procedure may have some state to
persist (e.g.
|
void |
setRegionStateToMerging(MasterProcedureEnv env)
Set the region states to MERGING state
|
void |
toStringClassDetails(StringBuilder sb)
Extend the toString() information with the procedure details
e.g.
|
checkOnline, checkTableModifiable, getUser, getWALRegionDir, preflightChecks, releaseSyncLatch, setUser, waitInitialized
addChildProcedure, execute, failIfAborted, getCurrentState, getCurrentStateId, getCycles, isEofState, isYieldAfterExecutionStep, isYieldBeforeExecuteFromState, rollback, setNextState, toStringState
addStackIndex, 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, setTimeoutFailure, shouldWaitClientAck, skipPersistence, toString, toStringClass, toStringDetails, toStringSimpleSB, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecuted
public MergeTableRegionsProcedure()
public MergeTableRegionsProcedure(MasterProcedureEnv env, RegionInfo regionToMergeA, RegionInfo regionToMergeB) throws IOException
IOException
public MergeTableRegionsProcedure(MasterProcedureEnv env, RegionInfo regionToMergeA, RegionInfo regionToMergeB, boolean forcible) throws IOException
IOException
public MergeTableRegionsProcedure(MasterProcedureEnv env, RegionInfo[] regionsToMerge, boolean forcible) throws IOException
IOException
protected StateMachineProcedure.Flow executeFromState(MasterProcedureEnv env, MasterProcedureProtos.MergeTableRegionsState state)
StateMachineProcedure
executeFromState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MergeTableRegionsState>
state
- state to executeprotected void rollbackState(MasterProcedureEnv env, MasterProcedureProtos.MergeTableRegionsState state) throws IOException
MergeTableRegionsProcedure
, two AssignProcedures are asynchronously
submitted for each region to be merged (rollback doesn't wait on the completion of the
AssignProcedures) . This can be improved by changing rollback() to support sub-procedures.
See HBASE-19851 for details.rollbackState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MergeTableRegionsState>
state
- state to rollbackIOException
- temporary failure, the rollback will retry laterprotected boolean isRollbackSupported(MasterProcedureProtos.MergeTableRegionsState state)
StateMachineProcedure
protected MasterProcedureProtos.MergeTableRegionsState getState(int stateId)
StateMachineProcedure
getState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MergeTableRegionsState>
stateId
- the ordinal() of the state enum (or state id)protected int getStateId(MasterProcedureProtos.MergeTableRegionsState state)
StateMachineProcedure
getStateId
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MergeTableRegionsState>
state
- the state enum objectprotected MasterProcedureProtos.MergeTableRegionsState getInitialState()
StateMachineProcedure
getInitialState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MergeTableRegionsState>
protected void serializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
serializeStateData
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MergeTableRegionsState>
serializer
- stores the serializable stateIOException
protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
deserializeStateData
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.MergeTableRegionsState>
serializer
- contains the serialized stateIOException
public void toStringClassDetails(StringBuilder sb)
Procedure
toStringClassDetails
in class AbstractStateMachineTableProcedure<MasterProcedureProtos.MergeTableRegionsState>
sb
- the string builder to use to append the proc specific informationprotected Procedure.LockState acquireLock(MasterProcedureEnv env)
Procedure
Procedure.execute(Object)
. It calls Procedure.releaseLock(Object)
after the call to
execute.
If you need to hold the lock for the life of the Procedure -- i.e. you do not want any other
Procedure interfering while this Procedure is running, see Procedure.holdLock(Object)
.
Example: in our Master we can execute request in parallel for different tables. We can create
t1 and create t2 and these creates can be executed at the same time. Anything else on t1/t2 is
queued waiting that specific table create to happen.
There are 3 LockState:
acquireLock
in class AbstractStateMachineTableProcedure<MasterProcedureProtos.MergeTableRegionsState>
protected void releaseLock(MasterProcedureEnv env)
Procedure
releaseLock
in class AbstractStateMachineTableProcedure<MasterProcedureProtos.MergeTableRegionsState>
protected boolean holdLock(MasterProcedureEnv env)
Procedure
holdLock
in class Procedure<MasterProcedureEnv>
public TableName getTableName()
getTableName
in interface TableProcedureInterface
getTableName
in class AbstractStateMachineTableProcedure<MasterProcedureProtos.MergeTableRegionsState>
public TableProcedureInterface.TableOperationType getTableOperationType()
TableProcedureInterface
getTableOperationType
in interface TableProcedureInterface
getTableOperationType
in class AbstractStateMachineTableProcedure<MasterProcedureProtos.MergeTableRegionsState>
protected ProcedureMetrics getProcedureMetrics(MasterProcedureEnv env)
Procedure
getProcedureMetrics
in class Procedure<MasterProcedureEnv>
env
- The environment passed to the procedure executorpublic void setRegionStateToMerging(MasterProcedureEnv env)
env
- MasterProcedureEnvpublic RegionInfo getMergedRegion()
protected 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.MergeTableRegionsState>
Copyright © 2007–2019 Cloudera. All rights reserved.