Class AbstractOperatePipeProcedureV2
java.lang.Object
org.apache.iotdb.confignode.procedure.Procedure<Env>
org.apache.iotdb.confignode.procedure.impl.StateMachineProcedure<ConfigNodeProcedureEnv,TState>
org.apache.iotdb.confignode.procedure.impl.node.AbstractNodeProcedure<OperatePipeTaskState>
org.apache.iotdb.confignode.procedure.impl.pipe.AbstractOperatePipeProcedureV2
- All Implemented Interfaces:
Comparable<Procedure<ConfigNodeProcedureEnv>>
- Direct Known Subclasses:
AlterPipeProcedureV2,CreatePipeProcedureV2,DropPipeProcedureV2,PipeHandleLeaderChangeProcedure,PipeHandleMetaChangeProcedure,PipeMetaSyncProcedure,StartPipeProcedureV2,StopPipeProcedureV2
public abstract class AbstractOperatePipeProcedureV2
extends AbstractNodeProcedure<OperatePipeTaskState>
This procedure manages 2 kinds of PIPE operations:
- PIPE user task operations:
- PIPE runtime task operations:
This class extends AbstractNodeProcedure to make sure that pipe task procedures can be
executed in sequence and node procedures can be locked when a pipe task procedure is running.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.iotdb.confignode.procedure.impl.StateMachineProcedure
StateMachineProcedure.Flow -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected AtomicReference<PipeTaskInfo>Fields inherited from class org.apache.iotdb.confignode.procedure.impl.StateMachineProcedure
isGeneratedByPipeFields inherited from class org.apache.iotdb.confignode.procedure.Procedure
NO_PROC_ID, NO_TIMEOUT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ProcedureLockStateacquireLock(ConfigNodeProcedureEnv configNodeProcedureEnv) Acquire a lock, user should override it if necessary.protected AtomicReference<PipeTaskInfo>acquireLockInternal(ConfigNodeProcedureEnv configNodeProcedureEnv) voiddeserialize(ByteBuffer byteBuffer) protected Map<Integer,TPushPipeMetaResp> dropSinglePipeOnDataNodes(String pipeName, ConfigNodeProcedureEnv env) Drop a pipe on all the dataNodes.abstract voidExecute at stateOperatePipeTaskState.CALCULATE_INFO_FOR_TASK.abstract voidExecute at stateOperatePipeTaskState.OPERATE_ON_DATA_NODES.protected StateMachineProcedure.FlowCalled to perform a single step of the specified 'state' of the procedure.abstract booleanExecute at stateOperatePipeTaskState.VALIDATE_TASK.abstract voidExecute at stateOperatePipeTaskState.WRITE_CONFIG_NODE_CONSENSUS.‘protected OperatePipeTaskStateReturn the initial state object that will be used for the first call to executeFromState().protected abstract PipeTaskOperationprotected OperatePipeTaskStategetState(int stateId) Convert an ordinal (or state id) to an Enum (or more descriptive) state object.protected intgetStateId(OperatePipeTaskState state) Convert the Enum (or more descriptive) state object to an ordinal (or state id).protected booleanUsed by the default implementation of abort() to know if the current state can be aborted and rollback can be triggered.static StringparsePushPipeMetaExceptionForPipe(String pipeName, Map<Integer, TPushPipeMetaResp> respMap) Parsing the given pipe's or all pipes' pushPipeMeta exceptions to string.protected Map<Integer,TPushPipeMetaResp> Pushing all the pipeMeta's to all the dataNodes, forcing an update to the pipe's runtime state.static Map<Integer,TPushPipeMetaResp> pushPipeMetaToDataNodes(ConfigNodeProcedureEnv env, AtomicReference<PipeTaskInfo> pipeTaskInfo) Pushing all the pipeMeta's to all the dataNodes, forcing an update to the pipe's runtime state.protected voidprotected Map<Integer,TPushPipeMetaResp> pushSinglePipeMetaToDataNodes(String pipeName, ConfigNodeProcedureEnv env) Pushing one pipeMeta to all the dataNodes, forcing an update to the pipe's runtime state.protected voidreleaseLock(ConfigNodeProcedureEnv configNodeProcedureEnv) Release a lock, user should override it if necessary.abstract voidabstract voidabstract voidabstract voidprotected voidrollbackState(ConfigNodeProcedureEnv env, OperatePipeTaskState state) Called to perform the rollback of the specified state.voidserialize(DataOutputStream stream) Methods inherited from class org.apache.iotdb.confignode.procedure.impl.StateMachineProcedure
addChildProcedure, execute, getCurrentState, getCycles, isEofState, isStateDeserialized, rollback, setNextState, toStringStateMethods inherited from class org.apache.iotdb.confignode.procedure.Procedure
addStackIndex, compareTo, deserializeTypeInfoForCompatibility, doAcquireLock, doExecute, doReleaseLock, doRollback, elapsedTime, getChildrenLatch, getException, getLastUpdate, getParentProcId, getProcId, getProcType, getResult, getRootProcId, getStackIndexes, getState, getSubmittedTime, getTimeout, getTimeoutTimestamp, hasChildren, hasException, hasLock, hasParent, hasTimeout, haveSameParent, holdLock, incChildrenLatch, isFailed, isFinished, isInitializing, isLockedWhenLoading, isRunnable, isSuccess, isWaiting, isYieldAfterExecution, removeStackIndex, restoreLock, setChildrenLatch, setFailure, setFailure, setLastUpdate, setParentProcId, setProcId, setProcRunnable, setResult, setRootProcedureId, setRootProcId, setStackIndexes, setState, setSubmittedTime, setTimeout, setTimeoutFailure, toString, toStringClassDetails, toStringDetails, toStringSimpleSB, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecuted
-
Field Details
-
isRollbackFromOperateOnDataNodesSuccessful
protected boolean isRollbackFromOperateOnDataNodesSuccessful -
isRollbackFromValidateTaskSuccessful
protected boolean isRollbackFromValidateTaskSuccessful -
pipeTaskInfo
-
-
Constructor Details
-
AbstractOperatePipeProcedureV2
public AbstractOperatePipeProcedureV2()
-
-
Method Details
-
acquireLockInternal
protected AtomicReference<PipeTaskInfo> acquireLockInternal(ConfigNodeProcedureEnv configNodeProcedureEnv) -
acquireLock
Description copied from class:ProcedureAcquire a lock, user should override it if necessary.- Overrides:
acquireLockin classAbstractNodeProcedure<OperatePipeTaskState>- Parameters:
configNodeProcedureEnv- environment- Returns:
- state of lock
-
releaseLock
Description copied from class:ProcedureRelease a lock, user should override it if necessary.- Overrides:
releaseLockin classAbstractNodeProcedure<OperatePipeTaskState>- Parameters:
configNodeProcedureEnv- env
-
getOperation
-
executeFromValidateTask
Execute at stateOperatePipeTaskState.VALIDATE_TASK.- Returns:
- false if this procedure can skip subsequent stages (start RUNNING pipe or stop STOPPED pipe without runtime exception)
- Throws:
PipeException- if validation for pipe parameters failed
-
executeFromCalculateInfoForTask
Execute at stateOperatePipeTaskState.CALCULATE_INFO_FOR_TASK. -
executeFromWriteConfigNodeConsensus
public abstract void executeFromWriteConfigNodeConsensus(ConfigNodeProcedureEnv env) throws PipeException Execute at stateOperatePipeTaskState.WRITE_CONFIG_NODE_CONSENSUS.‘- Throws:
PipeException- if configNode consensus write failed
-
executeFromOperateOnDataNodes
public abstract void executeFromOperateOnDataNodes(ConfigNodeProcedureEnv env) throws PipeException, IOException Execute at stateOperatePipeTaskState.OPERATE_ON_DATA_NODES.- Throws:
PipeException- if push pipe metas to dataNodes failedIOException- Exception when Serializing to byte buffer
-
executeFromState
protected StateMachineProcedure.Flow executeFromState(ConfigNodeProcedureEnv env, OperatePipeTaskState state) throws InterruptedException Description copied from class:StateMachineProcedureCalled to perform a single step of the specified 'state' of the procedure.- Specified by:
executeFromStatein classStateMachineProcedure<ConfigNodeProcedureEnv,OperatePipeTaskState> state- state to execute- Returns:
- Flow.NO_MORE_STATE if the procedure is completed, Flow.HAS_MORE_STATE if there is another step.
- Throws:
InterruptedException
-
isRollbackSupported
Description copied from class:StateMachineProcedureUsed by the default implementation of abort() to know if the current state can be aborted and rollback can be triggered.- Overrides:
isRollbackSupportedin classStateMachineProcedure<ConfigNodeProcedureEnv,OperatePipeTaskState>
-
rollbackState
protected void rollbackState(ConfigNodeProcedureEnv env, OperatePipeTaskState state) throws IOException, InterruptedException, ProcedureException Description copied from class:StateMachineProcedureCalled to perform the rollback of the specified state.- Specified by:
rollbackStatein classStateMachineProcedure<ConfigNodeProcedureEnv,OperatePipeTaskState> state- state to rollback- Throws:
IOException- temporary failure, the rollback will retry laterInterruptedExceptionProcedureException
-
rollbackFromValidateTask
-
rollbackFromCalculateInfoForTask
-
rollbackFromWriteConfigNodeConsensus
-
rollbackFromOperateOnDataNodes
- Throws:
IOException
-
getState
Description copied from class:StateMachineProcedureConvert an ordinal (or state id) to an Enum (or more descriptive) state object.- Specified by:
getStatein classStateMachineProcedure<ConfigNodeProcedureEnv,OperatePipeTaskState> - Parameters:
stateId- the ordinal() of the state enum (or state id)- Returns:
- the state enum object
-
getStateId
Description copied from class:StateMachineProcedureConvert the Enum (or more descriptive) state object to an ordinal (or state id).- Specified by:
getStateIdin classStateMachineProcedure<ConfigNodeProcedureEnv,OperatePipeTaskState> - Parameters:
state- the state enum object- Returns:
- stateId the ordinal() of the state enum (or state id)
-
getInitialState
Description copied from class:StateMachineProcedureReturn the initial state object that will be used for the first call to executeFromState().- Specified by:
getInitialStatein classStateMachineProcedure<ConfigNodeProcedureEnv,OperatePipeTaskState> - Returns:
- the initial state enum object
-
pushPipeMetaToDataNodes
protected Map<Integer,TPushPipeMetaResp> pushPipeMetaToDataNodes(ConfigNodeProcedureEnv env) throws IOException Pushing all the pipeMeta's to all the dataNodes, forcing an update to the pipe's runtime state.- Parameters:
env- ConfigNodeProcedureEnv- Returns:
- The responseMap after pushing pipe meta
- Throws:
IOException- Exception when Serializing to byte buffer
-
pushPipeMetaToDataNodes
public static Map<Integer,TPushPipeMetaResp> pushPipeMetaToDataNodes(ConfigNodeProcedureEnv env, AtomicReference<PipeTaskInfo> pipeTaskInfo) throws IOException Pushing all the pipeMeta's to all the dataNodes, forcing an update to the pipe's runtime state.- Parameters:
env- ConfigNodeProcedureEnvpipeTaskInfo- PipeTaskInfo managed outside this procedure- Returns:
- The responseMap after pushing pipe meta
- Throws:
IOException- Exception when Serializing to byte buffer
-
parsePushPipeMetaExceptionForPipe
public static String parsePushPipeMetaExceptionForPipe(String pipeName, Map<Integer, TPushPipeMetaResp> respMap) Parsing the given pipe's or all pipes' pushPipeMeta exceptions to string.- Parameters:
pipeName- The given pipe's pipe name,nullif report all pipes' exceptions.respMap- The responseMap after pushing pipe meta- Returns:
- Error messages for the given pipe after pushing pipe meta
-
pushPipeMetaToDataNodesIgnoreException
-
pushSinglePipeMetaToDataNodes
protected Map<Integer,TPushPipeMetaResp> pushSinglePipeMetaToDataNodes(String pipeName, ConfigNodeProcedureEnv env) throws IOException Pushing one pipeMeta to all the dataNodes, forcing an update to the pipe's runtime state.- Parameters:
pipeName- pipe name of the pipe to pushenv- ConfigNodeProcedureEnv- Returns:
- The responseMap after pushing pipe meta
- Throws:
IOException- Exception when Serializing to byte buffer
-
dropSinglePipeOnDataNodes
protected Map<Integer,TPushPipeMetaResp> dropSinglePipeOnDataNodes(String pipeName, ConfigNodeProcedureEnv env) Drop a pipe on all the dataNodes.- Parameters:
pipeName- pipe name of the pipe to dropenv- ConfigNodeProcedureEnv- Returns:
- The responseMap after pushing pipe meta
-
serialize
- Overrides:
serializein classStateMachineProcedure<ConfigNodeProcedureEnv,OperatePipeTaskState> - Throws:
IOException
-
deserialize
- Overrides:
deserializein classStateMachineProcedure<ConfigNodeProcedureEnv,OperatePipeTaskState>
-