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
Bulk child workflow executor that does not overflow the system.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe type of default bulk workflow.static final WorkflowStatestatic final WorkflowStatestatic final WorkflowStateBulk workflow states.static final StringState variable name for child data.static final StringState variable to define the maximum concurrency for executing child workflows.static final WorkflowStateFields inherited from class io.nflow.engine.workflow.definition.WorkflowDefinition
allowedTransitions, failureTransitions -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreate bulk workflow definition.protectedBulkWorkflow(String type) Extend bulk workflow definition. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanisRunning(WorkflowInstance instance) Override this to determine if the child workflow is running or not.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.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.DateTimeOverride this to customize the time to wait for children to finish.waitForChildrenToFinish(StateExecution execution, int concurrency) Check if all child workflows have finished.protected org.joda.time.DateTimeOverride 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, setNameMethods inherited from class io.nflow.engine.model.ModelObject
equals, hashCode, toString
-
Field Details
-
BULK_WORKFLOW_TYPE
The type of default bulk workflow.- See Also:
-
VAR_CHILD_DATA
State variable name for child data.- See Also:
-
VAR_CONCURRENCY
State variable to define the maximum concurrency for executing child workflows.- See Also:
-
SPLIT_WORK
Bulk workflow states. -
WAIT_FOR_CHILDREN_TO_FINISH
-
DONE
-
ERROR
-
-
Constructor Details
-
BulkWorkflow
Extend bulk workflow definition.- Parameters:
type- The type of the workflow.
-
BulkWorkflow
public BulkWorkflow()Create bulk workflow definition.
-
-
Method Details
-
splitWork
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
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
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.
-