logger.info("vNode " + vNode.getBaseNodeNames()
+ " has RoundRobin Rack policy");
logger.info("Candidate racks are " + candidateRacks);
}
AbstractHost candidate = null;
boolean found = false;
int rackIndex = 0;
while (candidates.size() > 0) {
List<AbstractHost> subset = candidates;
if (rrRackPolicy) {
while (rackIndex < candidateRacks.size()) {
subset = rackFilter(candidates, candidateRacks.get(rackIndex));
if (subset.size() > 0) {
break;
}
rackIndex++;
}
if (rackIndex == candidateRacks.size()) {
logger.warn("tried with all candidate racks, there are no host are available");
if (isAssociatedCandidates)
return null;
else
throw PlacementException.OUT_OF_RACK(candidateRacks, vNode.getBaseNodeNames());
}
logger.info("try hosts on Rack " + candidateRacks.get(rackIndex));
}
// least used hosts, RR policy
candidate = getLeastUsed(subset);
logger.info("found a candidate host " + candidate
+ ", try to place disk onto it");
// generate the disk placement plan for a candidate host
if (placeDisk(vNode, candidate)) {
// assign host
logger.info("candidate host " + candidate + " is selected");
assignHost(vNode, candidate);
found = true;
break;
}
logger.info("drop candidate host " + candidate.getName()
+ " as it failed to come out a disk placement plan");
candidates.remove(candidate);
}
if (!found)