コード例 #1
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
 /** Returns the number of idle {@link Executor}s that can start working immediately. */
 public int countIdle() {
   int n = 0;
   for (Executor e : executors) {
     if (e.isIdle()) n++;
   }
   return n;
 }
コード例 #2
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
 /**
  * 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;
 }
コード例 #3
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
  private void addNewExecutorIfNecessary() {
    Set<Integer> availableNumbers = new HashSet<Integer>();
    for (int i = 0; i < numExecutors; i++) availableNumbers.add(i);

    for (Executor executor : executors) availableNumbers.remove(executor.getNumber());

    for (Integer number : availableNumbers) {
      Executor e = new Executor(this, number);
      e.start();
      executors.add(e);
    }
  }
コード例 #4
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
 @Override
 protected void performDelete() throws IOException, InterruptedException {
   // if a build is in progress. Cancel it.
   RunT lb = getLastBuild();
   if (lb != null) {
     Executor e = lb.getExecutor();
     if (e != null) {
       e.interrupt();
       // should we block until the build is cancelled?
     }
   }
   super.performDelete();
 }
コード例 #5
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
  private synchronized void setNumExecutors(int n) {
    if (numExecutors == n) return; // no-op

    int diff = n - numExecutors;
    this.numExecutors = n;

    if (diff < 0) {
      // send signal to all idle executors to potentially kill them off
      for (Executor e : executors) if (e.isIdle()) e.interrupt();
    } else {
      // if the number is increased, add new ones
      addNewExecutorIfNecessary();
    }
  }
コード例 #6
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
 /** Interrupt all {@link Executor}s. */
 public void interrupt() {
   for (Executor e : executors) {
     e.interrupt();
   }
 }
コード例 #7
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
 /**
  * Returns true if any of the executors are functioning.
  *
  * <p>Note that if an executor dies, we'll leave it in {@link #executors} until the administrator
  * yanks it out, so that we can see why it died.
  */
 private boolean isAlive() {
   for (Executor e : executors) if (e.isAlive()) return true;
   return false;
 }
コード例 #8
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
 /** Returns true if this computer has some idle executors that can take more workload. */
 public final boolean isPartiallyIdle() {
   for (Executor e : executors) if (e.isIdle()) return true;
   return false;
 }
コード例 #9
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
 /** Returns true if all the executors of this computer are idle. */
 @Exported
 public final boolean isIdle() {
   if (!oneOffExecutors.isEmpty()) return false;
   for (Executor e : executors) if (!e.isIdle()) return false;
   return true;
 }
コード例 #10
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
 /**
  * Gets the current {@link Computer} that the build is running. This method only works when called
  * during a build, such as by {@link Publisher}, {@link BuildWrapper}, etc.
  */
 public static Computer currentComputer() {
   Executor e = Executor.currentExecutor();
   // If no executor then must be on master node
   return e != null ? e.getOwner() : Jenkins.getInstance().toComputer();
 }