Source:
public boolean needRecycle(String workerTag) { if (s_logger.isInfoEnabled()) s_logger.info("Check to see if a worker VM with tag " + workerTag + " needs to be recycled"); if (workerTag == null || workerTag.isEmpty()) { s_logger.error("Invalid worker VM tag " + workerTag); return false; } String tokens[] = workerTag.split("-"); if (tokens.length != 3) { s_logger.error("Invalid worker VM tag " + workerTag); return false; } long startTick = Long.parseLong(tokens[0]); long msid = Long.parseLong(tokens[1]); long runid = Long.parseLong(tokens[2]); if (_mshostPeerDao.countStateSeenInPeers(msid, runid, ManagementServerHost.State.Down) > 0) { if (s_logger.isInfoEnabled()) s_logger.info("Worker VM's owner management server node has been detected down from peer nodes, recycle it"); return true; } if (runid != _clusterMgr.getManagementRunId(msid)) { if (s_logger.isInfoEnabled()) s_logger.info("Worker VM's owner management server has changed runid, recycle it"); return true; } Long hungWorkerTimeout = 2 * (AsyncJobManagerImpl.JobExpireMinutes.value() + AsyncJobManagerImpl.JobCancelThresholdMinutes.value()) * MILISECONDS_PER_MINUTE; Long letsSayNow = System.currentTimeMillis(); if(s_vmwareCleanOldWorderVMs.value() && letsSayNow - startTick > hungWorkerTimeout) { if(s_logger.isInfoEnabled()) { s_logger.info("Worker VM expired, seconds elapsed: " + (System.currentTimeMillis() - startTick) / 1000); } return true; } if (s_logger.isTraceEnabled()) { s_logger.trace("Worker VM with tag '" + workerTag + "' does not need recycling, yet." + "But in " + (startTick + hungWorkerTimeout - letsSayNow) + " milisecs, though"); } return false; }

Target:
public boolean needRecycle(String workerTag) { if (s_logger.isInfoEnabled()) s_logger.info("Check to see if a worker VM with tag " + workerTag + " needs to be recycled"); if (workerTag == null || workerTag.isEmpty()) { s_logger.error("Invalid worker VM tag " + workerTag); return false; } String tokens[] = workerTag.split("-"); if (tokens.length != 3) { s_logger.error("Invalid worker VM tag " + workerTag); return false; } long startTick = Long.parseLong(tokens[0]); long msid = Long.parseLong(tokens[1]); long runid = Long.parseLong(tokens[2]); if (_mshostPeerDao.countStateSeenInPeers(msid, runid, ManagementServerHost.State.Down) > 0) { if (s_logger.isInfoEnabled()) s_logger.info("Worker VM's owner management server node has been detected down from peer nodes, recycle it"); return true; } if (runid != _clusterMgr.getManagementRunId(msid)) { if (s_logger.isInfoEnabled()) s_logger.info("Worker VM's owner management server has changed runid, recycle it"); return true; } Instant start = Instant.ofEpochMilli(startTick); Instant end = start.plusSeconds(2 * (AsyncJobManagerImpl.JobExpireMinutes.value() + AsyncJobManagerImpl.JobCancelThresholdMinutes.value()) * SECONDS_PER_MINUTE); Instant now = Instant.now(); if(s_vmwareCleanOldWorderVMs.value() && now.isAfter(end)) { if(s_logger.isInfoEnabled()) { s_logger.info("Worker VM expired, seconds elapsed: " + Duration.between(start,now).getSeconds()); } return true; } if (s_logger.isTraceEnabled()) { s_logger.trace("Worker VM with tag '" + workerTag + "' does not need recycling, yet." + "But in " + Duration.between(now,end).getSeconds() + " seconds, though"); } return false; }