final PendingRequestsMap pendingRequestsMap = entry.getValue();
final Iterator<Map.Entry<InstanceType, Integer>> it2 = pendingRequestsMap.iterator();
while (it2.hasNext()) {
final Map.Entry<InstanceType, Integer> entry2 = it2.next();
final InstanceType requestedInstanceType = entry2.getKey();
int numberOfPendingInstances = entry2.getValue().intValue();
// Consistency check
if (numberOfPendingInstances <= 0) {
LOG.error("Inconsistency: Job " + jobID + " has " + numberOfPendingInstances
+ " requests for instance type " + requestedInstanceType.getIdentifier());
continue;
}
while (numberOfPendingInstances > 0) {
if (LOG.isDebugEnabled()) {
LOG.debug("Trying to allocate instance of type " + requestedInstanceType.getIdentifier());
}
// TODO: Introduce topology awareness here
final AllocatedSlice slice = getSliceOfType(jobID, requestedInstanceType);
if (slice == null) {
break;
} else {
LOG.info("Allocated instance of type " + requestedInstanceType.getIdentifier()
+ " as a result of pending request for job " + jobID);
// Decrease number of pending instances
--numberOfPendingInstances;
pendingRequestsMap.decreaseNumberOfPendingInstances(requestedInstanceType);