From a560d6f0558c534eefacbe5618d43e0a9c068ff1 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Tue, 29 Nov 2011 11:23:21 +0530 Subject: [PATCH] bug 11910: no need to do full sync as first thing after connect --- .../com/cloud/agent/api/ClusterSyncAnswer.java | 10 ---------- .../com/cloud/agent/api/ClusterSyncCommand.java | 6 +++--- .../xen/resource/CitrixResourceBase.java | 5 ++--- .../com/cloud/vm/VirtualMachineManagerImpl.java | 15 ++++++--------- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/api/src/com/cloud/agent/api/ClusterSyncAnswer.java b/api/src/com/cloud/agent/api/ClusterSyncAnswer.java index d82701edcda..6da1aff460c 100644 --- a/api/src/com/cloud/agent/api/ClusterSyncAnswer.java +++ b/api/src/com/cloud/agent/api/ClusterSyncAnswer.java @@ -27,8 +27,6 @@ public class ClusterSyncAnswer extends Answer { private HashMap> _newStates; private HashMap> _allStates; private int _type = -1; // 0 for full, 1 for delta - private boolean isExecuted=false; // this is to avoid double execution first time, due to framework ??? - public static final int FULL_SYNC=0; public static final int DELTA_SYNC=1; @@ -75,12 +73,4 @@ public class ClusterSyncAnswer extends Answer { public boolean isDelta(){ return _type==1; } - - public boolean execute(){ - return !isExecuted; - } - - public void setExecuted(){ - isExecuted = true; - } } \ No newline at end of file diff --git a/api/src/com/cloud/agent/api/ClusterSyncCommand.java b/api/src/com/cloud/agent/api/ClusterSyncCommand.java index 0344e29f8e7..8198426bc5e 100644 --- a/api/src/com/cloud/agent/api/ClusterSyncCommand.java +++ b/api/src/com/cloud/agent/api/ClusterSyncCommand.java @@ -46,11 +46,11 @@ public class ClusterSyncCommand extends Command implements CronCommand { public void incrStep(){ _steps++; - if (_steps>=_skipSteps)_steps=0; + if (_steps>_skipSteps)_steps=0; } - public boolean isRightStep(){ - return (_steps==0); + public boolean isRightStep(){ + return (_steps==_skipSteps); } public long getClusterId() { diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 2dca4046082..e31cc7e5953 100755 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -6574,19 +6574,18 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe if (!_host.uuid.equals(hostr.uuid)) { return new ClusterSyncAnswer(cmd.getClusterId()); } - } catch (Exception e) { + } catch (Throwable e) { s_logger.warn("Check for master failed, failing the Cluster sync command"); return new ClusterSyncAnswer(cmd.getClusterId()); } HashMap> newStates = deltaClusterSync(conn); + cmd.incrStep(); if (cmd.isRightStep()){ // do full sync HashMap> allStates=fullClusterSync(conn); - cmd.incrStep(); return new ClusterSyncAnswer(cmd.getClusterId(), newStates, allStates); } else { - cmd.incrStep(); return new ClusterSyncAnswer(cmd.getClusterId(), newStates); } } diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 773e4a7415b..5414dea5f02 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -2044,15 +2044,12 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene for (final Answer answer : answers) { if (answer instanceof ClusterSyncAnswer) { ClusterSyncAnswer hs = (ClusterSyncAnswer) answer; - if (hs.execute()){ - if (hs.isFull()) { - deltaSync(hs.getNewStates()); - fullSync(hs.getClusterId(), hs.getAllStates()); - } else if (hs.isDelta()){ - deltaSync(hs.getNewStates()); - } + if (hs.isFull()) { + deltaSync(hs.getNewStates()); + fullSync(hs.getClusterId(), hs.getAllStates()); + } else if (hs.isDelta()){ + deltaSync(hs.getNewStates()); } - hs.setExecuted(); } else if (!answer.getResult()) { s_logger.warn("Cleanup failed due to " + answer.getDetails()); } else { @@ -2126,7 +2123,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene long agentId = agent.getId(); if (agent.getHypervisorType() == HypervisorType.XenServer) { // only for Xen ClusterSyncCommand syncCmd = new ClusterSyncCommand(Integer.parseInt(Config.ClusterDeltaSyncInterval.getDefaultValue()), - Integer.parseInt(Config.ClusterFullSyncSkipSteps.getDefaultValue()), clusterId); + Integer.parseInt(Config.ClusterFullSyncSkipSteps.getDefaultValue()), clusterId); try { long seq_no = _agentMgr.send(agentId, new Commands(syncCmd), this); s_logger.debug("Cluster VM sync started with jobid " + seq_no);