forked from linkedin/parseq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.java
More file actions
111 lines (99 loc) · 3.48 KB
/
Task.java
File metadata and controls
111 lines (99 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Copyright 2012 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.linkedin.parseq;
import com.linkedin.parseq.internal.TaskLogger;
import com.linkedin.parseq.promise.Promise;
import com.linkedin.parseq.trace.Related;
import com.linkedin.parseq.trace.ShallowTrace;
import com.linkedin.parseq.trace.Trace;
import java.util.Collection;
import java.util.Set;
/**
* A task represents a deferred execution that also contains its resulting
* value. In addition, tasks include some tracing information that can be
* used with various trace printers.
* <p/>
* Tasks should generally be run using either an {@link Engine} or a
* {@link Context}. They should not be run directly.
*
* @author Chris Pettitt (cpettitt@linkedin.com)
*/
public interface Task<T> extends Promise<T>, Cancellable
{
/**
* Returns the name of this task.
*
* @return the name of this task
*/
public String getName();
/**
* Returns the priority for this task.
*
* @return the priority for this task.
*/
int getPriority();
/**
* Overrides the priority for this task. Higher priority tasks will be
* executed before lower priority tasks in the same context. In most cases,
* the default priority is sufficient.
* <p/>
* The default priority is 0. Use {@code priority < 0} to make a task
* lower priority and {@code priority > 0} to make a task higher
* priority.
* <p/>
* If the task has already started execution the priority cannot be
* changed.
*
* @param priority the new priority for the task.
* @return {@code true} if the priority was set; otherwise {@code false}.
* @throws IllegalArgumentException if the priority is out of range
* @see Priority
*/
boolean setPriority(int priority);
/**
* Attempts to run the task with the given context. This method is
* reserved for use by {@link Engine} and {@link Context}.
*
* @param context the context to use while running this step
* @param taskLogger the logger used for task events
* @param parent the parent of this task
* @param predecessors that lead to the execution of this task
*/
void contextRun(Context context, TaskLogger taskLogger,
Task<?> parent, Collection<Task<?>> predecessors);
/**
* Returns the ShallowTrace for this task. The ShallowTrace will be
* a point-in-time snapshot and may change over time until the task is
* completed.
*
* @return the ShallowTrace related to this task
*/
ShallowTrace getShallowTrace();
/**
* Returns the Trace for this task. The Trace will be a point-in-time snapshot
* and may change over time until the task is completed.
*
* @return the Trace related to this task
*/
Trace getTrace();
/**
* Returns the set of relationships of this task. The parent relationships are not included.
*
* @see com.linkedin.parseq.trace.Relationship the available relationships
* @return the set of relationships of this task.
*/
Set<Related<Task<?>>> getRelationships();
}