Package com.dtolabs.rundeck.core.rules
Class WorkflowEngine
- java.lang.Object
-
- com.dtolabs.rundeck.core.rules.WorkflowEngine
-
- All Implemented Interfaces:
StateWorkflowSystem
,WorkflowSystem<java.util.Map<java.lang.String,java.lang.String>>
,WorkflowSystemEventHandler
public class WorkflowEngine extends java.lang.Object implements StateWorkflowSystem, WorkflowSystemEventHandler
A WorkflowSystem which processes the operations by use of a rule system and a mutable state. implementation: Operations can supply state changes after they succeed, or fail. State changes provided by operations are added in the order they are received, and after a set of available state changes are added, the rule engine is used to update the state based on its rules. After the state is updated, all pending operations are queried to see if they can run given the new state, and any that can are queued to be executed. Workflow processing stops when no operations are currently running, no new state changes are available, and no pending operations can be run.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.dtolabs.rundeck.core.rules.StateWorkflowSystem
StateWorkflowSystem.OperationCompleteEvent<D,RES extends WorkflowSystem.OperationCompleted<D>,OP extends WorkflowSystem.Operation<D,RES>>, StateWorkflowSystem.OperationEvent<D>, StateWorkflowSystem.StateChange<D>, StateWorkflowSystem.StateChangeEvent<D>, StateWorkflowSystem.StateEvent<D>
-
Nested classes/interfaces inherited from interface com.dtolabs.rundeck.core.rules.WorkflowSystem
WorkflowSystem.Operation<X,T extends WorkflowSystem.OperationCompleted>, WorkflowSystem.OperationCompleted<T>, WorkflowSystem.OperationResult<D,T extends WorkflowSystem.OperationCompleted<D>,X extends WorkflowSystem.Operation<D,T>>, WorkflowSystem.SharedData<T,Y>
-
-
Constructor Summary
Constructors Constructor Description WorkflowEngine(RuleEngine ruleEngine, MutableStateObj state, java.util.concurrent.ExecutorService executor)
Create engine
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
event(WorkflowSystemEvent event)
handle eventvoid
event(WorkflowSystemEventType eventType, java.lang.String message)
handle event with messagevoid
event(WorkflowSystemEventType eventType, java.lang.String message, java.lang.Object data)
handle event with message and databoolean
isWorkflowEndState()
<DAT,RES extends WorkflowSystem.OperationCompleted<DAT>,OP extends WorkflowSystem.Operation<DAT,RES>>
java.util.Set<WorkflowSystem.OperationResult<DAT,RES,OP>>processOperations(java.util.Set<OP> operations, WorkflowSystem.SharedData<DAT,java.util.Map<java.lang.String,java.lang.String>> sharedData)
Process the operations and return results when all runnable operations are complete.<D> boolean
processStateChange(java.lang.String identity, StateObj newState, D newData, WorkflowSystem.SharedData<D,java.util.Map<java.lang.String,java.lang.String>> sharedData)
Handle the state changes for the rule engine-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.dtolabs.rundeck.core.rules.StateWorkflowSystem
getListeners, getRuleEngine, getState, setListeners
-
Methods inherited from interface com.dtolabs.rundeck.core.rules.WorkflowSystem
isInterrupted
-
-
-
-
Constructor Detail
-
WorkflowEngine
public WorkflowEngine(RuleEngine ruleEngine, MutableStateObj state, java.util.concurrent.ExecutorService executor)
Create engine- Parameters:
ruleEngine
- rule engine to process state changes via rulesstate
- initial stateexecutor
- executor to process operations, which should be multithreaded to process operations concurrently
-
-
Method Detail
-
processOperations
public <DAT,RES extends WorkflowSystem.OperationCompleted<DAT>,OP extends WorkflowSystem.Operation<DAT,RES>> java.util.Set<WorkflowSystem.OperationResult<DAT,RES,OP>> processOperations(java.util.Set<OP> operations, WorkflowSystem.SharedData<DAT,java.util.Map<java.lang.String,java.lang.String>> sharedData)
Description copied from interface:WorkflowSystem
Process the operations and return results when all runnable operations are complete.- Specified by:
processOperations
in interfaceWorkflowSystem<java.util.Map<java.lang.String,java.lang.String>>
- Type Parameters:
DAT
- shared data typeRES
- success result of an operationOP
- operation class- Parameters:
operations
- operations- Returns:
- set of results for all processed operations
-
processStateChange
public <D> boolean processStateChange(java.lang.String identity, StateObj newState, D newData, WorkflowSystem.SharedData<D,java.util.Map<java.lang.String,java.lang.String>> sharedData)
Description copied from interface:StateWorkflowSystem
Handle the state changes for the rule engine- Specified by:
processStateChange
in interfaceStateWorkflowSystem
- Parameters:
identity
- step identitynewState
- state change mapnewData
- new data provided by operationsharedData
- shared data- Returns:
- true if internal state was changed
-
event
public void event(WorkflowSystemEventType eventType, java.lang.String message)
Description copied from interface:WorkflowSystemEventHandler
handle event with message- Specified by:
event
in interfaceWorkflowSystemEventHandler
-
event
public void event(WorkflowSystemEventType eventType, java.lang.String message, java.lang.Object data)
Description copied from interface:WorkflowSystemEventHandler
handle event with message and data- Specified by:
event
in interfaceWorkflowSystemEventHandler
-
event
public void event(WorkflowSystemEvent event)
Description copied from interface:WorkflowSystemEventHandler
handle event- Specified by:
event
in interfaceWorkflowSystemEventHandler
-
isWorkflowEndState
public boolean isWorkflowEndState()
- Specified by:
isWorkflowEndState
in interfaceStateWorkflowSystem
- Returns:
- true if the state indicates the workflow should end
-
-