Class AbstractStateMachineTableProcedure<TState>
java.lang.Object
org.apache.hadoop.hbase.procedure2.Procedure<TEnvironment>
org.apache.hadoop.hbase.procedure2.StateMachineProcedure<MasterProcedureEnv,TState>
org.apache.hadoop.hbase.master.procedure.AbstractStateMachineTableProcedure<TState>
- All Implemented Interfaces:
Comparable<Procedure<MasterProcedureEnv>>
,TableProcedureInterface
- Direct Known Subclasses:
AbstractStateMachineRegionProcedure
,CloneSnapshotProcedure
,CreateTableProcedure
,DeleteTableProcedure
,DisableTableProcedure
,EnableTableProcedure
,FlushTableProcedure
,GCMergedRegionsProcedure
,GCMultipleMergedRegionsProcedure
,InitMetaProcedure
,MergeTableRegionsProcedure
,ModifyStoreFileTrackerProcedure
,ModifyTableDescriptorProcedure
,ModifyTableProcedure
,ReopenTableRegionsProcedure
,RestoreSnapshotProcedure
,SnapshotProcedure
,TruncateTableProcedure
@Private
public abstract class AbstractStateMachineTableProcedure<TState>
extends StateMachineProcedure<MasterProcedureEnv,TState>
implements TableProcedureInterface
Base class for all the Table procedures that want to use a StateMachineProcedure. It provides
helpers like basic locking, sync latch, and toStringClassDetails().
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
StateMachineProcedure.Flow
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.procedure2.Procedure
Procedure.LockState
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.master.procedure.TableProcedureInterface
TableProcedureInterface.TableOperationType
-
Field Summary
Fields inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
stateCount
Fields inherited from class org.apache.hadoop.hbase.procedure2.Procedure
NO_PROC_ID, NO_TIMEOUT
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
protected
-
Method Summary
Modifier and TypeMethodDescriptionprotected Procedure.LockState
The user should override this method if they need a lock on an Entity.protected static void
checkOnline
(MasterProcedureEnv env, RegionInfo ri) Check region is online.protected void
Check whether a table is modifiable - exists and either offline or online with config setabstract TableName
Returns the name of the table the procedure is operating onGiven an operation type we can take decisions about what to do with pending operations.protected User
getUser()
protected final org.apache.hadoop.fs.Path
getWALRegionDir
(MasterProcedureEnv env, RegionInfo region) protected boolean
protected void
preflightChecks
(MasterProcedureEnv env, Boolean enabled) Check that cluster is up and master is running.protected void
The user should override this method, and release lock if necessary.protected void
protected void
void
Extend the toString() information with the procedure details e.g.protected boolean
TheProcedure.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 callProcedure.acquireLock(Object)
to actually handle the lock for this procedure.Methods inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
abort, addChildProcedure, deserializeStateData, execute, executeFromState, failIfAborted, getCurrentState, getCurrentStateId, getCycles, getInitialState, getState, getStateId, isEofState, isRollbackSupported, isRollbackSupported, isYieldAfterExecutionStep, isYieldBeforeExecuteFromState, rollback, rollbackState, serializeStateData, setNextState, toStringState
Methods inherited from class org.apache.hadoop.hbase.procedure2.Procedure
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, holdLock, incChildrenLatch, isBypass, isFailed, isFinished, isInitializing, isLockedWhenLoading, isRunnable, isSuccess, isWaiting, removeStackIndex, setAbortFailure, setChildrenLatch, setExecuted, setFailure, setFailure, setLastUpdate, setNonceKey, setOwner, setOwner, setParentProcId, setProcId, setResult, setRootProcId, setStackIndexes, setState, setSubmittedTime, setTimeout, setTimeoutFailure, shouldWaitClientAck, skipPersistence, suspend, toString, toStringClass, toStringDetails, toStringSimpleSB, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecuted
-
Field Details
-
syncLatch
-
user
-
-
Constructor Details
-
AbstractStateMachineTableProcedure
protected AbstractStateMachineTableProcedure() -
AbstractStateMachineTableProcedure
-
AbstractStateMachineTableProcedure
- Parameters:
env
- Uses this to set Procedure Owner at least.
-
-
Method Details
-
getTableName
Description copied from interface:TableProcedureInterface
Returns the name of the table the procedure is operating on- Specified by:
getTableName
in interfaceTableProcedureInterface
-
getTableOperationType
Description copied from interface:TableProcedureInterface
Given an operation type we can take decisions about what to do with pending operations. e.g. if we get a delete and we have some table operation pending (e.g. add column) we can abort those operations.- Specified by:
getTableOperationType
in interfaceTableProcedureInterface
- Returns:
- the operation type that the procedure is executing.
-
toStringClassDetails
Description copied from class:Procedure
Extend the toString() information with the procedure details e.g. className and parameters- Overrides:
toStringClassDetails
in classProcedure<MasterProcedureEnv>
- Parameters:
sb
- the string builder to use to append the proc specific information
-
waitInitialized
Description copied from class:Procedure
TheProcedure.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 callProcedure.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 ifProcedure.holdLock(Object)
is true. But theProcedureExecutor
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.- Overrides:
waitInitialized
in classProcedure<MasterProcedureEnv>
- Returns:
- true means we need to wait until the environment has been initialized, otherwise true.
-
acquireLock
Description copied from class:Procedure
The user should override this method if they need a lock on an Entity. A lock can be anything, and it is up to the implementor. The Procedure Framework will call this method just before it invokesProcedure.execute(Object)
. It callsProcedure.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, seeProcedure.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:- LOCK_ACQUIRED should be returned when the proc has the lock and the proc is ready to execute.
- LOCK_YIELD_WAIT should be returned when the proc has not the lock and the framework should take care of readding the procedure back to the runnable set for retry
- LOCK_EVENT_WAIT should be returned when the proc has not the lock and someone will take care of readding the procedure back to the runnable set when the lock is available.
- Overrides:
acquireLock
in classProcedure<MasterProcedureEnv>
- Returns:
- the lock state as described above.
-
releaseLock
Description copied from class:Procedure
The user should override this method, and release lock if necessary.- Overrides:
releaseLock
in classProcedure<MasterProcedureEnv>
-
getUser
-
setUser
-
releaseSyncLatch
-
checkTableModifiable
Check whether a table is modifiable - exists and either offline or online with config set- Parameters:
env
- MasterProcedureEnv- Throws:
IOException
-
getWALRegionDir
protected final org.apache.hadoop.fs.Path getWALRegionDir(MasterProcedureEnv env, RegionInfo region) throws IOException - Throws:
IOException
-
preflightChecks
Check that cluster is up and master is running. Check table is modifiable. Ifenabled
, check table is enabled else check it is disabled. Call in Procedure constructor so can pass any exception to caller.- Parameters:
enabled
- If true, check table is enabled and throw exception if not. If false, do the inverse. If null, do no table checks.- Throws:
HBaseIOException
-
isTableEnabled
-
checkOnline
protected static void checkOnline(MasterProcedureEnv env, RegionInfo ri) throws DoNotRetryRegionException Check region is online.- Throws:
DoNotRetryRegionException
-