newStates.putAll(_vms);
for (Map.Entry<String, State> entry : newStates.entrySet()) {
String vm = entry.getKey();
State newState = entry.getValue();
State oldState = oldStates.remove(vm);
if (s_logger.isTraceEnabled()) {
s_logger.trace("VM " + vm + ": has state " + newState + " and we have state " + (oldState != null ? oldState.toString() : "null"));
}
if (oldState == null) {
_vms.put(vm, newState);
changes.put(vm, newState);
} else if (oldState == State.Starting) {
if (newState == State.Running) {
_vms.put(vm, newState);
} else if (newState == State.Stopped) {
s_logger.debug("Ignoring vm " + vm + " because of a lag in starting the vm.");
}
} else if (oldState == State.Stopping) {
if (newState == State.Stopped) {
_vms.put(vm, newState);
} else if (newState == State.Running) {
s_logger.debug("Ignoring vm " + vm + " because of a lag in stopping the vm. ");
}
} else if (oldState != newState) {
_vms.put(vm, newState);
changes.put(vm, newState);
}
}
for (Map.Entry<String, State> entry : oldStates.entrySet()) {
String vm = entry.getKey();
State oldState = entry.getValue();
if (s_logger.isTraceEnabled()) {
s_logger.trace("VM " + vm + " is now missing from simulator agent so reporting stopped");
}