Revision 40099
Added by Michele Artini over 8 years ago
WorkflowProcess.java | ||
---|---|---|
12 | 12 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
13 | 13 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
14 | 14 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
15 |
import eu.dnetlib.msro.workflows.graph.*; |
|
15 |
import eu.dnetlib.msro.workflows.graph.Graph; |
|
16 |
import eu.dnetlib.msro.workflows.graph.GraphNode; |
|
16 | 17 |
import eu.dnetlib.msro.workflows.util.ProcessCallback; |
17 | 18 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
18 | 19 |
import org.antlr.stringtemplate.StringTemplate; |
... | ... | |
155 | 156 |
|
156 | 157 |
} |
157 | 158 |
|
158 |
public void markAsCompleted(final Token token) {
|
|
159 |
private void markAsCompleted(final Token token) {
|
|
159 | 160 |
completeProcess(token, true); |
160 | 161 |
} |
161 | 162 |
|
162 |
public void markAsFailed(final Token token) {
|
|
163 |
private void markAsFailed(final Token token) {
|
|
163 | 164 |
completeProcess(token, false); |
164 | 165 |
} |
165 | 166 |
|
166 |
private final void completeProcess(final Token token, boolean success) {
|
|
167 |
private void completeProcess(final Token token, boolean success) { |
|
167 | 168 |
lastActivityDate = DateUtils.now(); |
168 | 169 |
|
169 | 170 |
final String profileId = token.getEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_ID, String.class).trim(); |
... | ... | |
241 | 242 |
return res; |
242 | 243 |
} |
243 | 244 |
|
244 |
@Override |
|
245 |
public int compareTo(final WorkflowProcess wp) { |
|
246 |
return NumberUtils.compare(getPriority(), wp.getPriority()); |
|
247 |
} |
|
248 |
|
|
249 | 245 |
public boolean isTerminated() { |
250 | 246 |
switch (status) { |
251 | 247 |
case COMPLETED: |
... | ... | |
257 | 253 |
} |
258 | 254 |
} |
259 | 255 |
|
260 |
public Token createNewToken(final GraphNode graphNode, final Env... envs) {
|
|
256 |
private Token createNewToken(final GraphNode graphNode, final Env... envs) {
|
|
261 | 257 |
final Token token = new Token(tokenCounter++, this, graphNode); |
262 | 258 |
tokens.add(token); |
263 | 259 |
for (Env e : envs) { |
... | ... | |
266 | 262 |
return token; |
267 | 263 |
} |
268 | 264 |
|
269 |
public Token createNewToken(final GraphNode graphNode, final Token... oldTokens) {
|
|
265 |
private Token createNewToken(final GraphNode graphNode, final Token... oldTokens) {
|
|
270 | 266 |
final Token token = new Token(tokenCounter++, this, graphNode); |
271 | 267 |
tokens.add(token); |
272 | 268 |
for (Token t : oldTokens) { |
... | ... | |
279 | 275 |
return lastActivityDate; |
280 | 276 |
} |
281 | 277 |
|
278 |
public void setLastActivityDate(final long lastActivityDate) { |
|
279 |
this.lastActivityDate = lastActivityDate; |
|
280 |
} |
|
281 |
|
|
282 |
@Override |
|
283 |
public String toString() { |
|
284 |
return String.format("[process id='%s' name='%s']", id, name); |
|
285 |
} |
|
286 |
|
|
287 |
@Override |
|
288 |
public int compareTo(final WorkflowProcess wp) { |
|
289 |
return NumberUtils.compare(getPriority(), wp.getPriority()); |
|
290 |
} |
|
291 |
|
|
282 | 292 |
public enum Status { |
283 | 293 |
CREATED, EXECUTING, COMPLETED, FAILED, KILLED; |
284 | 294 |
} |
Also available in: Unified diff
partial reimplementation of the wf engine