@InterfaceAudience.Private public class CreateNamespaceProcedure extends AbstractStateMachineNamespaceProcedure<MasterProcedureProtos.CreateNamespaceState>
StateMachineProcedure.Flow
Procedure.LockState
TableProcedureInterface.TableOperationType
stateCount
NO_PROC_ID, NO_TIMEOUT
Constructor and Description |
---|
CreateNamespaceProcedure() |
CreateNamespaceProcedure(MasterProcedureEnv env,
NamespaceDescriptor nsDescriptor) |
CreateNamespaceProcedure(MasterProcedureEnv env,
NamespaceDescriptor nsDescriptor,
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 |
createDirectory(MasterProcedureEnv env,
NamespaceDescriptor nsDescriptor)
Create the namespace directory
|
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.CreateNamespaceState state)
called to perform a single step of the specified 'state' of the procedure
|
protected MasterProcedureProtos.CreateNamespaceState |
getInitialState()
Return the initial state object that will be used for the first call to executeFromState().
|
protected String |
getNamespaceName() |
protected MasterProcedureProtos.CreateNamespaceState |
getState(int stateId)
Convert an ordinal (or state id) to an Enum (or more descriptive) state object.
|
protected int |
getStateId(MasterProcedureProtos.CreateNamespaceState state)
Convert the Enum (or more descriptive) state object to an ordinal (or state id).
|
TableProcedureInterface.TableOperationType |
getTableOperationType()
Given an operation type we can take decisions about what to do with pending operations.
|
protected static void |
insertIntoNSTable(MasterProcedureEnv env,
NamespaceDescriptor nsDescriptor)
Insert the row into ns table
|
protected boolean |
isRollbackSupported(MasterProcedureProtos.CreateNamespaceState state)
Used by the default implementation of abort() to know if the current state can be aborted
and rollback can be triggered.
|
protected void |
rollbackState(MasterProcedureEnv env,
MasterProcedureProtos.CreateNamespaceState 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.
|
protected static void |
setNamespaceQuota(MasterProcedureEnv env,
NamespaceDescriptor nsDescriptor)
Set quota for the namespace
|
protected boolean |
shouldWaitClientAck(MasterProcedureEnv env)
By default, the executor will keep the procedure result around util
the eviction TTL is expired.
|
protected static void |
updateZKNamespaceManager(MasterProcedureEnv env,
NamespaceDescriptor nsDescriptor)
Update ZooKeeper.
|
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. |
getTableName, releaseLock, releaseSyncLatch, toStringClassDetails
abort, 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, 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, skipPersistence, toString, toStringClass, toStringDetails, toStringSimpleSB, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecuted
public CreateNamespaceProcedure()
public CreateNamespaceProcedure(MasterProcedureEnv env, NamespaceDescriptor nsDescriptor)
public CreateNamespaceProcedure(MasterProcedureEnv env, NamespaceDescriptor nsDescriptor, ProcedurePrepareLatch latch)
protected StateMachineProcedure.Flow executeFromState(MasterProcedureEnv env, MasterProcedureProtos.CreateNamespaceState state) throws InterruptedException
StateMachineProcedure
executeFromState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.CreateNamespaceState>
state
- state to executeInterruptedException
protected void rollbackState(MasterProcedureEnv env, MasterProcedureProtos.CreateNamespaceState state) throws IOException
StateMachineProcedure
rollbackState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.CreateNamespaceState>
state
- state to rollbackIOException
- temporary failure, the rollback will retry laterprotected boolean isRollbackSupported(MasterProcedureProtos.CreateNamespaceState state)
StateMachineProcedure
protected MasterProcedureProtos.CreateNamespaceState getState(int stateId)
StateMachineProcedure
getState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.CreateNamespaceState>
stateId
- the ordinal() of the state enum (or state id)protected int getStateId(MasterProcedureProtos.CreateNamespaceState state)
StateMachineProcedure
getStateId
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.CreateNamespaceState>
state
- the state enum objectprotected MasterProcedureProtos.CreateNamespaceState getInitialState()
StateMachineProcedure
getInitialState
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.CreateNamespaceState>
protected void serializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
serializeStateData
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.CreateNamespaceState>
serializer
- stores the serializable stateIOException
protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
deserializeStateData
in class StateMachineProcedure<MasterProcedureEnv,MasterProcedureProtos.CreateNamespaceState>
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 AbstractStateMachineNamespaceProcedure<MasterProcedureProtos.CreateNamespaceState>
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 AbstractStateMachineNamespaceProcedure<MasterProcedureProtos.CreateNamespaceState>
public TableProcedureInterface.TableOperationType getTableOperationType()
TableProcedureInterface
getTableOperationType
in interface TableProcedureInterface
getTableOperationType
in class AbstractStateMachineNamespaceProcedure<MasterProcedureProtos.CreateNamespaceState>
protected String getNamespaceName()
getNamespaceName
in class AbstractStateMachineNamespaceProcedure<MasterProcedureProtos.CreateNamespaceState>
protected static void createDirectory(MasterProcedureEnv env, NamespaceDescriptor nsDescriptor) throws IOException
env
- MasterProcedureEnvnsDescriptor
- NamespaceDescriptorIOException
protected static void insertIntoNSTable(MasterProcedureEnv env, NamespaceDescriptor nsDescriptor) throws IOException
env
- MasterProcedureEnvnsDescriptor
- NamespaceDescriptorIOException
protected static void updateZKNamespaceManager(MasterProcedureEnv env, NamespaceDescriptor nsDescriptor) throws IOException
env
- MasterProcedureEnvnsDescriptor
- NamespaceDescriptorIOException
protected static void setNamespaceQuota(MasterProcedureEnv env, NamespaceDescriptor nsDescriptor) throws IOException
env
- MasterProcedureEnvnsDescriptor
- NamespaceDescriptorIOException
protected boolean shouldWaitClientAck(MasterProcedureEnv env)
Procedure
shouldWaitClientAck
in class Procedure<MasterProcedureEnv>
env
- the environment passed to the ProcedureExecutorCopyright © 2007–2019 Cloudera. All rights reserved.