forked from YahooArchive/oozie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WorkflowInstance.java
196 lines (168 loc) · 5.94 KB
/
WorkflowInstance.java
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**
* Copyright (c) 2010 Yahoo! Inc. All rights reserved.
* 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. See accompanying LICENSE file.
*/
package org.apache.oozie.workflow;
import org.apache.hadoop.conf.Configuration;
import org.apache.oozie.workflow.lite.NodeDef;
import java.util.Map;
/**
* A workflow instance is an executable instance of a {@link WorkflowApp}.
*/
public interface WorkflowInstance {
/**
* Separator to qualify variables belonging to a node. <p/> Variables names should be compossed as <code>nodeName +
* {@link #NODE_VAR_SEPARATOR} + varName</code>.
*/
public final static String NODE_VAR_SEPARATOR = "#";
/**
* Defines the possible stati of a {@link WorkflowInstance}.
*/
public static enum Status {
PREP(false),
RUNNING(false),
SUSPENDED(false),
SUCCEEDED(true),
FAILED(true),
KILLED(true);
private boolean isEndState;
private Status(boolean isEndState) {
this.isEndState = isEndState;
}
/**
* Return if the status if an end state (it cannot change anymore).
*
* @return if the status if an end state (it cannot change anymore).
*/
public boolean isEndState() {
return isEndState;
}
}
/**
* Return the configuration of the instance.
*
* @return the configuration of the instance.
*/
public Configuration getConf();
/**
* Return the ID of the instance.
*
* @return the ID of the instance.
*/
public String getId();
/**
* Return the workflow application that defines the instance.
*
* @return the workflow application that defines the instance.
*/
public WorkflowApp getApp();
/**
* Start the instance.
*
* @throws WorkflowException thrown if the instance could not be started.
*/
public boolean start() throws WorkflowException;
/**
* Signal the instance that a node has completed.
*
* @param path execution path of the node that has completed.
* @param signaValue signal value for the node.
* @return <code>true</code> if the instance has completed its execution, <code>false</code> otherwise.
*/
public boolean signal(String path, String signaValue) throws WorkflowException;
/**
* Fail the instance. <p/> All executing nodes will be be signaled for fail.
*
* @param nodeName the name of the node to be failed.
* @throws WorkflowException thrown if the instance could not be failed.
*/
public void fail(String nodeName) throws WorkflowException;
/**
* Kill the instance. <p/> All executing nodes will be be signaled for kill.
*
* @throws WorkflowException thrown if the instance could not be killed.
*/
public void kill() throws WorkflowException;
/**
* Suspend the instance.
*
* @throws WorkflowException thrown if the instance could not be suspended.
*/
public void suspend() throws WorkflowException;
/**
* Resume the instance.
*
* @throws WorkflowException thrown if the instance could not be resume.
*/
public void resume() throws WorkflowException;
/**
* Return the current status of the instance.
*
* @return the current status of the instance.
*/
public Status getStatus();
/**
* Set a variable in the context of the instance. <p/> Variables are persisted with the instance.
*
* @param name variable name.
* @param value variable value, setting a <code>null</code> value removes the variable.
*/
public void setVar(String name, String value);
/**
* Return a variable from the context of the instance.
*
* @param name name of the variable.
* @return variable value, <code>null</code> if the variable is not in the context.
*/
public String getVar(String name);
/**
* Return a map with all the variables in the context of the instance.
*
* @return a map with all the variables in the context of the instance.
*/
public Map<String, String> getAllVars();
/**
* Add a set of variables in the context of the instance. <p/> Variables are persisted with the instance.
*
* @param varMap map with the variables to add.
*/
public void setAllVars(Map<String, String> varMap);
/**
* Set a transient variable in the context of the instance. <p/> Transient variables are not persisted with the
* instance.
*
* @param name transient variable name.
* @param value transient variable value, setting a <code>null</code> value removes the variable.
*/
public void setTransientVar(String name, Object value);
/**
* Return a transient variable from the context of the instance.
*
* @param name name of the transient variable.
* @return transient variable value, <code>null</code> if the variable is not in the context.
*/
public Object getTransientVar(String name);
/**
* Return the transition a node did. <p/> This is meaninful only for action and decision nodes.
*
* @param node the node name.
* @return the transition the node did, <code>null</code> if the node didn't execute yet.
*/
public String getTransition(String node);
/**
* Get NodeDef from workflow instance
* @param executionPath execution path
* @return node def
*/
public NodeDef getNodeDef(String executionPath);
}