/** * Finds the executor currently running a given process. * @param executable a possibly running executable * @return the executor (possibly a {@link OneOffExecutor}) whose {@link Executor#getCurrentExecutable} matches that, * or null if it could not be found (for example because the execution has already completed) * @since 1.607 */ @CheckForNull public static Executor of(Executable executable) { Jenkins jenkins = Jenkins.getInstanceOrNull(); // TODO confirm safe to assume non-null and use getInstance() if (jenkins == null) { return null; } for (Computer computer : jenkins.getComputers()) { for (Executor executor : computer.getAllExecutors()) { if (executor.getCurrentExecutable() == executable) { return executor; } } } return null; }
@Override public boolean isReadyToRestart() throws IOException, InterruptedException { for (Computer c : Jenkins.getInstance().getComputers()) { if (c.isOnline()) { for (Executor e : c.getAllExecutors()) { if (blocksRestart(e)) { return false; } } } } return true; } private static boolean blocksRestart(Executor e) {
for (Executor e : c.getAllExecutors()) { if (e.isInterrupted()) {
for (Executor e : c.getAllExecutors()) { final WorkUnit workUnit = e.getCurrentWorkUnit(); final Executable executable = workUnit != null ? workUnit.getExecutable() : null;
/** * Finds the executor currently running a given process. * @param executable a possibly running executable * @return the executor (possibly a {@link OneOffExecutor}) whose {@link Executor#getCurrentExecutable} matches that, * or null if it could not be found (for example because the execution has already completed) * @since 1.607 */ @CheckForNull public static Executor of(Executable executable) { Jenkins jenkins = Jenkins.getInstanceOrNull(); // TODO confirm safe to assume non-null and use getInstance() if (jenkins == null) { return null; } for (Computer computer : jenkins.getComputers()) { for (Executor executor : computer.getAllExecutors()) { if (executor.getCurrentExecutable() == executable) { return executor; } } } return null; }
@Override public boolean isReadyToRestart() throws IOException, InterruptedException { for (Computer c : Jenkins.getInstance().getComputers()) { if (c.isOnline()) { for (Executor e : c.getAllExecutors()) { if (blocksRestart(e)) { return false; } } } } return true; } private static boolean blocksRestart(Executor e) {
for (Executor e : c.getAllExecutors()) { final WorkUnit workUnit = e.getCurrentWorkUnit(); final Executable executable = workUnit != null ? workUnit.getExecutable() : null;
for (Executor e : c.getAllExecutors()) { WorkUnit workUnit = e.getCurrentWorkUnit(); if (workUnit != null) {