public static void dumpInfo(Task<?> t, Writer out, String currentIndentation, String tab) throws IOException { out.append(currentIndentation+t+": "+t.getStatusDetail(false)+"\n"); if (t instanceof HasTaskChildren) { for (Task<?> child: ((HasTaskChildren)t).getChildren()) { dumpInfo(child, out, currentIndentation+tab, tab); } } out.flush(); } }
@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; } } };
private boolean waitAppShutdown(CountdownTimer shutdownTimeoutTimer, Task<?> t) throws TimeoutException { Duration waitInterval = null; //wait indefinitely if no shutdownTimeoutTimer (shutdownTimeout == 0) if (shutdownTimeoutTimer != null) { waitInterval = Duration.of(SHUTDOWN_TIMEOUT_CHECK_INTERVAL, TimeUnit.MILLISECONDS); } // waitInterval == null - blocks indefinitely while(!t.blockUntilEnded(waitInterval)) { if (shutdownTimeoutTimer.isExpired()) { log.warn("Timeout while waiting for applications to stop at "+t+".\n"+t.getStatusDetail(true)); throw new TimeoutException(); } } if (t.isError()) { log.warn("Error stopping application "+t+" during shutdown (ignoring)\n"+t.getStatusDetail(true)); return false; } else { return true; } } }.start();
private void assertAllOurConfigTasksNotCancelled() { for (Task<?> t: tasksMadeByFactory) { Assert.assertFalse( t.isCancelled(), "Task should not have been cancelled: "+t+" - "+t.getStatusDetail(false) ); } }
private void assertAllOurConfigTasksCancelled() { // TODO added Feb 2017 - but might need an "eventually" here, if cancel is happening in a BG thread // (but I think it is always foreground) for (Task<?> t: tasksMadeByFactory) { Assert.assertTrue( t.isCancelled(), "Task should have been cancelled: "+t+" - "+t.getStatusDetail(false) ); } }
private void assertAllTasksDone() { for (Task<?> t: tasksMadeByFactory) { Assert.assertTrue( t.isDone(), "Task should have been done: "+t+" - "+t.getStatusDetail(false) ); } } }
@Override public void run() { try { // Expect "wait a bit" to tell us it's blocking if (!entity.getNowWaitingLatch().await(TIMEOUT, TimeUnit.MILLISECONDS)) { result.set("took too long for waitabit to be waiting"); return; } // Expect "wait a bit" to have retrieved and set its task try { Task<?> t = entity.getWaitingTask().get(); String status = t.getStatusDetail(true); log.info("waitabit task says:\n"+status); if (!status.contains("waitabit extra status details")) { result.set("Status not in expected format: doesn't contain extra status details phrase 'My extra status details'\n"+status); return; } if (!status.startsWith("waitabit.blocking")) { result.set("Status not in expected format: doesn't start with blocking details 'waitabit.blocking'\n"+status); return; } } finally { entity.getContinueFromWaitingLatch().countDown(); } } catch (Throwable t) { log.warn("Failure: "+t, t); result.set("Failure: "+t); } }}); bg.start();
String status = subtask.getStatusDetail(true); log.info("subtask task says:\n"+status); if (!status.contains("spawned child blocking details")) {
rv += "Children:\n"; for (Task<?> child: childrenTasks) { rv += " "+child+": "+child.getStatusDetail(false)+"\n";
synchronized (sonsConfig) { assertEquals(null, sonsConfig[0]); for (Task tt : ((EntityInternal)dad).getExecutionContext().getTasks()) { log.info("task at dad: {}, {}", tt, tt.getStatusDetail(false)); } for (Task tt : ((EntityInternal)son).getExecutionContext().getTasks()) { log.info("task at son: {}, {}", tt, tt.getStatusDetail(false)); } dad.sensors().set(HelloEntity.FAVOURITE_NAME, "Dan"); if (!s1.tryAcquire(2, TimeUnit.SECONDS)) fail("race mismatch, missing permits");
task.isDone() ? null : task instanceof TaskInternal ? asLink(((TaskInternal<?>)task).getBlockingTask(), ub) : null, task.isDone() ? null : task instanceof TaskInternal ? ((TaskInternal<?>)task).getBlockingDetails() : null, task.getStatusDetail(true), streams, links);