You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2017/12/19 05:43:11 UTC
[cloudstack] 04/20: CLOUDSTACK-7853: Fix ping timeout edge case and
refactor code
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch debian9-systemvmtemplate
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit b882f6c7bf96fe42353d0ae209a7a331d772fd66
Author: Rohit Yadav <ro...@shapeblue.com>
AuthorDate: Sat Dec 2 15:50:34 2017 +0530
CLOUDSTACK-7853: Fix ping timeout edge case and refactor code
Refresh InaccurateClock every 10seconds, refactor code to get ping timeout
and ping interval.
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
---
.../src/com/cloud/agent/manager/AgentManagerImpl.java | 16 ++++++++--------
.../main/java/com/cloud/utils/time/InaccurateClock.java | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
index 325f3ec..7815c76 100644
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -213,7 +213,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
_nodeId = ManagementServerNode.getManagementServerId();
s_logger.info("Configuring AgentManagerImpl. management server node id(msid): " + _nodeId);
- final long lastPing = (System.currentTimeMillis() >> 10) - (long) (PingTimeout.value() * PingInterval.value());
+ final long lastPing = (System.currentTimeMillis() >> 10) - getTimeout();
_hostDao.markHostsAsDisconnected(_nodeId, lastPing);
registerForHostEvents(new BehindOnPingListener(), true, true, false);
@@ -241,8 +241,12 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
return true;
}
+ protected int getPingInterval() {
+ return PingInterval.value();
+ }
+
protected long getTimeout() {
- return (long) (PingTimeout.value() * PingInterval.value());
+ return (long) (Math.ceil(PingTimeout.value() * PingInterval.value()));
}
@Override
@@ -358,10 +362,6 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
return null;
}
- protected int getPingInterval() {
- return PingInterval.value();
- }
-
@Override
public Answer send(final Long hostId, final Command cmd) throws AgentUnavailableException, OperationTimedoutException {
final Commands cmds = new Commands(Command.OnError.Stop);
@@ -623,7 +623,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
}
}
- _monitorExecutor.scheduleWithFixedDelay(new MonitorTask(), PingInterval.value(), PingInterval.value(), TimeUnit.SECONDS);
+ _monitorExecutor.scheduleWithFixedDelay(new MonitorTask(), getPingInterval(), getPingInterval(), TimeUnit.SECONDS);
return true;
}
@@ -1515,7 +1515,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
attache = createAttacheForDirectConnect(host, resource);
final StartupAnswer[] answers = new StartupAnswer[cmds.length];
for (int i = 0; i < answers.length; i++) {
- answers[i] = new StartupAnswer(cmds[i], attache.getId(), PingInterval.value());
+ answers[i] = new StartupAnswer(cmds[i], attache.getId(), getPingInterval());
}
attache.process(answers);
diff --git a/utils/src/main/java/com/cloud/utils/time/InaccurateClock.java b/utils/src/main/java/com/cloud/utils/time/InaccurateClock.java
index 2a22853..e03231d 100644
--- a/utils/src/main/java/com/cloud/utils/time/InaccurateClock.java
+++ b/utils/src/main/java/com/cloud/utils/time/InaccurateClock.java
@@ -63,7 +63,7 @@ public class InaccurateClock extends StandardMBean implements InaccurateClockMBe
public synchronized String restart() {
turnOff();
s_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("InaccurateClock"));
- s_executor.scheduleAtFixedRate(new SetTimeTask(), 0, 60, TimeUnit.SECONDS);
+ s_executor.scheduleAtFixedRate(new SetTimeTask(), 0, 10, TimeUnit.SECONDS);
return "Restarted";
}
--
To stop receiving notification emails like this one, please contact
"commits@cloudstack.apache.org" <co...@cloudstack.apache.org>.