/** * 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(); }