@InterfaceAudience.Private public abstract class AbstractStateMachineTableProcedure<TState> extends StateMachineProcedure<MasterProcedureEnv,TState> implements TableProcedureInterface
StateMachineProcedure.Flow
Procedure.LockState
TableProcedureInterface.TableOperationType
stateCount
NO_PROC_ID, NO_TIMEOUT
Modifier | Constructor and Description |
---|---|
protected |
AbstractStateMachineTableProcedure() |
protected |
AbstractStateMachineTableProcedure(MasterProcedureEnv env) |
protected |
AbstractStateMachineTableProcedure(MasterProcedureEnv env,
ProcedurePrepareLatch latch) |
Modifier and Type | Method and Description |
---|---|
protected Procedure.LockState |
acquireLock(MasterProcedureEnv env)
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 |
checkTableModifiable(MasterProcedureEnv env)
Check whether a table is modifiable - exists and either offline or online with config set
|
abstract TableName |
getTableName() |
abstract TableProcedureInterface.TableOperationType |
getTableOperationType()
Given an operation type we can take decisions about what to do with pending operations.
|
protected User |
getUser() |
protected org.apache.hadoop.fs.Path |
getWALRegionDir(MasterProcedureEnv env,
RegionInfo region) |
protected void |
preflightChecks(MasterProcedureEnv env,
Boolean enabled)
Check that cluster is up and master is running.
|
protected void |
releaseLock(MasterProcedureEnv env)
The user should override this method, and release lock if necessary.
|
protected void |
releaseSyncLatch() |
protected void |
setUser(User user) |
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. |
abort, addChildProcedure, deserializeStateData, execute, executeFromState, failIfAborted, getCurrentState, getCurrentStateId, getCycles, getInitialState, getState, getStateId, isEofState, isRollbackSupported, isYieldAfterExecutionStep, isYieldBeforeExecuteFromState, rollback, rollbackState, serializeStateData, 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, holdLock, 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
protected AbstractStateMachineTableProcedure()
protected AbstractStateMachineTableProcedure(MasterProcedureEnv env)
protected AbstractStateMachineTableProcedure(MasterProcedureEnv env, ProcedurePrepareLatch latch)
env
- Uses this to set Procedure Owner at least.public abstract TableName getTableName()
getTableName
in interface TableProcedureInterface
public abstract TableProcedureInterface.TableOperationType getTableOperationType()
TableProcedureInterface
getTableOperationType
in interface TableProcedureInterface
public void toStringClassDetails(StringBuilder sb)
Procedure
toStringClassDetails
in class Procedure<MasterProcedureEnv>
sb
- the string builder to use to append the proc specific informationprotected 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 Procedure<MasterProcedureEnv>
protected 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 Procedure<MasterProcedureEnv>
protected void releaseLock(MasterProcedureEnv env)
Procedure
releaseLock
in class Procedure<MasterProcedureEnv>
protected User getUser()
protected void setUser(User user)
protected void releaseSyncLatch()
protected void checkTableModifiable(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
protected final org.apache.hadoop.fs.Path getWALRegionDir(MasterProcedureEnv env, RegionInfo region) throws IOException
IOException
protected void preflightChecks(MasterProcedureEnv env, Boolean enabled) throws HBaseIOException
enabled
, check table is enabled else check it is disabled.
Call in Procedure constructor so can pass any exception to caller.enabled
- If true, check table is enabled and throw exception if not. If false, do the
inverse. If null, do no table checks.HBaseIOException
protected static void checkOnline(MasterProcedureEnv env, RegionInfo ri) throws DoNotRetryRegionException
DoNotRetryRegionException
Copyright © 2007–2019 Cloudera. All rights reserved.