@Override public synchronized long check(JCloudsComputer c) { if (c.isIdle() && !c.getNode().isPendingDelete() && !disabled) { // Get the retention time, in minutes, from the JCloudsCloud this JCloudsComputer belongs to. final int retentionTime = JCloudsCloud.getByName(c.getCloudName()).getRetentionTime(); if (retentionTime > -1) { final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds(); if (idleMilliseconds > TimeUnit2.MINUTES.toMillis(retentionTime)) { LOGGER.info("Setting " + c.getName() + " to be deleted."); if (!c.isOffline()) { c.setTemporarilyOffline(true, OfflineCause.create(Messages._DeletedCause())); } c.getNode().setPendingDelete(true); } } } return 1; }
/** Try to connect to it ASAP. */ @Override public void start(JCloudsComputer c) { c.connect(false); }