diff --git a/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java b/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java index 2a35b55ca96..df30b47737b 100644 --- a/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java +++ b/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java @@ -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 _vms = new HashMap(20); + protected Map _vms = new HashMap(); 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 newStates = sync(); HashMap> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid); return new PingRoutingWithNwGroupsCommand(getType(), id, newStates, nwGrpStates);