Exemple #1
0
 /**
  * Marks the computer as temporarily offline. This retains the underlying {@link Channel}
  * connection, but prevent builds from executing.
  *
  * @param cause If the first argument is true, specify the reason why the node is being put
  *     offline.
  */
 public void setTemporarilyOffline(boolean temporarilyOffline, OfflineCause cause) {
   offlineCause = temporarilyOffline ? cause : null;
   this.temporarilyOffline = temporarilyOffline;
   Node node = getNode();
   if (node != null) {
     node.setTemporaryOfflineCause(offlineCause);
   }
   Jenkins.getInstance().getQueue().scheduleMaintenance();
   synchronized (statusChangeLock) {
     statusChangeLock.notifyAll();
   }
   for (ComputerListener cl : ComputerListener.all()) {
     if (temporarilyOffline) cl.onTemporarilyOffline(this, cause);
     else cl.onTemporarilyOnline(this);
   }
 }
Exemple #2
0
  /**
   * Updates Computers.
   *
   * <p>This method tries to reuse existing {@link Computer} objects so that we won't upset {@link
   * Executor}s running in it.
   */
  protected void updateComputerList(boolean automaticSlaveLaunch) throws IOException {
    Map<Node, Computer> computers = getComputerMap();
    synchronized (
        updateComputerLock) { // just so that we don't have two code updating computer list at the
                              // same time
      Map<String, Computer> byName = new HashMap<String, Computer>();
      for (Computer c : computers.values()) {
        if (c.getNode() == null) continue; // this computer is gone
        byName.put(c.getNode().getNodeName(), c);
      }

      Set<Computer> old = new HashSet<Computer>(computers.values());
      Set<Computer> used = new HashSet<Computer>();

      updateComputer(this, byName, used, automaticSlaveLaunch);
      for (Node s : getNodes()) {
        long start = System.currentTimeMillis();
        updateComputer(s, byName, used, automaticSlaveLaunch);
        if (LOG_STARTUP_PERFORMANCE)
          LOGGER.info(
              String.format(
                  "Took %dms to update node %s",
                  System.currentTimeMillis() - start, s.getNodeName()));
      }

      // find out what computers are removed, and kill off all executors.
      // when all executors exit, it will be removed from the computers map.
      // so don't remove too quickly
      old.removeAll(used);
      for (Computer c : old) {
        killComputer(c);
      }
    }
    getQueue().scheduleMaintenance();
    for (ComputerListener cl : ComputerListener.all()) cl.onConfigurationChange();
  }