public abstract class AbstractWorkflow extends AbstractPluginConfigurable<WorkflowConfigurer> implements Workflow, ProgramLifecycle<WorkflowContext>
Workflow methods for easy extension.
Example of configuring a workflow:
@Override
public void configure() {
setName("PurchaseHistoryWorkflow");
setDescription("PurchaseHistoryWorkflow description");
addMapReduce("PurchaseHistoryBuilder");
}
See the Purchase example application.| Constructor and Description |
|---|
AbstractWorkflow() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAction(CustomAction action)
Adds a custom action to the
Workflow. |
protected void |
addMapReduce(String mapReduce)
Adds a MapReduce program to the
Workflow. |
protected void |
addSpark(String spark)
Adds a Spark program to the
Workflow. |
protected WorkflowConditionConfigurer<? extends WorkflowConfigurer> |
condition(Condition condition)
Adds a condition to the
Workflow. |
protected WorkflowConditionConfigurer<? extends WorkflowConfigurer> |
condition(Predicate<WorkflowContext> predicate)
Adds a condition to the
Workflow. |
protected abstract void |
configure()
Override this method to configure this
Workflow. |
void |
configure(WorkflowConfigurer configurer)
Configures a
Workflow using the given WorkflowConfigurer. |
protected void |
createLocalDataset(String datasetName,
Class<? extends Dataset> datasetClass)
Adds a local dataset instance with
DatasetProperties.EMPTY to the Workflow. |
protected void |
createLocalDataset(String datasetName,
Class<? extends Dataset> datasetClass,
DatasetProperties props)
Adds a local dataset instance to the
Workflow. |
protected void |
createLocalDataset(String datasetName,
String typeName)
Adds a local dataset instance with
DatasetProperties.EMPTY to the Workflow. |
protected void |
createLocalDataset(String datasetName,
String typeName,
DatasetProperties properties)
Adds a local dataset instance to the
Workflow. |
void |
destroy()
Destroy is the last thing that gets called before the program is shutdown.
|
protected WorkflowForkConfigurer<? extends WorkflowConfigurer> |
fork()
Adds a fork to the
Workflow. |
protected WorkflowConfigurer |
getConfigurer()
Returns the
WorkflowConfigurer, only available at configuration time. |
protected WorkflowContext |
getContext()
Return an instance of the
WorkflowContext. |
void |
initialize(WorkflowContext context)
Initializes a Program.
|
protected void |
setDescription(String description)
Sets the description of the
Workflow. |
protected void |
setName(String name)
Sets the name of the
Workflow. |
protected void |
setProperties(Map<String,String> properties)
Sets the properties that will be available through the
WorkflowSpecification.getProperties()
at runtime. |
usePlugin, usePlugin, usePluginClass, usePluginClassaddDatasetModule, addDatasetType, createDataset, createDataset, createDataset, createDatasetpublic final void configure(WorkflowConfigurer configurer)
WorkflowWorkflow using the given WorkflowConfigurer.protected abstract void configure()
Workflow.protected final WorkflowConfigurer getConfigurer()
WorkflowConfigurer, only available at configuration time.getConfigurer in class AbstractPluginConfigurable<WorkflowConfigurer>protected final void setDescription(String description)
Workflow.protected final void setProperties(Map<String,String> properties)
WorkflowSpecification.getProperties()
at runtime.properties - the properties to setprotected final void addAction(CustomAction action)
Workflow.action - the action to be addedprotected final void addMapReduce(String mapReduce)
Workflow.mapReduce - the name of MapReduce program to be addedprotected final void addSpark(String spark)
Workflow.spark - the name of the Spark program to be addedprotected final WorkflowForkConfigurer<? extends WorkflowConfigurer> fork()
Workflow.WorkflowForkConfigurer to configure actions in the forkprotected final WorkflowConditionConfigurer<? extends WorkflowConfigurer> condition(Predicate<WorkflowContext> predicate)
Workflow.predicate - the Predicate to be evaluated to determine which branch to takeWorkflowConditionConfigurer to configure the branches in the conditionprotected final WorkflowConditionConfigurer<? extends WorkflowConfigurer> condition(Condition condition)
Workflow.condition - the Condition to be evaluated to determine which branch to takeWorkflowConditionConfigurer to configure the branches in the conditionprotected final void createLocalDataset(String datasetName, String typeName, DatasetProperties properties)
Workflow.
Local datasets are created at the start of every Workflow run and deleted once the run
is complete. User can decide to keep the local datasets even after the run is complete by
specifying the runtime arguments - dataset.dataset_name.keep.local=true.
datasetName - name of the dataset instancetypeName - name of the dataset typeproperties - dataset instance propertiesprotected final void createLocalDataset(String datasetName, String typeName)
DatasetProperties.EMPTY to the Workflow.
Local datasets are created at the start of every Workflow run and deleted once the run
is complete. User can decide to keep the local datasets even after the run is complete by
specifying the runtime arguments - dataset.dataset_name.keep.local=true.
datasetName - name of the dataset instancetypeName - name of the dataset typeprotected final void createLocalDataset(String datasetName, Class<? extends Dataset> datasetClass, DatasetProperties props)
Workflow. Also deploys the dataset type
represented by the datasetClass parameter in the current namespace.
Local datasets are created at the start of every Workflow run and deleted once the run
is complete. User can decide to keep the local datasets even after the run is complete by
specifying the runtime arguments - dataset.dataset_name.keep.local=true.
datasetName - name of the dataset instancedatasetClass - dataset class to create the Dataset type fromprops - dataset instance propertiesprotected final void createLocalDataset(String datasetName, Class<? extends Dataset> datasetClass)
DatasetProperties.EMPTY to the Workflow.
Also deploys the dataset type represented by the datasetClass parameter in the current
namespace.
Local datasets are created at the start of every Workflow run and deleted once the run
is complete. User can decide to keep the local datasets even after the run is complete by
specifying the runtime arguments - dataset.dataset_name.keep.local=true.
datasetName - name of the dataset instancedatasetClass - dataset class to create the Dataset type frompublic void initialize(WorkflowContext context) throws Exception
ProgramLifecycle
This method will be called only once per ProgramLifecycle instance.
initialize in interface ProgramLifecycle<WorkflowContext>context - An instance of RuntimeContextException - If there is any error during initialization.public void destroy()
ProgramLifecycledestroy in interface ProgramLifecycle<WorkflowContext>protected final WorkflowContext getContext()
WorkflowContext.Copyright © 2024 Cask Data, Inc. Licensed under the Apache License, Version 2.0.