result |= delegate().cancel(mode.isAllowedToInterruptTask()); if (mode.isAllowedToInterruptDependentSubmittedTasks()) { int subtasksFound=0; int subtasksReallyCancelled=0; if (mode.isAllowedToInterruptAllSubmittedTasks() || BrooklynTaskTags.isTransient(t)) { if (log.isTraceEnabled()) { log.trace("Cancelling "+t+" on recursive cancellation of "+task);
protected boolean cancel(TaskCancellationMode mode, Boolean interruptPrimaryThreadOverride) { if (isDone()) return false; if (log.isTraceEnabled()) log.trace("cancelling DST {}", this); // first do the super's cancel, setting cancelled, and calling doCancel to cancel children boolean result = super.cancel(mode); // then come back and ensure our primary thread is cancelled if needed if (interruptPrimaryThreadOverride==null) interruptPrimaryThreadOverride = mode.isAllowedToInterruptTask(); if (log.isTraceEnabled()) { log.trace("DST cancelling "+this+" mode "+mode+", interruptPrimary "+interruptPrimaryThreadOverride); } synchronized (jobTransitionLock) { if (primaryThread!=null) { if (interruptPrimaryThreadOverride) { if (log.isTraceEnabled()) log.trace("cancelling {} - interrupting", this); primaryThread.interrupt(); } result = true; } } return result; }
@Override protected boolean doCancel(org.apache.brooklyn.util.core.task.TaskInternal.TaskCancellationMode mode) { boolean result = false; if (mode.isAllowedToInterruptDependentSubmittedTasks()) { for (Task<?> t: getChildren()) { if (!t.isDone()) { result = ((TaskInternal<?>)t).cancel(mode) || result; } } } result = super.doCancel(mode) || result; return result; // returns true if anything is successfully cancelled }
@Override protected boolean doCancel(TaskCancellationMode mode) { boolean result = false; if (mode.isAllowedToInterruptDependentSubmittedTasks()) { for (Task<?> t: secondaryJobsAll) { // secondary jobs are dependent result = ((TaskInternal<?>)t).cancel(mode) || result; } } return super.doCancel(mode) || result; // returns true if anything is successfully cancelled }
@SuppressWarnings("deprecation") protected boolean doCancel(TaskCancellationMode mode) { if (internalFuture!=null) { if (internalFuture instanceof ListenableForwardingFuture) { return ((ListenableForwardingFuture<?>)internalFuture).cancel(mode); } else { return internalFuture.cancel(mode.isAllowedToInterruptTask()); } } return true; }