cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ro...@apache.org
Subject [cloudstack] 04/34: CLOUDSTACK-7853: Fix ping timeout edge case and refactor code
Date Sat, 16 Dec 2017 06:45:57 GMT
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 86c21bade1c01a748ee77687f8e0a6375c879209
Author: Rohit Yadav <rohit.yadav@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 <rohit.yadav@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" <commits@cloudstack.apache.org>.

Mime
View raw message