@Override public Object fromString(String string) { return Jenkins.getInstance().getQueue(); }
/** * Returns the queue item if the owner is scheduled for execution in the queue, in REVERSE ORDER */ public List<Item> getQueuedItems() { LinkedList<Item> list = new LinkedList<Item>(); for (Item item : Jenkins.getInstance().getQueue().getItems()) { if (item.task == owner) { list.addFirst(item); } } return list; }
/** * Returns the time when this computer first became in demand. */ public final long getDemandStartMilliseconds() { long firstDemand = Long.MAX_VALUE; for (Queue.BuildableItem item : Jenkins.getInstance().getQueue().getBuildableItems(this)) { firstDemand = Math.min(item.buildableStartMilliseconds, firstDemand); } return firstDemand; }
public Executor(@Nonnull Computer owner, int n) { super("Executor #"+n+" for "+owner.getDisplayName()); this.owner = owner; this.queue = Jenkins.get().getQueue(); this.number = n; }
/** * Wraps a {@link Runnable} with the {@link Queue} lock held. * * @param runnable the operation to wrap. * @since 1.618 */ public static Runnable wrapWithLock(Runnable runnable) { final Jenkins jenkins = Jenkins.getInstanceOrNull(); // TODO confirm safe to assume non-null and use getInstance() final Queue queue = jenkins == null ? null : jenkins.getQueue(); return queue == null ? runnable : new LockedRunnable(runnable); }
/** * Wraps a {@link hudson.remoting.Callable} with the {@link Queue} lock held. * * @param callable the operation to wrap. * @since 1.618 */ public static <V, T extends Throwable> hudson.remoting.Callable<V, T> wrapWithLock(hudson.remoting.Callable<V, T> callable) { final Jenkins jenkins = Jenkins.getInstanceOrNull(); // TODO confirm safe to assume non-null and use getInstance() final Queue queue = jenkins == null ? null : jenkins.getQueue(); return queue == null ? callable : new LockedHRCallable<>(callable); }
/** * Returns true if the build is in the queue. */ @Override public boolean isInQueue() { return Jenkins.getInstance().getQueue().contains(this); }
/** * Restores the queue content during the start up. */ @Initializer(after=JOB_LOADED) public static void init(Jenkins h) { h.getQueue().load(); }
/** * Wraps a {@link java.util.concurrent.Callable} with the {@link Queue} lock held. * * @param callable the operation to wrap. * @since 1.618 */ public static <V> java.util.concurrent.Callable<V> wrapWithLock(java.util.concurrent.Callable<V> callable) { final Jenkins jenkins = Jenkins.getInstanceOrNull(); // TODO confirm safe to assume non-null and use getInstance() final Queue queue = jenkins == null ? null : jenkins.getQueue(); return queue == null ? callable : new LockedJUCCallable<V>(callable); }
@Override public int computeQueueLength() { return Jenkins.getInstance().getQueue().countBuildableItemsFor(Label.this); }
@Override public int computeQueueLength() { return Jenkins.getInstance().getQueue().strictCountBuildableItemsFor(null); }
@Override protected int run() throws Exception { Jenkins.getActiveInstance().getQueue().clear(); return 0; }
/** * Returns the first queue item if the owner is scheduled for execution in the queue. */ public Item getQueuedItem() { return Jenkins.getInstance().getQueue().getItem(owner); }
/** * @deprecated Use {@link #getQueueItems()}. As of 1.607 the approximation is no longer needed. * @return The items in the queue. */ @Deprecated public List<Queue.Item> getApproximateQueueItemsQuickly() { return filterQueue(Jenkins.getInstance().getQueue().getApproximateItemsQuickly()); }
/** @deprecated Use {@link #doCancelItem} instead. */ @Deprecated @RequirePOST public HttpResponse doCancelQueue() throws IOException, ServletException { if(hasCancelPermission()){ Jenkins.getInstance().getQueue().cancel(this); } return HttpResponses.forwardToPreviousPage(); }
/** * Cancel previous quiet down Jenkins - preparation for a restart */ @RequirePOST // TODO the cancel link needs to be updated accordingly public synchronized HttpRedirect doCancelQuietDown() { checkPermission(ADMINISTER); isQuietingDown = false; getQueue().scheduleMaintenance(); return new HttpRedirect("."); }
@CheckForNull Queue.Item scheduleBuild2(int quietPeriod, List<Action> actions) { if (!asJob().isBuildable()) return null; List<Action> queueActions = new ArrayList<Action>(actions); if (isParameterized() && Util.filter(queueActions, ParametersAction.class).isEmpty()) { queueActions.add(new ParametersAction(getDefaultParametersValues())); } return Jenkins.getInstance().getQueue().schedule2(asJob(), quietPeriod, queueActions).getItem(); }
@Override @RequirePOST public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { super.doConfigSubmit(req,rsp); updateTransientActions(); // notify the queue as the project might be now tied to different node Jenkins.getInstance().getQueue().scheduleMaintenance(); // this is to reflect the upstream build adjustments done above Jenkins.getInstance().rebuildDependencyGraphAsync(); }
/** * Standard implementation of {@link ParameterizedJob#doCancelQueue}. */ @RequirePOST public final void doCancelQueue( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { asJob().checkPermission(Item.CANCEL); Jenkins.getInstance().getQueue().cancel(asJob()); rsp.forwardToPreviousPage(req); }
protected void doRun() { Jenkins j = Jenkins.getInstance(); List<Queue.BuildableItem> bis = j.getQueue().getBuildableItems(); // update statistics on agents for( Label l : j.getLabels() ) { l.loadStatistics.updateCounts(l.loadStatistics.computeSnapshot(bis)); } // update statistics of the entire system j.unlabeledLoad.updateCounts(j.unlabeledLoad.computeSnapshot(bis)); j.overallLoad.updateCounts(j.overallLoad.computeSnapshot(bis)); }