private long checkInternal(MesosComputer c) { if (c.getNode() == null) { return 1; } // If we just launched this computer, check back after 1 min. // NOTE: 'c.getConnectTime()' refers to when the Jenkins slave was launched. if ((System.currentTimeMillis() - c.getConnectTime()) < MINUTES.toMillis(idleTerminationMinutes)) { return 1; } // If the computer is offline, terminate it. if (c.isOffline()) { LOGGER.info("Disconnecting offline computer " + c.getName()); c.getNode().terminate(); return 1; } // Terminate the computer if it is idle for longer than // 'idleTerminationMinutes'. if (c.isIdle()) { final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds(); if (idleMilliseconds > MINUTES.toMillis(idleTerminationMinutes)) { LOGGER.info("Disconnecting idle computer " + c.getName()); c.getNode().terminate(); } } return 1; }
/** Try to connect to it ASAP to launch the slave agent. */ @Override public void start(MesosComputer c) { c.connect(false); }