/** * 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; }
/** * Computes a self-consistent snapshot of the load statistics. * * Note: The original method of computing load statistics would compute the total and idle counts independently * which could lead to counting errors while jobs started in between the different state counting operations. * By returning a {@link LoadStatisticsSnapshot} we get a single consistent view of the counts which was valid * for at least one point in time during the execution of this method. * * @return a self-consistent snapshot of the load statistics. * @since 1.607 */ public LoadStatisticsSnapshot computeSnapshot() { if (modern) { return computeSnapshot(Jenkins.getInstance().getQueue().getBuildableItems()); } else { int t = computeTotalExecutors(); int i = computeIdleExecutors(); return new LoadStatisticsSnapshot(t, t, Math.max(i-t,0), Math.max(t-i,0), i, i, computeQueueLength()); } }
@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, Computer computer, long start, long end) { TimeRange timeRange = new TimeRange(start, end - start); List<FutureLoad> loads = new ArrayList<FutureLoad>(); for (BuildableItem bi : Jenkins.getInstance().getQueue().getBuildableItems()) { TentativePlan tp = bi.getAction(TentativePlan.class); if (tp==null) {// do this even for bi==plan.item ensures that we have FIFO semantics in tentative plans. tp = makeTentativePlan(bi); if (tp==null) continue; // no viable plan. } if (tp.isStale()) { // if the tentative plan is stale, just keep on pushing it to the current time // (if we recreate the plan, it'll be put at the end of the queue, whereas this job // should actually get priority over others) tp.range.shiftTo(System.currentTimeMillis()); } // don't let its own tentative plan count when considering a scheduling for a job if (plan.item==bi) continue; // no overlap in the time span, meaning this plan is for a distant future if (!timeRange.overlapsWith(tp.range)) continue; // if this tentative plan has no baring on this computer, that's ignorable Integer i = tp.footprint.get(computer); if (i==null) continue; return Collections.singleton(tp.range.toFutureLoad(i)); } return loads; }
for (Queue.BuildableItem item : Queue.getInstance().getBuildableItems()) {
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)); }
/** * Returns the time when this computer first became in demand. */ public final long getDemandStartMilliseconds() { long firstDemand = Long.MAX_VALUE; for (Queue.BuildableItem item : Hudson.getInstance().getQueue().getBuildableItems(this)) { firstDemand = Math.min(item.buildableStartMilliseconds, firstDemand); } return firstDemand; }
/** * Returns the time when this computer first became in demand. */ public final long getDemandStartMilliseconds() { long firstDemand = Long.MAX_VALUE; for (Queue.BuildableItem item : Hudson.getInstance().getQueue().getBuildableItems(this)) { firstDemand = Math.min(item.buildableStartMilliseconds, firstDemand); } return firstDemand; }
/** * Returns the time when this computer first became in demand. */ public final long getDemandStartMilliseconds() { long firstDemand = Long.MAX_VALUE; for (Queue.BuildableItem item : Hudson.getInstance().getQueue().getBuildableItems(this)) { firstDemand = Math.min(item.buildableStartMilliseconds, firstDemand); } return firstDemand; }
/** * 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; }
/** * Returns the time when this computer first became in demand. */ public final long getDemandStartMilliseconds() { long firstDemand = Long.MAX_VALUE; for (Queue.BuildableItem item : Hudson.getInstance().getQueue().getBuildableItems(this)) { firstDemand = Math.min(item.buildableStartMilliseconds, firstDemand); } return firstDemand; }
/** * Computes a self-consistent snapshot of the load statistics. * * Note: The original method of computing load statistics would compute the total and idle counts independently * which could lead to counting errors while jobs started in between the different state counting operations. * By returning a {@link LoadStatisticsSnapshot} we get a single consistent view of the counts which was valid * for at least one point in time during the execution of this method. * * @return a self-consistent snapshot of the load statistics. * @since 1.607 */ public LoadStatisticsSnapshot computeSnapshot() { if (modern) { return computeSnapshot(Jenkins.getInstance().getQueue().getBuildableItems()); } else { int t = computeTotalExecutors(); int i = computeIdleExecutors(); return new LoadStatisticsSnapshot(t, t, Math.max(i-t,0), Math.max(t-i,0), i, i, computeQueueLength()); } }
@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, Computer computer, long start, long end) { TimeRange timeRange = new TimeRange(start, end - start); List<FutureLoad> loads = new ArrayList<FutureLoad>(); for (BuildableItem bi : Hudson.getInstance().getQueue().getBuildableItems()) { TentativePlan tp = bi.getAction(TentativePlan.class); if (tp==null) {// do this even for bi==plan.item ensures that we have FIFO semantics in tentative plans. tp = makeTentativePlan(bi); if (tp==null) continue; // no viable plan. } if (tp.isStale()) { // if the tentative plan is stale, just keep on pushing it to the current time // (if we recreate the plan, it'll be put at the end of the queue, whereas this job // should actually get priority over others) tp.range.shiftTo(System.currentTimeMillis()); } // don't let its own tentative plan count when considering a scheduling for a job if (plan.item==bi) continue; // no overlap in the time span, meaning this plan is for a distant future if (!timeRange.overlapsWith(tp.range)) continue; // if this tentative plan has no baring on this computer, that's ignorable Integer i = tp.footprint.get(computer); if (i==null) continue; return Collections.singleton(tp.range.toFutureLoad(i)); } return loads; }
@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, Computer computer, long start, long end) { TimeRange timeRange = new TimeRange(start, end - start); List<FutureLoad> loads = new ArrayList<FutureLoad>(); for (BuildableItem bi : Jenkins.getInstance().getQueue().getBuildableItems()) { TentativePlan tp = bi.getAction(TentativePlan.class); if (tp==null) {// do this even for bi==plan.item ensures that we have FIFO semantics in tentative plans. tp = makeTentativePlan(bi); if (tp==null) continue; // no viable plan. } if (tp.isStale()) { // if the tentative plan is stale, just keep on pushing it to the current time // (if we recreate the plan, it'll be put at the end of the queue, whereas this job // should actually get priority over others) tp.range.shiftTo(System.currentTimeMillis()); } // don't let its own tentative plan count when considering a scheduling for a job if (plan.item==bi) continue; // no overlap in the time span, meaning this plan is for a distant future if (!timeRange.overlapsWith(tp.range)) continue; // if this tentative plan has no baring on this computer, that's ignorable Integer i = tp.footprint.get(computer); if (i==null) continue; return Collections.singleton(tp.range.toFutureLoad(i)); } return loads; }
@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, Computer computer, long start, long end) { TimeRange timeRange = new TimeRange(start, end - start); List<FutureLoad> loads = new ArrayList<FutureLoad>(); for (BuildableItem bi : Hudson.getInstance().getQueue().getBuildableItems()) { TentativePlan tp = bi.getAction(TentativePlan.class); if (tp==null) {// do this even for bi==plan.item ensures that we have FIFO semantics in tentative plans. tp = makeTentativePlan(bi); if (tp==null) continue; // no viable plan. } if (tp.isStale()) { // if the tentative plan is stale, just keep on pushing it to the current time // (if we recreate the plan, it'll be put at the end of the queue, whereas this job // should actually get priority over others) tp.range.shiftTo(System.currentTimeMillis()); } // don't let its own tentative plan count when considering a scheduling for a job if (plan.item==bi) continue; // no overlap in the time span, meaning this plan is for a distant future if (!timeRange.overlapsWith(tp.range)) continue; // if this tentative plan has no baring on this computer, that's ignorable Integer i = tp.footprint.get(computer); if (i==null) continue; return Collections.singleton(tp.range.toFutureLoad(i)); } return loads; }
@Override public Iterable<FutureLoad> predict(MappingWorksheet plan, Computer computer, long start, long end) { TimeRange timeRange = new TimeRange(start, end - start); List<FutureLoad> loads = new ArrayList<FutureLoad>(); for (BuildableItem bi : Hudson.getInstance().getQueue().getBuildableItems()) { TentativePlan tp = bi.getAction(TentativePlan.class); if (tp==null) {// do this even for bi==plan.item ensures that we have FIFO semantics in tentative plans. tp = makeTentativePlan(bi); if (tp==null) continue; // no viable plan. } if (tp.isStale()) { // if the tentative plan is stale, just keep on pushing it to the current time // (if we recreate the plan, it'll be put at the end of the queue, whereas this job // should actually get priority over others) tp.range.shiftTo(System.currentTimeMillis()); } // don't let its own tentative plan count when considering a scheduling for a job if (plan.item==bi) continue; // no overlap in the time span, meaning this plan is for a distant future if (!timeRange.overlapsWith(tp.range)) continue; // if this tentative plan has no baring on this computer, that's ignorable Integer i = tp.footprint.get(computer); if (i==null) continue; return Collections.singleton(tp.range.toFutureLoad(i)); } return loads; }
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)); }
protected void doRun() { Hudson h = Hudson.getInstance(); List<hudson.model.Queue.BuildableItem> bis = h.getQueue().getBuildableItems(); // update statistics on slaves for( Label l : h.getLabels() ) { l.loadStatistics.totalExecutors.update(l.getTotalExecutors()); l.loadStatistics.busyExecutors .update(l.getBusyExecutors()); int q=0; for (hudson.model.Queue.BuildableItem bi : bis) { if(bi.task.getAssignedLabel()==l) q++; } l.loadStatistics.queueLength.update(q); } // update statistics of the entire system ComputerSet cs = new ComputerSet(); h.overallLoad.totalExecutors.update(cs.getTotalExecutors()); h.overallLoad.busyExecutors .update(cs.getBusyExecutors()); int q=0; for (hudson.model.Queue.BuildableItem bi : bis) { if(bi.task.getAssignedLabel()==null) q++; } h.overallLoad.queueLength.update(q); h.overallLoad.totalQueueLength.update(bis.size()); } }
protected void doRun() { Hudson h = Hudson.getInstance(); List<hudson.model.Queue.BuildableItem> bis = h.getQueue().getBuildableItems(); // update statistics on slaves for( Label l : h.getLabels() ) { l.loadStatistics.totalExecutors.update(l.getTotalExecutors()); l.loadStatistics.busyExecutors .update(l.getBusyExecutors()); int q=0; for (hudson.model.Queue.BuildableItem bi : bis) { if(bi.task.getAssignedLabel()==l) q++; } l.loadStatistics.queueLength.update(q); } // update statistics of the entire system ComputerSet cs = new ComputerSet(); h.overallLoad.totalExecutors.update(cs.getTotalExecutors()); h.overallLoad.busyExecutors .update(cs.getBusyExecutors()); int q=0; for (hudson.model.Queue.BuildableItem bi : bis) { if(bi.task.getAssignedLabel()==null) q++; } h.overallLoad.queueLength.update(q); h.overallLoad.totalQueueLength.update(bis.size()); } }
protected void doRun() { Hudson h = Hudson.getInstance(); List<hudson.model.Queue.BuildableItem> bis = h.getQueue().getBuildableItems(); // update statistics on slaves for( Label l : h.getLabels() ) { l.loadStatistics.totalExecutors.update(l.getTotalExecutors()); l.loadStatistics.busyExecutors .update(l.getBusyExecutors()); int q=0; for (hudson.model.Queue.BuildableItem bi : bis) { if(bi.task.getAssignedLabel()==l) q++; } l.loadStatistics.queueLength.update(q); } // update statistics of the entire system ComputerSet cs = new ComputerSet(); h.overallLoad.totalExecutors.update(cs.getTotalExecutors()); h.overallLoad.busyExecutors .update(cs.getBusyExecutors()); int q=0; for (hudson.model.Queue.BuildableItem bi : bis) { if(bi.task.getAssignedLabel()==null) q++; } h.overallLoad.queueLength.update(q); h.overallLoad.totalQueueLength.update(bis.size()); } }
protected void doRun() { Hudson h = Hudson.getInstance(); List<hudson.model.Queue.BuildableItem> bis = h.getQueue().getBuildableItems(); // update statistics on slaves for (Label l : h.getLabels()) { l.loadStatistics.totalExecutors.update(l.getTotalExecutors()); l.loadStatistics.busyExecutors.update(l.getBusyExecutors()); int q = 0; for (hudson.model.Queue.BuildableItem bi : bis) { if (bi.task.getAssignedLabel() == l) { q++; } } l.loadStatistics.queueLength.update(q); } // update statistics of the entire system ComputerSet cs = new ComputerSet(); h.overallLoad.totalExecutors.update(cs.getTotalExecutors()); h.overallLoad.busyExecutors.update(cs.getBusyExecutors()); int q = 0; for (hudson.model.Queue.BuildableItem bi : bis) { if (bi.task.getAssignedLabel() == null) { q++; } } h.overallLoad.queueLength.update(q); h.overallLoad.totalQueueLength.update(bis.size()); } }