diff --git a/api/src/com/cloud/agent/api/ClusterSyncAnswer.java b/api/src/com/cloud/agent/api/ClusterSyncAnswer.java index d3ea9452016..d82701edcda 100644 --- a/api/src/com/cloud/agent/api/ClusterSyncAnswer.java +++ b/api/src/com/cloud/agent/api/ClusterSyncAnswer.java @@ -25,8 +25,9 @@ import com.cloud.vm.VirtualMachine.State; public class ClusterSyncAnswer extends Answer { private long _clusterId; private HashMap> _newStates; + private HashMap> _allStates; private int _type = -1; // 0 for full, 1 for delta - private boolean isExecuted=false; // this is to avoidf double execution first time, due to framework ??? + private boolean isExecuted=false; // this is to avoid double execution first time, due to framework ??? public static final int FULL_SYNC=0; @@ -39,10 +40,19 @@ public class ClusterSyncAnswer extends Answer { _type = -1; } - public ClusterSyncAnswer(long clusterId, HashMap> newStates, int type){ + + public ClusterSyncAnswer(long clusterId, HashMap> newStates){ _clusterId = clusterId; _newStates = newStates; - _type = type; + _type = DELTA_SYNC; + result = true; + } + + public ClusterSyncAnswer(long clusterId, HashMap> newStates, HashMap> allStates){ + _clusterId = clusterId; + _newStates = newStates; + _allStates = allStates; + _type = FULL_SYNC; result = true; } @@ -53,6 +63,10 @@ public class ClusterSyncAnswer extends Answer { public HashMap> getNewStates() { return _newStates; } + + public HashMap> getAllStates() { + return _allStates; + } public boolean isFull(){ return _type==0; diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 5e4437f1ff6..2dca4046082 100755 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -6578,23 +6578,17 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe s_logger.warn("Check for master failed, failing the Cluster sync command"); return new ClusterSyncAnswer(cmd.getClusterId()); } - HashMap> newStates; - int sync_type=-1; + HashMap> newStates = deltaClusterSync(conn); if (cmd.isRightStep()){ // do full sync - newStates=fullClusterSync(conn); - sync_type = ClusterSyncAnswer.FULL_SYNC; + HashMap> allStates=fullClusterSync(conn); + cmd.incrStep(); + return new ClusterSyncAnswer(cmd.getClusterId(), newStates, allStates); } else { - // do delta sync - newStates = deltaClusterSync(conn); - if (newStates == null) { - s_logger.warn("Unable to get current status from sync"); - } - sync_type = ClusterSyncAnswer.DELTA_SYNC; + cmd.incrStep(); + return new ClusterSyncAnswer(cmd.getClusterId(), newStates); } - cmd.incrStep(); - return new ClusterSyncAnswer(cmd.getClusterId(), newStates, sync_type); } diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index bfbb278d9c3..59df224c601 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -159,7 +159,7 @@ public enum Config { PingInterval("Advanced", AgentManager.class, Integer.class, "ping.interval", "60", "Ping interval in seconds", null), PingTimeout("Advanced", AgentManager.class, Float.class, "ping.timeout", "2.5", "Multiplier to ping.interval before announcing an agent has timed out", null), ClusterDeltaSyncInterval("Advanced", AgentManager.class, Integer.class, "sync.interval", "60", "Cluster Delta sync interval in seconds", null), - ClusterFullSyncSkipSteps("Advanced", AgentManager.class, Integer.class, "skip.steps", "30", "Cluster full sync skip steps count", null), + ClusterFullSyncSkipSteps("Advanced", AgentManager.class, Integer.class, "skip.steps", "60", "Cluster full sync skip steps count", null), Port("Advanced", AgentManager.class, Integer.class, "port", "8250", "Port to listen on for agent connection.", null), RouterCpuMHz("Advanced", NetworkManager.class, Integer.class, "router.cpu.mhz", String.valueOf(VirtualNetworkApplianceManager.DEFAULT_ROUTER_CPU_MHZ), "Default CPU speed (MHz) for router VM.", null), RestartRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "restart.retry.interval", "600", "Time (in seconds) between retries to restart a vm", null), diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 6363fbf9f71..d063b92fb4a 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -1703,7 +1703,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene } - public Commands fullSync(final long clusterId, Map> newStates) { Commands commands = new Commands(OnError.Continue); Map infos = convertToInfos(newStates); @@ -1711,30 +1710,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene final List vms = _vmDao.listByClusterId(clusterId); for (VMInstanceVO vm : vms) { AgentVmInfo info = infos.remove(vm.getId()); - VMInstanceVO castedVm = null; - if (info == null) { - // the vm is not there on cluster, check the vm status in DB - if (vm.getState() == State.Starting && (DateUtil.currentGMTTime().getTime() - vm.getUpdateTime().getTime()) < 10*60*1000){ - continue; // ignoring this VM as it is still settling - } - info = new AgentVmInfo(vm.getInstanceName(), getVmGuru(vm), vm, State.Stopped); - castedVm = info.guru.findById(vm.getId()); - hId = vm.getHostId() == null ? vm.getLastHostId() : vm.getHostId(); - } else { - castedVm = info.vm; - String hostGuid = info.getHostUuid(); - Host host = _resourceMgr.findHostByGuid(hostGuid); - if (host == null) { - infos.put(vm.getId(), info); - continue; - } - hId = host.getId(); - } - HypervisorGuru hvGuru = _hvGuruMgr.getGuru(castedVm.getHypervisorType()); - Command command = compareState(hId, castedVm, info, false, hvGuru.trackVmHostChange()); - if (command != null) { - commands.addCommand(command); - } } for (final AgentVmInfo left : infos.values()) { s_logger.warn("Stopping a VM that we have no record of: " + left.name); @@ -2072,7 +2047,8 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene ClusterSyncAnswer hs = (ClusterSyncAnswer) answer; if (hs.execute()){ if (hs.isFull()) { - fullSync(hs.getClusterId(), hs.getNewStates()); + deltaSync(hs.getNewStates()); + fullSync(hs.getClusterId(), hs.getAllStates()); } else if (hs.isDelta()){ deltaSync(hs.getNewStates()); } @@ -2149,7 +2125,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene Long clusterId = agent.getClusterId(); long agentId = agent.getId(); - if (agent.getHypervisorType() == HypervisorType.XenServer) { // only fro Xen + if (agent.getHypervisorType() == HypervisorType.XenServer) { // only for Xen ClusterSyncCommand syncCmd = new ClusterSyncCommand(Integer.parseInt(Config.ClusterDeltaSyncInterval.getDefaultValue()), Integer.parseInt(Config.ClusterFullSyncSkipSteps.getDefaultValue()), clusterId); try {