Package io.nflow.engine.workflow.curated
Class BulkWorkflow
- java.lang.Object
-
- io.nflow.engine.model.ModelObject
-
- io.nflow.engine.workflow.definition.WorkflowDefinition
-
- io.nflow.engine.workflow.curated.BulkWorkflow
-
@Component public class BulkWorkflow extends WorkflowDefinition
Bulk child workflow executor that does not overflow the system.
-
-
Field Summary
Fields Modifier and Type Field Description static StringBULK_WORKFLOW_TYPEThe type of default bulk workflow.static WorkflowStateDONEstatic WorkflowStateERRORstatic WorkflowStateSPLIT_WORKBulk workflow states.static StringVAR_CHILD_DATAState variable name for child data.static StringVAR_CONCURRENCYState variable to define the maximum concurrency for executing child workflows.static WorkflowStateWAIT_FOR_CHILDREN_TO_FINISH-
Fields inherited from class io.nflow.engine.workflow.definition.WorkflowDefinition
allowedTransitions, failureTransitions
-
-
Constructor Summary
Constructors Modifier Constructor Description BulkWorkflow()Create bulk workflow definition.protectedBulkWorkflow(String type)Extend bulk workflow definition.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanisRunning(WorkflowInstance instance)Override this to determine if the child workflow is running or not.NextActionsplitWork(StateExecution execution, com.fasterxml.jackson.databind.JsonNode data)CallsplitWorkImpl(io.nflow.engine.workflow.definition.StateExecution,com.fasterxml.jackson.databind.JsonNode)to create new child workflows.protected booleansplitWorkImpl(StateExecution execution, com.fasterxml.jackson.databind.JsonNode data)Override this to create child workflows or add the children before starting the parent.protected org.joda.time.DateTimewaitForChildrenToCompleteUntil()Override this to customize the time to wait for children to finish.NextActionwaitForChildrenToFinish(StateExecution execution, int concurrency)Check if all child workflows have finished.protected org.joda.time.DateTimewaitForChildrenUntil()Override this to customize the time to wait for new children before waking up.-
Methods inherited from class io.nflow.engine.workflow.definition.WorkflowDefinition
getAllowedTransitions, getDescription, getErrorState, getFailureTransitions, getInitialState, getMethod, getMethod, getName, getSettings, getState, getStates, getSupportedSignals, getType, isAllowedNextAction, isStartState, permit, permit, registerState, setDescription, setName
-
Methods inherited from class io.nflow.engine.model.ModelObject
equals, hashCode, toString
-
-
-
-
Field Detail
-
BULK_WORKFLOW_TYPE
public static final String BULK_WORKFLOW_TYPE
The type of default bulk workflow.- See Also:
- Constant Field Values
-
VAR_CHILD_DATA
public static final String VAR_CHILD_DATA
State variable name for child data.- See Also:
- Constant Field Values
-
VAR_CONCURRENCY
public static final String VAR_CONCURRENCY
State variable to define the maximum concurrency for executing child workflows.- See Also:
- Constant Field Values
-
SPLIT_WORK
public static final WorkflowState SPLIT_WORK
Bulk workflow states.
-
WAIT_FOR_CHILDREN_TO_FINISH
public static final WorkflowState WAIT_FOR_CHILDREN_TO_FINISH
-
DONE
public static final WorkflowState DONE
-
ERROR
public static final WorkflowState ERROR
-
-
Constructor Detail
-
BulkWorkflow
protected BulkWorkflow(String type)
Extend bulk workflow definition.- Parameters:
type- The type of the workflow.
-
BulkWorkflow
public BulkWorkflow()
Create bulk workflow definition.
-
-
Method Detail
-
splitWork
public NextAction splitWork(StateExecution execution, com.fasterxml.jackson.databind.JsonNode data)
CallsplitWorkImpl(io.nflow.engine.workflow.definition.StateExecution,com.fasterxml.jackson.databind.JsonNode)to create new child workflows.- Parameters:
execution- State execution context.data- Child data.- Returns:
- Action to start waiting for children to finish or action to wait for children to be created.
-
splitWorkImpl
protected boolean splitWorkImpl(StateExecution execution, com.fasterxml.jackson.databind.JsonNode data)
Override this to create child workflows or add the children before starting the parent.- Parameters:
execution- State execution context.data- Child data.- Returns:
- True to start processing the children, false to wait for children to be created.
- Throws:
RuntimeException- Thrown by default implementation if children are not created before the parent is started.
-
waitForChildrenUntil
protected org.joda.time.DateTime waitForChildrenUntil()
Override this to customize the time to wait for new children before waking up. Default is one hour.- Returns:
- Time when parent should wake up to check if new children have been added.
-
waitForChildrenToFinish
public NextAction waitForChildrenToFinish(StateExecution execution, int concurrency)
Check if all child workflows have finished. Start new children if needed and allowed by concurrency limit.- Parameters:
execution- State execution context.concurrency- The maximum number of child workflows to start.- Returns:
- Action to retry this state at the time returned by
waitForChildrenToCompleteUntil().
-
isRunning
protected boolean isRunning(WorkflowInstance instance)
Override this to determine if the child workflow is running or not. The default implementation returns true if the instance state is finished or created.- Parameters:
instance- The child workflow instance to check.- Returns:
- True if the child is running, false otherwise.
-
waitForChildrenToCompleteUntil
protected org.joda.time.DateTime waitForChildrenToCompleteUntil()
Override this to customize the time to wait for children to finish. Default is 15 minutes. This is a safety mechanism only, as when the children normally go to finished state, they will automatically wake up the parent workflow.- Returns:
- The time when parent should wake up to check if the children are finished.
-
-