// ignore all segments for which there are no other owners to pull data from.
// these segments are considered empty (or lost) and do not require a state transfer
for (Iterator<Integer> it = segmentsToProcess.iterator(); it.hasNext(); ) {
Integer segmentId = it.next();
Address source = pickSourceOwner(segmentId, faultysources);
if (source == null) {
it.remove();
}
}
while (!segmentsToProcess.isEmpty()) {
Map<Address, Set<Integer>> segmentsBySource = new HashMap<Address, Set<Integer>>();
for (int segmentId : segmentsToProcess) {
synchronized (this) {
// already active transfers do not need to be added again
if (transfersBySegment.containsKey(segmentId)) {
continue;
}
}
Address source = pickSourceOwner(segmentId, faultysources);
if (source != null) {
Set<Integer> segmentsFromSource = segmentsBySource.get(source);
if (segmentsFromSource == null) {
segmentsFromSource = new HashSet<Integer>();
segmentsBySource.put(source, segmentsFromSource);