Search in sources :

Example 1 with Terminator

use of hudson.init.Terminator in project workflow-cps-plugin by jenkinsci.

the class CpsFlowExecution method suspendAll.

@Restricted(DoNotUse.class)
@Terminator
public static void suspendAll() {
    CpsFlowExecution exec = null;
    try (Timeout t = Timeout.limit(3, TimeUnit.MINUTES)) {
        // TODO some complicated sequence of calls to Futures could allow all of them to run in parallel
        LOGGER.fine("starting to suspend all executions");
        for (FlowExecution execution : FlowExecutionList.get()) {
            if (execution instanceof CpsFlowExecution) {
                LOGGER.log(Level.FINE, "waiting to suspend {0}", execution);
                exec = (CpsFlowExecution) execution;
                // Like waitForSuspension but with a timeout:
                if (exec.programPromise != null) {
                    exec.programPromise.get(1, TimeUnit.MINUTES).scheduleRun().get(1, TimeUnit.MINUTES);
                }
            }
        }
        LOGGER.fine("finished suspending all executions");
    } catch (Exception x) {
        LOGGER.log(Level.WARNING, "problem suspending " + exec, x);
    }
}
Also used : Timeout(org.jenkinsci.plugins.workflow.support.concurrent.Timeout) FlowExecution(org.jenkinsci.plugins.workflow.flow.FlowExecution) UsernameNotFoundException(org.acegisecurity.userdetails.UsernameNotFoundException) AbortException(hudson.AbortException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) FlowInterruptedException(org.jenkinsci.plugins.workflow.steps.FlowInterruptedException) Restricted(org.kohsuke.accmod.Restricted) Terminator(hudson.init.Terminator)

Aggregations

AbortException (hudson.AbortException)1 Terminator (hudson.init.Terminator)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 UsernameNotFoundException (org.acegisecurity.userdetails.UsernameNotFoundException)1 FlowExecution (org.jenkinsci.plugins.workflow.flow.FlowExecution)1 FlowInterruptedException (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException)1 Timeout (org.jenkinsci.plugins.workflow.support.concurrent.Timeout)1 Restricted (org.kohsuke.accmod.Restricted)1