Repository: cloudstack Updated Branches: refs/heads/4.4 d04f59a30 -> a29f954a2
CLOUDSTACK-7184 retry-wait loop config to deal with network glitches Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a29f954a Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a29f954a Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a29f954a Branch: refs/heads/4.4 Commit: a29f954a269c992307f0410df88ca4ac7a0b82a0 Parents: d04f59a Author: Daan Hoogland <d...@onecht.net> Authored: Tue Sep 16 12:20:30 2014 +0200 Committer: Daan Hoogland <d...@onecht.net> Committed: Thu Sep 18 08:55:23 2014 +0200 ---------------------------------------------------------------------- .../cloud/agent/manager/DirectAgentAttache.java | 20 +++++++++++++++++--- .../xen/resource/CitrixResourceBase.java | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a29f954a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java index 7ca6929..2039a96 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.apache.log4j.Logger; +import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.managed.context.ManagedContextRunnable; import com.cloud.agent.api.Answer; @@ -40,6 +41,10 @@ import com.cloud.resource.ServerResource; public class DirectAgentAttache extends AgentAttache { private final static Logger s_logger = Logger.getLogger(DirectAgentAttache.class); + protected final ConfigKey<Integer> _HostPingRetryCount = new ConfigKey<Integer>("Advanced", Integer.class, "host.ping.retry.count", "0", + "Number of times retrying a host ping while waiting for check results", true); + protected final ConfigKey<Integer> _HostPingRetryTimer = new ConfigKey<Integer>("Advanced", Integer.class, "host.ping.retry.timer", "5", + "Interval to wait before retrying a host ping while waiting for check results", true); ServerResource _resource; List<ScheduledFuture<?>> _futures = new ArrayList<ScheduledFuture<?>>(); AgentManagerImpl _mgr; @@ -96,7 +101,7 @@ public class DirectAgentAttache extends AgentAttache { if (answers != null && answers[0] instanceof StartupAnswer) { StartupAnswer startup = (StartupAnswer)answers[0]; int interval = startup.getPingInterval(); - _futures.add(_agentMgr.getCronJobPool().scheduleAtFixedRate(new PingTask(), interval, interval, TimeUnit.SECONDS)); + _futures.add(_agentMgr.getCronJobPool().scheduleAtFixedRate(producePingTask(), interval, interval, TimeUnit.SECONDS)); } } else { Command[] cmds = req.getCommands(); @@ -116,7 +121,7 @@ public class DirectAgentAttache extends AgentAttache { StartupAnswer startup = (StartupAnswer)answers[0]; int interval = startup.getPingInterval(); s_logger.info("StartupAnswer received " + startup.getHostId() + " Interval = " + interval); - _futures.add(_agentMgr.getCronJobPool().scheduleAtFixedRate(new PingTask(), interval, interval, TimeUnit.SECONDS)); + _futures.add(_agentMgr.getCronJobPool().scheduleAtFixedRate(producePingTask(), interval, interval, TimeUnit.SECONDS)); } } @@ -149,6 +154,9 @@ public class DirectAgentAttache extends AgentAttache { } } + PingTask producePingTask() { + return new PingTask(); + } protected class PingTask extends ManagedContextRunnable { @Override protected synchronized void runInContext() { @@ -161,7 +169,13 @@ public class DirectAgentAttache extends AgentAttache { ServerResource resource = _resource; if (resource != null) { - PingCommand cmd = resource.getCurrentStatus(_id); + PingCommand cmd = null; + int retried = 0; + while ( cmd == null && ++retried < _HostPingRetryCount.value()) + { + cmd = resource.getCurrentStatus(_id); + Thread.sleep(1000*_HostPingRetryTimer.value()); + } if (cmd == null) { s_logger.warn("Unable to get current status on " + _id + "(" + _name + ")"); return; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a29f954a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 644ef65..a399c98 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -4276,7 +4276,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe if (!pingXAPI()) { Thread.sleep(1000); if (!pingXAPI()) { - s_logger.warn(" can not ping xenserver " + _host.uuid); + s_logger.warn("can not ping xenserver " + _host.uuid); return null; } }