Esempio n. 1
0
 /**
  * Returns the time when this computer last became idle.
  *
  * <p>If this computer is already idle, the return value will point to the time in the past since
  * when this computer has been idle.
  *
  * <p>If this computer is busy, the return value will point to the time in the future where this
  * computer will be expected to become free.
  */
 public final long getIdleStartMilliseconds() {
   long firstIdle = Long.MIN_VALUE;
   for (Executor e : oneOffExecutors) {
     firstIdle = Math.max(firstIdle, e.getIdleStartMilliseconds());
   }
   for (Executor e : executors) {
     firstIdle = Math.max(firstIdle, e.getIdleStartMilliseconds());
   }
   return firstIdle;
 }
Esempio n. 2
0
 /** 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;
 }
Esempio n. 3
0
 /** Decrease the count of slaves being "provisioned". */
 private void decrementAmiSlaveProvision(String ami) {
   synchronized (provisioningAmis) {
     int currentProvisioning;
     try {
       currentProvisioning = provisioningAmis.get(ami);
     } catch (NullPointerException npe) {
       return;
     }
     provisioningAmis.put(ami, Math.max(currentProvisioning - 1, 0));
   }
 }
Esempio n. 4
0
  public long getEstimatedDuration() {
    List<RunT> builds = getLastBuildsOverThreshold(3, Result.UNSTABLE);

    if (builds.isEmpty()) return -1;

    long totalDuration = 0;
    for (RunT b : builds) {
      totalDuration += b.getDuration();
    }
    if (totalDuration == 0) return -1;

    return Math.round((double) totalDuration / builds.size());
  }