@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, final Computer computer, long start, long eternity) { long now = System.currentTimeMillis(); List<FutureLoad> fl = new ArrayList<FutureLoad>(); for (Executor e : computer.getExecutors()) { if (e.isIdle()) continue; long eta = e.getEstimatedRemainingTimeMillis(); long end = eta<0 ? eternity : now + eta; // when does this task end? if (end < start) continue; // should be over by the 'start' time. fl.add(new FutureLoad(start, end-start, 1)); } return fl; } }
public Builder with(@CheckForNull Computer computer) { if (computer == null) { return this; } if (computer.isOnline()) { final List<Executor> executors = computer.getExecutors(); final boolean acceptingTasks = computer.isAcceptingTasks(); for (Executor e : executors) { definedExecutors++; onlineExecutors++; if (e.getCurrentWorkUnit() != null) { busyExecutors++; } else { idleExecutors++; if (acceptingTasks) availableExecutors++; } } } else { final int numExecutors = computer.getNumExecutors(); definedExecutors += numExecutors; if (computer.isConnecting()) { connectingExecutors += numExecutors; } } return this; }
for (Computer c : Jenkins.getInstance().getComputers()) { if (c.isOffline()) continue; for (Executor e : c.getExecutors()) { slots.add(new PseudoExecutorSlot(e));
@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, final Computer computer, long start, long eternity) { long now = System.currentTimeMillis(); List<FutureLoad> fl = new ArrayList<FutureLoad>(); for (Executor e : computer.getExecutors()) { if (e.isIdle()) continue; long eta = e.getEstimatedRemainingTimeMillis(); long end = eta<0 ? eternity : now + eta; // when does this task end? if (end < start) continue; // should be over by the 'start' time. fl.add(new FutureLoad(start, end-start, 1)); } return fl; } }
/** * Checks if argument computer is currently building something. * @param computer the computer to check for * @return true if computer is building, otherwise false */ public static boolean isBuilding(Computer computer) { boolean isBuilding = false; List<Executor> executors = new ArrayList<Executor>(computer.getExecutors()); executors.addAll(computer.getOneOffExecutors()); for (Executor executor : executors) { if (executor.isBusy()) { isBuilding = true; break; } } return isBuilding; }
@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, final Computer computer, long start, long eternity) { long now = System.currentTimeMillis(); List<FutureLoad> fl = new ArrayList<FutureLoad>(); for (Executor e : computer.getExecutors()) { if (e.isIdle()) continue; long eta = e.getEstimatedRemainingTimeMillis(); long end = eta<0 ? eternity : now + eta; // when does this task end? if (end < start) continue; // should be over by the 'start' time. fl.add(new FutureLoad(start, end-start, 1)); } return fl; } }
@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, final Computer computer, long start, long eternity) { long now = System.currentTimeMillis(); List<FutureLoad> fl = new ArrayList<FutureLoad>(); for (Executor e : computer.getExecutors()) { if (e.isIdle()) continue; long eta = e.getEstimatedRemainingTimeMillis(); long end = eta<0 ? eternity : now + eta; // when does this task end? if (end < start) continue; // should be over by the 'start' time. fl.add(new FutureLoad(start, end-start, 1)); } return fl; } }
@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, final Computer computer, long start, long eternity) { long now = System.currentTimeMillis(); List<FutureLoad> fl = new ArrayList<FutureLoad>(); for (Executor e : computer.getExecutors()) { if (e.isIdle()) continue; long eta = e.getEstimatedRemainingTimeMillis(); long end = eta<0 ? eternity : now + eta; // when does this task end? if (end < start) continue; // should be over by the 'start' time. fl.add(new FutureLoad(start, end-start, 1)); } return fl; } }
private int pipelinesOnNode(@Nonnull Node node, @Nonnull Run<?,?> run, @Nonnull List<FlowNode> flowNodes) { int runCount = 0; LOGGER.log(Level.FINE, "Checking for pipelines of {0} on node {1}", new Object[] {run.getDisplayName(), node.getDisplayName()}); Computer computer = node.toComputer(); if (computer != null) { //Not all nodes are certain to become computers, like nodes with 0 executors. // Don't count flyweight tasks that might not consume an actual executor, unlike with builds. for (Executor e : computer.getExecutors()) { runCount += pipelinesOnExecutor(run, e, flowNodes); } } return runCount; }
@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, final Computer computer, long start, long eternity) { long now = System.currentTimeMillis(); List<FutureLoad> fl = new ArrayList<FutureLoad>(); for (Executor e : computer.getExecutors()) { if (e.isIdle()) { continue; } long eta = e.getEstimatedRemainingTimeMillis(); long end = eta < 0 ? eternity : now + eta; // when does this task end? if (end < start) { continue; // should be over by the 'start' time. } fl.add(new FutureLoad(start, end - start, 1)); } return fl; } }
static Executor getExecutor(Run run) { for (Computer c : Hudson.getInstance().getComputers()) { for (Executor e : c.getExecutors()) { if (e.getCurrentExecutable() == run) { return e; } } } return null; }
/** * Gets the {@link Executor} building this job, if it's being built. * Otherwise null. */ public Executor getExecutor() { for( Computer c : Hudson.getInstance().getComputers() ) { for (Executor e : c.getExecutors()) { if(e.getCurrentExecutable()==this) return e; } } return null; }
private int getBusyExecutors() { int busyExecutors = 0; Computer[] computers = Jenkins.getInstance().getComputers(); for (Computer compi : computers) { for (Executor executor : compi.getExecutors()) { if (executor.isBusy()) { busyExecutors++; } } } return busyExecutors; }
/** * Gets the {@link Executor} building this job, if it's being built. * Otherwise null. */ public Executor getExecutor() { for( Computer c : Hudson.getInstance().getComputers() ) { for (Executor e : c.getExecutors()) { if(e.getCurrentExecutable()==this) return e; } } return null; }
/** * Gets the {@link Executor} building this job, if it's being built. * Otherwise null. */ public Executor getExecutor() { for( Computer c : Hudson.getInstance().getComputers() ) { for (Executor e : c.getExecutors()) { if(e.getCurrentExecutable()==this) return e; } } return null; }
private int getBusyExecutors() { int busyExecutors = 0; //boolean stillRunningExecutorFound = false; Computer[] computers = Hudson.getInstance().getComputers(); for (Computer compi : computers) { for (Executor executor : compi.getExecutors()) { if (executor.isBusy()) { busyExecutors++; } } } return busyExecutors; }
@Override @Exported public Executor getExecutor() { final Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { return null; } for (final Computer computer : jenkins.getComputers()) { for (final Executor executor : computer.getExecutors()) { if (isCurrent(executor)) { return executor; } } } return null; }
private int buildsOfProjectOnNode(Node node, Task task) { if (!shouldBeThrottled(task, getThrottleJobProperty(task))) { return 0; } int runCount = 0; LOGGER.log(Level.FINE, "Checking for builds of {0} on node {1}", new Object[] {task.getName(), node.getDisplayName()}); // I think this'll be more reliable than job.getBuilds(), which seemed to not always get // a build right after it was launched, for some reason. Computer computer = node.toComputer(); if (computer != null) { //Not all nodes are certain to become computers, like nodes with 0 executors. // Count flyweight tasks that might not consume an actual executor. for (Executor e : computer.getOneOffExecutors()) { runCount += buildsOnExecutor(task, e); } for (Executor e : computer.getExecutors()) { runCount += buildsOnExecutor(task, e); } } return runCount; }
@Override public String getStatus() { // Yet another copy of the same logic; perhaps this should be factored into some method returning a union of Queue.Item and PlaceholderExecutable? for (Queue.Item item : Queue.getInstance().getItems()) { if (item.task instanceof PlaceholderTask && ((PlaceholderTask) item.task).context.equals(getContext())) { return "waiting for " + item.task.getFullDisplayName() + " to be scheduled; blocked: " + item.getWhy(); } } Jenkins j = Jenkins.getInstance(); if (j != null) { COMPUTERS: for (Computer c : j.getComputers()) { for (Executor e : c.getExecutors()) { Queue.Executable exec = e.getCurrentExecutable(); if (exec instanceof PlaceholderTask.PlaceholderExecutable && ((PlaceholderTask.PlaceholderExecutable) exec).getParent().context.equals(getContext())) { return "running on " + c.getName(); } } } } return "node block appears to be neither running nor scheduled"; }
private static void assertNoTasksRunning(Jenkins j) { j.getQueue().maintain(); assert j.getQueue().isEmpty(); Computer[] computerList = j.getComputers(); for (Computer c : computerList) { List<Executor> executors = c.getExecutors(); for (Executor ex : executors) { if (ex.isBusy()) { Assert.fail("Computer "+c+" has an Executor "+ex+" still running a task: "+ex.getCurrentWorkUnit()); } } } }