@Override public void onTaskFinalization(Task<?> t) { if (!Tasks.isAncestorCancelled(t) && !t.isSubmitted()) { log.warn(t+" was never submitted; did the code create it and forget to run it? ('cancel' the task to suppress this message)"); log.debug("Detail of unsubmitted task "+t+":\n"+t.getStatusDetail(true)); return; } if (!t.isDone()) { // shouldn't happen // TODO But does happen if management context was terminated (e.g. running test suite). // Should check if Execution Manager is running, and only log if it was not terminated? log.warn("Task "+t+" is being finalized before completion"); return; } } };
protected boolean deleteTaskNonRecursive(Task<?> task) { Set<?> tags = checkNotNull(task, "task").getTags(); for (Object tag : tags) { synchronized (tasksByTag) { Set<Task<?>> tasks = tasksWithTagLiveOrNull(tag); if (tasks != null) { tasks.remove(task); if (tasks.isEmpty()) { tasksByTag.remove(tag); } } } } Task<?> removed = tasksById.remove(task.getId()); incompleteTaskIds.remove(task.getId()); if (removed!=null && removed.isSubmitted() && !removed.isDone()) { log.warn("Deleting submitted task before completion: "+removed+"; this task will continue to run in the background outwith "+this+", but perhaps it should have been cancelled?"); } return removed != null; }
private void assertImmediateFakeTaskFromMethod(CallInfo callInfo, String method) { // previously task was null, but now there is a "fake task" assertNotNull(callInfo.task); Assert.assertFalse(callInfo.task.isSubmitted()); assertContainsCallingMethod(callInfo.stackTrace, method); }
protected void submitIfNecessary(TaskAdaptable<?> task) { if (!task.asTask().isSubmitted()) { if (BasicExecutionContext.getCurrentExecutionContext() == null) { throw new IllegalStateException("Compound task ("+task+") launched from "+this+" missing required execution context"); } else { BasicExecutionContext.getCurrentExecutionContext().submit(task); } } }
private void assertRealTaskNotFromMethod(CallInfo callInfo, String method) { assertNotNull(callInfo.task); Assert.assertTrue(callInfo.task.isSubmitted()); assertNotContainsCallingMethod(callInfo.stackTrace, method); }
@Override public Integer call() { Preconditions.checkState(x.isSubmitted()); return x.getUnchecked()+y; } }).build();
if (task.isSubmitted()) { if (log.isTraceEnabled()) { log.trace("DST "+this+" skipping submission of child "+task+" because it is already submitted");
@Override public T call() throws Exception { if (!task.asTask().isSubmitted()) { BasicExecutionContext.getCurrentExecutionContext().submit(task); } return transformer.apply(task.asTask().get()); }}); }
@Override public int compare(Task<?> o1, Task<?> o2) { if (!Objects.equal(o1.isSubmitted(), o2.isSubmitted())) { return o1.isSubmitted() ? -1 : 1;
if (!task.isSubmitted()) { if (exec==null) { return Maybe.absent("Value for unsubmitted task '"+getDescription()+"' requested but no execution context available");
if (!stoppingMachine.isSubmitted()) {