/** returns true if the task either is currently queued or has been submitted */ public boolean isQueuedOrSubmitted() { return wasQueued || Tasks.isQueuedOrSubmitted(task); } /** specifies an execContext to use if the task has to be explicitly submitted;
/** Returns the result of the last task queued in this context, coerced to the given type */ protected <V> V last(Class<V> type) { Task<?> last = waitForLast(); if (last==null) throw new IllegalStateException("No last task available (in "+DynamicTasks.getTaskQueuingContext()+")"); if (!Tasks.isQueuedOrSubmitted(last)) throw new IllegalStateException("Last task "+last+" has not been queued or submitted; will not block on its result"); return TypeCoercions.coerce(last.getUnchecked(), type); } }
Preconditions.checkState(!Tasks.isQueuedOrSubmitted(task), "Task to queue must not yet be submitted: {}", task);
@Override public Boolean call() { return (script.peekTask() != null) && Tasks.isQueuedOrSubmitted(script.peekTask()); } }).run());
@Test(groups = "Integration") public void testStreamsInTask() { final ScriptHelper script = new ScriptHelper(newLocalhostRunner(), "mock"). body.append("echo `echo foo``echo bar`", "grep absent-text badfile_which_does_not_exist_blaahblahasdewq"). gatherOutput(); Assert.assertNull(script.peekTask()); Task<Integer> task = script.newTask(); Assert.assertTrue(BrooklynTaskTags.streams(task).size() >= 3, "Expected at least 3 streams: "+BrooklynTaskTags.streams(task)); Assert.assertFalse(Tasks.isQueuedOrSubmitted(task)); WrappedStream in = BrooklynTaskTags.stream(task, BrooklynTaskTags.STREAM_STDIN); Assert.assertNotNull(in); Assert.assertTrue(in.streamContents.get().contains("echo foo"), "Expected 'echo foo' but had: "+in.streamContents.get()); Assert.assertTrue(in.streamSize.get() > 0); Assert.assertNotNull(script.peekTask()); }
if (!Tasks.isQueuedOrSubmitted(t) && (!(Tasks.current() instanceof HasTaskChildren) || !Iterables.contains( ((HasTaskChildren)Tasks.current()).getChildren(), t ))) {