Source:
public void refresh() { Set<? extends ComputeMetadata> computes = computeService.listNodes(); Set<NodeMetadata> nodes = new LinkedHashSet<NodeMetadata>(); for (ComputeMetadata c: computes) { if (c instanceof NodeMetadata) { nodes.add((NodeMetadata)c); } else { log.warn("MachinePool "+this+" ignoring non-Node record for remote machine: "+c); } } MachineSet allNewDetectedMachines = new MachineSet(nodes); MachineSet newDetectedMachines = filterForAllowedMachines(allNewDetectedMachines); MachineSet oldDetectedMachines; synchronized (this) { oldDetectedMachines = detectedMachines; detectedMachines = newDetectedMachines; refreshNeeded.set(false); } if (log.isDebugEnabled()) { MachineSet appearedMachinesIncludingBlacklist = allNewDetectedMachines.removed(oldDetectedMachines); MachineSet appearedMachines = filterForAllowedMachines(appearedMachinesIncludingBlacklist); if (appearedMachinesIncludingBlacklist.size()>appearedMachines.size()) log.debug("Pool "+this+", ignoring "+(appearedMachinesIncludingBlacklist.size()-appearedMachines.size())+" disallowed"); int matchedAppeared = 0; for (NodeMetadata m: appearedMachines) { Set<ReusableMachineTemplate> ts = getTemplatesMatchingInstance(m); if (!ts.isEmpty()) { matchedAppeared++; if (log.isDebugEnabled()) log.debug("Pool "+this+", newly detected machine "+m+", matches pool templates "+ts); } else { log.debug("Pool "+this+", newly detected machine "+m+", does not match any pool templates"); } } if (matchedAppeared>0) log.info("Pool "+this+" discovered "+matchedAppeared+" matching machines (of "+appearedMachines.size()+" total new; "+newDetectedMachines.size()+" total including claimed and unmatched)"); else log.debug("Pool "+this+" discovered "+matchedAppeared+" matching machines (of "+appearedMachines.size()+" total new; "+newDetectedMachines.size()+" total including claimed and unmatched)"); } }

Target:
public synchronized void refresh() { refreshNeeded.set(false); Set<? extends ComputeMetadata> computes = computeService.listNodes(); Set<NodeMetadata> nodes = new LinkedHashSet<NodeMetadata>(); for (ComputeMetadata c: computes) { if (c instanceof NodeMetadata) { nodes.add((NodeMetadata)c); } else { log.warn("MachinePool "+this+" ignoring non-Node record for remote machine: "+c); } } MachineSet allNewDetectedMachines = new MachineSet(nodes); MachineSet newDetectedMachines = filterForAllowedMachines(allNewDetectedMachines); MachineSet oldDetectedMachines; oldDetectedMachines = detectedMachines; detectedMachines = newDetectedMachines; MachineSet appearedMachinesIncludingBlacklist = allNewDetectedMachines.removed(oldDetectedMachines); MachineSet appearedMachines = filterForAllowedMachines(appearedMachinesIncludingBlacklist); if (appearedMachinesIncludingBlacklist.size()>appearedMachines.size()) if (log.isDebugEnabled()) log.debug("Pool "+this+", ignoring "+(appearedMachinesIncludingBlacklist.size()-appearedMachines.size())+" disallowed"); int matchedAppeared = 0; for (NodeMetadata m: appearedMachines) { Set<ReusableMachineTemplate> ts = getTemplatesMatchingInstance(m); if (!ts.isEmpty()) { matchedAppeared++; if (log.isDebugEnabled()) log.debug("Pool "+this+", newly detected machine "+m+", matches pool templates "+ts); } else { if (log.isDebugEnabled()) log.debug("Pool "+this+", newly detected machine "+m+", does not match any pool templates"); } } if (matchedAppeared>0) { log.info("Pool "+this+" discovered "+matchedAppeared+" matching machines (of "+appearedMachines.size()+" total new; "+newDetectedMachines.size()+" total including claimed and unmatched)"); } else { if (log.isDebugEnabled()) log.debug("Pool "+this+" discovered "+matchedAppeared+" matching machines (of "+appearedMachines.size()+" total new; "+newDetectedMachines.size()+" total including claimed and unmatched)"); } }