final Set seenKeys = new HashSet();
final Hashtable dict = new Hashtable();
for (int i = 0; i < vms.length; i++) {
final VM vm = vms[i];
if (vm == null) {
logger.error("Manager implementation is invalid, received " +
"null VM in query response");
continue; // *** GOTO NEXT VM ***
}
final String groupid = vm.getGroupID();
if (groupid == null) {
this._newNoGroupID(vm, seenKeys, dict);
} else {
this._newGroupReservation(vm, groupid, seenKeys, dict);
}
}
// look at all VMs to make sure they have elastic instance IDs,
// they will not if they were created via other protocols and have
// never shown up to this messaging layer before
final Iterator iter = dict.keySet().iterator();
while (iter.hasNext()) {
final String elasticReservationID = (String) iter.next();
final List group = (List) dict.get(elasticReservationID);
final Iterator groupiter = group.iterator();
while (groupiter.hasNext()) {
final VM vm = (VM) groupiter.next();
try {
this.ids.checkInstanceAndReservation(vm.getID(),
elasticReservationID);
} catch (Exception e) {
final String elasticSingleID =
this.ids.managerInstanceToElasticReservation(vm.getID());
if (elasticSingleID == null) {
throw new CannotTranslateException(e.getMessage(), e);
}
}