use of java.util.AbstractQueue in project eureka by Netflix.
the class Applications method shuffleAndFilterInstances.
/**
* Shuffle the instances and filter for only {@link InstanceStatus#UP} if
* required.
*
*/
private void shuffleAndFilterInstances(Map<String, AbstractQueue<InstanceInfo>> srcMap, Map<String, AtomicReference<List<InstanceInfo>>> destMap, Map<String, AtomicLong> vipIndexMap, boolean filterUpInstances) {
for (Map.Entry<String, AbstractQueue<InstanceInfo>> entries : srcMap.entrySet()) {
AbstractQueue<InstanceInfo> instanceInfoQueue = entries.getValue();
List<InstanceInfo> l = new ArrayList<InstanceInfo>(instanceInfoQueue);
if (filterUpInstances) {
Iterator<InstanceInfo> it = l.iterator();
while (it.hasNext()) {
InstanceInfo instanceInfo = it.next();
if (!InstanceStatus.UP.equals(instanceInfo.getStatus())) {
it.remove();
}
}
}
Collections.shuffle(l);
AtomicReference<List<InstanceInfo>> instanceInfoList = destMap.get(entries.getKey());
if (instanceInfoList == null) {
instanceInfoList = new AtomicReference<List<InstanceInfo>>(l);
destMap.put(entries.getKey(), instanceInfoList);
}
instanceInfoList.set(l);
vipIndexMap.put(entries.getKey(), new AtomicLong(0));
}
// finally remove all vips that are completed deleted (i.e. missing) from the srcSet
Set<String> srcVips = srcMap.keySet();
Set<String> destVips = destMap.keySet();
destVips.retainAll(srcVips);
}
Aggregations