Source:
private long internalCheck(EC2Computer computer) { if (idleTerminationMinutes == 0 || computer.getNode() == null) { return 1; } if (computer.isIdle() && !DISABLED) { final long uptime; InstanceState state; try { state = computer.getState(); uptime = computer.getUptime(); } catch (AmazonClientException | InterruptedException e) { LOGGER.fine("Exception while checking host uptime for " + computer.getName() + ", will retry next check. Exception: " + e); return 1; } if (InstanceState.TERMINATED.equals(state) || computer.getSlaveTemplate().stopOnTerminate && (InstanceState.STOPPED.equals(state) || InstanceState.STOPPING.equals(state))) { return 1; } if (computer.isOffline() && uptime < TimeUnit.MINUTES.toMillis(STARTUP_TIMEOUT)) { return 1; } final long idleMilliseconds = System.currentTimeMillis() - computer.getIdleStartMilliseconds(); if ( uptime < idleMilliseconds) { return 1; } if (idleTerminationMinutes > 0) { if (idleMilliseconds > TimeUnit.MINUTES.toMillis(idleTerminationMinutes)) { LOGGER.info("Idle timeout of " + computer.getName() + " after " + TimeUnit.MILLISECONDS.toMinutes(idleMilliseconds) + " idle minutes, instance status"+state.toString()); computer.getNode().idleTimeout(); } } else { final int oneHourSeconds = (int) TimeUnit.SECONDS.convert(1, TimeUnit.HOURS); final int freeSecondsLeft = oneHourSeconds - (int) (TimeUnit.SECONDS.convert(uptime, TimeUnit.MILLISECONDS) % oneHourSeconds); if (freeSecondsLeft <= TimeUnit.MINUTES.toSeconds(Math.abs(idleTerminationMinutes))) { LOGGER.info("Idle timeout of " + computer.getName() + " after " + TimeUnit.MILLISECONDS.toMinutes(idleMilliseconds) + " idle minutes, with " + TimeUnit.SECONDS.toMinutes(freeSecondsLeft) + " minutes remaining in billing period"); computer.getNode().idleTimeout(); } } } return 1; }

Target:
private long internalCheck(EC2Computer computer) { if (idleTerminationMinutes == 0 || computer.getNode() == null) { return 1; } if (computer.isIdle() && !DISABLED) { final long uptime; InstanceState state; try { state = computer.getState(); uptime = computer.getUptime(); } catch (AmazonClientException | InterruptedException e) { LOGGER.fine("Exception while checking host uptime for " + computer.getName() + ", will retry next check. Exception: " + e); return 1; } if (InstanceState.TERMINATED.equals(state) || computer.getSlaveTemplate().stopOnTerminate && (InstanceState.STOPPED.equals(state) || InstanceState.STOPPING.equals(state))) { if (computer.isOnline()) { LOGGER.info("External Stop of " + computer.getName() + " detected - disconnecting. instance status" + state.toString()); computer.disconnect(null); } return 1; } if (computer.isOffline() && uptime < TimeUnit.MINUTES.toMillis(STARTUP_TIMEOUT)) { return 1; } final long idleMilliseconds = System.currentTimeMillis() - computer.getIdleStartMilliseconds(); if ( uptime < idleMilliseconds) { return 1; } if (idleTerminationMinutes > 0) { if (idleMilliseconds > TimeUnit.MINUTES.toMillis(idleTerminationMinutes)) { LOGGER.info("Idle timeout of " + computer.getName() + " after " + TimeUnit.MILLISECONDS.toMinutes(idleMilliseconds) + " idle minutes, instance status"+state.toString()); computer.getNode().idleTimeout(); } } else { final int oneHourSeconds = (int) TimeUnit.SECONDS.convert(1, TimeUnit.HOURS); final int freeSecondsLeft = oneHourSeconds - (int) (TimeUnit.SECONDS.convert(uptime, TimeUnit.MILLISECONDS) % oneHourSeconds); if (freeSecondsLeft <= TimeUnit.MINUTES.toSeconds(Math.abs(idleTerminationMinutes))) { LOGGER.info("Idle timeout of " + computer.getName() + " after " + TimeUnit.MILLISECONDS.toMinutes(idleMilliseconds) + " idle minutes, with " + TimeUnit.SECONDS.toMinutes(freeSecondsLeft) + " minutes remaining in billing period"); computer.getNode().idleTimeout(); } } } return 1; }