public class WorkflowManagerBuilder extends Object
WorkflowManager
instancesModifier and Type | Method and Description |
---|---|
WorkflowManagerBuilder |
addingTaskExecutor(TaskExecutor taskExecutor,
int qty,
TaskType taskType)
Adds a pool of task executors for a given task type to this instance of
the workflow.
|
WorkflowManager |
build()
Return a new WorkflowManager using the current builder values
|
static WorkflowManagerBuilder |
builder()
Return a new builder
|
WorkflowManagerBuilder |
withAutoCleaner(AutoCleaner autoCleaner,
Duration runPeriod)
optional
Sets an auto-cleaner that will run every given period. |
WorkflowManagerBuilder |
withCurator(org.apache.curator.framework.CuratorFramework curator,
String namespace,
String version)
required
Set the Curator instance to use. |
WorkflowManagerBuilder |
withInstanceName(String instanceName)
optional
|
WorkflowManagerBuilder |
withQueueFactory(QueueFactory queueFactory)
optional
Pluggable queue factory. |
WorkflowManagerBuilder |
withSerializer(Serializer serializer)
optional
By default, a JSON serializer is used to store data in ZooKeeper. |
WorkflowManagerBuilder |
withTaskRunnerService(Executor taskRunnerService)
optional
By default, tasks are run in an internal executor service. |
public static WorkflowManagerBuilder builder()
public WorkflowManagerBuilder withCurator(org.apache.curator.framework.CuratorFramework curator, String namespace, String version)
curator
- Curator instancenamespace
- workflow namespaceversion
- workflow versionpublic WorkflowManagerBuilder addingTaskExecutor(TaskExecutor taskExecutor, int qty, TaskType taskType)
Adds a pool of task executors for a given task type to this instance of the workflow. The specified number of executors are allocated. Call this method multiple times to allocate executors for the various types of tasks that will be used in this workflow. You can choose to have all workflow instances execute all task types or target certain task types to certain instances.
qty
is the maximum concurrency for the given type of task for this instance.
The logical concurrency for a given task type is the total qty of all instances in the
workflow. e.g. if there are 3 instances in the workflow and instance A has 2 executors
for task type "a", instance B has 3 executors for task type "a" and instance C has no
executors for task type "a", the maximum concurrency for task type "a" is 5.
IMPORTANT: every workflow cluster must have at least one instance that has task executor(s) for each task type that will be submitted to the workflow. i.e workflows will stall if there is no executor for a given task type.
taskExecutor
- the executorqty
- the number of instances for this pooltaskType
- task typepublic WorkflowManagerBuilder withInstanceName(String instanceName)
Used in reporting. This will be the value recorded as tasks are executed. Via reporting, you can determine which instance has executed a given task.
Default is: InetAddress.getLocalHost().getHostName()
instanceName
- the name of this instancepublic WorkflowManager build()
public WorkflowManagerBuilder withQueueFactory(QueueFactory queueFactory)
queueFactory
- new queue factorypublic WorkflowManagerBuilder withAutoCleaner(AutoCleaner autoCleaner, Duration runPeriod)
autoCleaner
- the auto cleaner to userunPeriod
- how often to runpublic WorkflowManagerBuilder withSerializer(Serializer serializer)
serializer
- serializer to usepublic WorkflowManagerBuilder withTaskRunnerService(Executor taskRunnerService)
taskRunnerService
- custom executor serviceCopyright © 2014–2018 Nirmata. All rights reserved.