/** * Gets the one off {@link Executor} building this job, if it's being built. * Otherwise null. * @since 1.433 */ public @CheckForNull Executor getOneOffExecutor() { for( Computer c : Jenkins.getInstance().getComputers() ) { for (Executor e : c.getOneOffExecutors()) { if(e.getCurrentExecutable()==this) return e; } } return null; }
/** * 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; }
/** * Gets the one off {@link Executor} building this job, if it's being built. * Otherwise null. * @since 1.433 */ public @CheckForNull Executor getOneOffExecutor() { for( Computer c : Jenkins.getInstance().getComputers() ) { for (Executor e : c.getOneOffExecutors()) { if(e.getCurrentExecutable()==this) return e; } } return null; }
@Override public Executor getOneOffExecutor() { for (final Computer c : Jenkins.getInstance().getComputers()) { for (final Executor e : c.getOneOffExecutors()) { if (isCurrent(e)) return e; } } return null; }
/** * Returns a set of queue ids of all currently running builds on a node. * * @param nodeName the node name to list running projects for * @return set of queue ids */ public static Set<Long> getRunninProjectsQueueIDs(String nodeName) { Set<Long> runningProjects = new HashSet<Long>(); Node node = Jenkins.getInstance().getNode(nodeName); if (nodeName.isEmpty()) { // Special case when building on master node = Jenkins.getInstance(); } if (node != null) { Computer computer = node.toComputer(); if (computer != null) { List<Executor> executors = new ArrayList<Executor>(computer.getExecutors()); executors.addAll(computer.getOneOffExecutors()); for (Executor executor : executors) { Queue.Executable executable = executor.getCurrentExecutable(); if (executable instanceof AbstractBuild) { AbstractBuild build = (AbstractBuild)executable; runningProjects.add(build.getQueueId()); } } } } return Collections.unmodifiableSet(runningProjects); }
building.add(e.getCurrentExecutable()); for (Executor e : c.getOneOffExecutors()) { if (e.isBusy()) building.add(e.getCurrentExecutable());
building.add(e.getCurrentExecutable()); for (Executor e : c.getOneOffExecutors()) { if (e.isBusy()) building.add(e.getCurrentExecutable());
building.add(e.getCurrentExecutable()); for (Executor e : c.getOneOffExecutors()) { if (e.isBusy()) building.add(e.getCurrentExecutable());
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; }
for (Computer c : jenkins.getComputers()) { List<Executor> executors = new ArrayList<Executor>(); executors.addAll(c.getOneOffExecutors()); executors.addAll(c.getExecutors()); for (Executor e : executors) {
executors.addAll(computer.getOneOffExecutors());
/** * Gets the number of current indexing tasks on the specified node. * * @param node the node. * @return number of current indexing tasks on the specified node. */ public int indexingCount(@CheckForNull Node node) { int result = 0; @CheckForNull Computer computer = node == null ? null : node.toComputer(); if (computer != null) { // not all nodes will have a computer for (Executor e : computer.getExecutors()) { if (e.getCurrentExecutable() instanceof FolderComputation) { result++; } } for (Executor e : computer.getOneOffExecutors()) { if (e.getCurrentExecutable() instanceof FolderComputation) { result++; } } } return result; }
/** * Gets the number of current computation tasks on the specified node. * * @param node the node. * @return number of current computation tasks on the specified node. */ public int computationCount(@CheckForNull Node node) { int result = 0; @CheckForNull Computer computer = node == null ? null : node.toComputer(); if (computer != null) { // not all nodes will have a computer for (Executor e : computer.getExecutors()) { if (e.getCurrentExecutable() instanceof FolderComputation) { result++; } } for (Executor e : computer.getOneOffExecutors()) { if (e.getCurrentExecutable() instanceof FolderComputation) { result++; } } } return result; }
for (Executor e : c.getOneOffExecutors()) { WorkUnit workUnit = e.getCurrentWorkUnit(); if (workUnit != null) {
for (Executor e : c.getOneOffExecutors()) { if (e.isBusy()) { if (e.getCauseOfDeath() == null) {
@Test @Issue("JENKINS-42511") public void concurrentEvents() throws Exception { CoordinatedComputedFolder d = r.jenkins.createProject(CoordinatedComputedFolder.class, "d"); d.kids.addAll(Arrays.asList("A", "B")); QueueTaskFuture<Queue.Executable> future = d.scheduleBuild2(0).getFuture(); d.onKid("B"); future.get(); waitUntilNoActivityIgnoringThreadDeathUpTo(10000); List<Throwable> deaths = new ArrayList<Throwable>(); for (Computer comp : r.jenkins.getComputers()) { for (Executor e : comp.getExecutors()) { if (e.getCauseOfDeath() != null) { deaths.add(e.getCauseOfDeath()); } } for (Executor e : comp.getOneOffExecutors()) { if (e.getCauseOfDeath() != null) { deaths.add(e.getCauseOfDeath()); } } } assertThat("None of the executors have died abnormally", deaths, containsInAnyOrder()); }
@Override public String getStatus() { for (Queue.Item i : Queue.getInstance().getItems()) { for (BuildTriggerAction.Trigger trigger : BuildTriggerAction.triggersFor(i)) { if (trigger.context.equals(getContext())) { return "waiting to schedule " + i.task.getFullDisplayName() + "; blocked: " + i.getWhy(); } } } for (Computer c : Jenkins.getActiveInstance().getComputers()) { for (Executor e : c.getExecutors()) { String r = running(e); if (r != null) { return r; } } for (Executor e : c.getOneOffExecutors()) { String r = running(e); if (r != null) { return r; } } } // TODO QueueTaskFuture does not allow us to record the queue item ID return "unsure what happened to downstream build"; } private @CheckForNull String running(@Nonnull Executor e) {
interrupted |= maybeInterrupt(e, cause, context); for (Executor e : c.getOneOffExecutors()) { interrupted |= maybeInterrupt(e, cause, context);
/** * Returns true if Hudson is building something or going to build something. */ public boolean isSomethingHappeningIgnoringThreadDeath() { if (!r.jenkins.getQueue().isEmpty()) { return true; } for (Computer n : r.jenkins.getComputers()) { for (OneOffExecutor e : n.getOneOffExecutors()) { if (e.getCauseOfDeath() == null && e.isBusy()) { return true; } } for (Executor e : n.getExecutors()) { if (e.getCauseOfDeath() == null && e.isBusy()) { return true; } } } return false; }