From 1ea9b5d7035bcc8adaaeb7f752747d065e9c2468 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Thu, 20 Oct 2011 10:51:40 +0530 Subject: [PATCH] bug 10588: putting config param for cluster sync intervals --- api/src/com/cloud/agent/api/ClusterSyncAnswer.java | 14 +++++++++++--- .../xen/resource/CitrixResourceBase.java | 4 ++-- server/src/com/cloud/configuration/Config.java | 2 ++ .../com/cloud/vm/VirtualMachineManagerImpl.java | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/api/src/com/cloud/agent/api/ClusterSyncAnswer.java b/api/src/com/cloud/agent/api/ClusterSyncAnswer.java index dc4cc1edbf7..ac4434d3152 100644 --- a/api/src/com/cloud/agent/api/ClusterSyncAnswer.java +++ b/api/src/com/cloud/agent/api/ClusterSyncAnswer.java @@ -24,13 +24,17 @@ import com.cloud.vm.VirtualMachine.State; public class ClusterSyncAnswer extends Answer { long _clusterId; - private HashMap> _newStates; - private int _type = -1; // 0 for full, 1 for delta + HashMap> _newStates; + int _type = -1; // 0 for full, 1 for delta public static final int FULL_SYNC=0; public static final int DELTA_SYNC=1; - public ClusterSyncAnswer() { + public ClusterSyncAnswer(long clusterId) { + _clusterId = clusterId; + result = false; + this.details = "Ignore sync as this is not a pool master"; + _type = -1; } public ClusterSyncAnswer(long clusterId, HashMap> newStates, int type){ @@ -51,4 +55,8 @@ public class ClusterSyncAnswer extends Answer { public boolean isFull(){ return _type==0; } + + public boolean isDelta(){ + return _type==1; + } } \ No newline at end of file diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 643c4edff3d..2633ed360da 100755 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -6610,11 +6610,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe Host.Record hostr = poolr.master.getRecord(conn); if (!_host.uuid.equals(hostr.uuid)) { s_logger.debug("Not the master node so just return ok: " + _host.ip); - return new Answer(cmd, false, "Not a pool master"); + return new ClusterSyncAnswer(cmd.getClusterId()); } } catch (Exception e) { s_logger.warn("Check for master failed, failing the Cluster sync command"); - return new Answer(cmd, false, "Not a pool master"); + return new ClusterSyncAnswer(cmd.getClusterId()); } HashMap> newStates; int sync_type; diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 8198525e609..57d88d1cf3e 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -146,6 +146,8 @@ public enum Config { MigrateRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "migrate.retry.interval", "120", "Time (in seconds) between migration retries", null), 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), 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 fa29ba46d61..4c87def3b0b 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -1943,7 +1943,8 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene long agentId = agent.getId(); Long clusterId = agent.getClusterId(); - ClusterSyncCommand syncCmd = new ClusterSyncCommand(60, 20, clusterId); + ClusterSyncCommand syncCmd = new ClusterSyncCommand(Integer.parseInt(Config.ClusterDeltaSyncInterval.getDefaultValue()), + 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);