bug 12791: Simulator: reload vm state when restart mgt server.

status 12791: resolved fixed
This commit is contained in:
Edison Su 2012-01-05 18:18:27 -08:00
parent cd29fdf711
commit 144265dbf4
1 changed files with 7 additions and 1 deletions

View File

@ -46,7 +46,7 @@ import com.cloud.vm.VirtualMachine.State;
public class AgentRoutingResource extends AgentStorageResource {
private static final Logger s_logger = Logger.getLogger(AgentRoutingResource.class);
protected Map<String, State> _vms = new HashMap<String, State>(20);
protected Map<String, State> _vms = new HashMap<String, State>();
protected String _mountParent;
@ -91,6 +91,12 @@ public class AgentRoutingResource extends AgentStorageResource {
if (isStopped()) {
return null;
}
synchronized (_vms) {
if (_vms.size() == 0) {
//load vms state from database
_vms.putAll(_simMgr.getVmStates(hostGuid));
}
}
final HashMap<String, State> newStates = sync();
HashMap<String, Pair<Long, Long>> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid);
return new PingRoutingWithNwGroupsCommand(getType(), id, newStates, nwGrpStates);