public class Task extends Object implements AutoCloseable
Task static utility methods to retrieve existing tasks already defined in DataFlow.
For for instance you can define a new task like this:
Task task = Task.builder(dataflowOperations)
.name("myComposedTask")
.definition("a: timestamp && b:timestamp")
.description("My Composed Task")
.build();
Next you can launch the task and inspect the executions result. Mind that the task is run asynchronously.
import org.awaitility.Awaitility;
long launchId = task.launch();
// Leverage Awaitility to wait until task completion.
Awaitility.await().until(() -> task.executionStatus(launchId) == TaskExecutionStatus.COMPLETE);
// Check the executions
task.executions().forEach( execution -> System.out.println(execution.getExitCode()));
Use
close() to destroy the task manually. Since tasks are auto-closable you can use the
Java try block instead:
try (Task task = Task.builder(dataFlowOperations)
.name("myTask")
.definition("timestamp")
.description("Test timestamp task")
.build()) {
long launchId1 = task.launch();
// Do something
} // Task is destroyed.
Use the TaskBuilder.allTasks() and TaskBuilder.findByName(String)
static helper methods to list or retrieve existing tasks defined in DataFlow.
| Modifier and Type | Method and Description |
|---|---|
static TaskBuilder |
builder(DataFlowOperations dataFlowOperations)
Fluent API method to create a
TaskBuilder. |
void |
cleanupAllTaskExecutions()
Remove all task executions.
|
void |
cleanupTaskExecution(long taskExecutionId,
String schemaTarget)
Remove specified task execution for the specified task execution id.
|
void |
close() |
Optional<TaskExecutionResource> |
composedTaskChildExecution(String childTaskName)
Retrieve task executions for child task name associated with this task's instance.
|
Optional<Task> |
composedTaskChildTaskByLabel(String childTaskLabel) |
List<Task> |
composedTaskChildTasks() |
void |
destroy()
Destroy the task.
|
Optional<TaskExecutionResource> |
execution(long executionId,
String schemaTarget)
Retrieve task execution by Id.
|
Optional<TaskExecutionResource> |
executionByParentExecutionId(long parentExecutionId,
String schemaTarget)
Find
TaskExecutionResource by a parent execution id. |
Collection<TaskExecutionResource> |
executions()
List task executions for this task.
|
TaskExecutionStatus |
executionStatus(long executionId,
String schemaTarget)
Task execution status
|
String |
getTaskName() |
boolean |
isComposed() |
Collection<JobExecutionResource> |
jobExecutionResources() |
Collection<JobInstanceResource> |
jobInstanceResources() |
Collection<StepExecutionResource> |
jobStepExecutions(long jobExecutionId,
String schemaTarget) |
LaunchResponseResource |
launch()
Launch a task without properties or arguments.
|
LaunchResponseResource |
launch(List<String> arguments)
Launch a task with command line arguments.
|
LaunchResponseResource |
launch(Map<String,String> properties,
List<String> arguments)
Launch a task with deployment properties and command line arguments.
|
void |
stop()
Stop all Tasks' running
TaskExecutions. |
void |
stop(String schemaTarget,
long... taskExecutionIds)
Stop a list of
TaskExecutions. |
Collection<JobExecutionThinResource> |
thinkJobExecutionResources() |
public static TaskBuilder builder(DataFlowOperations dataFlowOperations)
TaskBuilder.dataFlowOperations - DataFlowOperations Data Flow Rest client instance.public LaunchResponseResource launch()
public LaunchResponseResource launch(List<String> arguments)
arguments - the command line arguments.public LaunchResponseResource launch(Map<String,String> properties, List<String> arguments)
properties - the deployment properties.arguments - the command line arguments.public void stop()
TaskExecutions.
Note: this functionality is platform dependent! It works for local platform but does nothing on K8s!
public void stop(String schemaTarget, long... taskExecutionIds)
TaskExecutions.schemaTarget - the schema target of the task executions.taskExecutionIds - List of TaskExecution ids to stop.
Note: this functionality is platform dependent! It works for local platform but does nothing on K8s!
public void destroy()
public Collection<TaskExecutionResource> executions()
public Optional<TaskExecutionResource> execution(long executionId, String schemaTarget)
executionId - Task execution IdschemaTarget - the schema target of the task execution.public Optional<TaskExecutionResource> executionByParentExecutionId(long parentExecutionId, String schemaTarget)
TaskExecutionResource by a parent execution id.parentExecutionId - parent task execution id.schemaTarget - the schema target of the parent execution.public TaskExecutionStatus executionStatus(long executionId, String schemaTarget)
executionId - execution Id.schemaTarget - the schema target of the execution.public boolean isComposed()
public List<Task> composedTaskChildTasks()
public Optional<Task> composedTaskChildTaskByLabel(String childTaskLabel)
childTaskLabel - Name of the child composed task (excluding the parent prefix).public Collection<JobExecutionResource> jobExecutionResources()
JobExecutionResource belonging to the task.public Collection<JobExecutionThinResource> thinkJobExecutionResources()
public Collection<StepExecutionResource> jobStepExecutions(long jobExecutionId, String schemaTarget)
jobExecutionId - the job execution id.schemaTarget - the schema target of the job execution.StepExecutionResource belonging to the job.public Collection<JobInstanceResource> jobInstanceResources()
JobInstanceResource belonging to this task.public String getTaskName()
public void close()
close in interface AutoCloseablepublic void cleanupTaskExecution(long taskExecutionId,
String schemaTarget)
taskExecutionId - the id of the task execution to be removed.schemaTarget - the schema targetpublic void cleanupAllTaskExecutions()
public Optional<TaskExecutionResource> composedTaskChildExecution(String childTaskName)
childTaskName - to be used to search for the associated task executions.Copyright © 2023 Pivotal Software, Inc.. All rights reserved.