@@ -213,7 +213,7 @@ public boolean configure(final String name, final Map<String, Object> params) th
213213 _nodeId = ManagementServerNode .getManagementServerId ();
214214 s_logger .info ("Configuring AgentManagerImpl. management server node id(msid): " + _nodeId );
215215
216- final long lastPing = (System .currentTimeMillis () >> 10 ) - ( long ) ( PingTimeout . value () * PingInterval . value () );
216+ final long lastPing = (System .currentTimeMillis () >> 10 ) - getTimeout ( );
217217 _hostDao .markHostsAsDisconnected (_nodeId , lastPing );
218218
219219 registerForHostEvents (new BehindOnPingListener (), true , true , false );
@@ -241,8 +241,12 @@ public boolean configure(final String name, final Map<String, Object> params) th
241241 return true ;
242242 }
243243
244+ protected int getPingInterval () {
245+ return PingInterval .value ();
246+ }
247+
244248 protected long getTimeout () {
245- return (long ) (PingTimeout .value () * PingInterval .value ());
249+ return (long ) (Math . ceil ( PingTimeout .value () * PingInterval .value () ));
246250 }
247251
248252 @ Override
@@ -358,10 +362,6 @@ public Answer sendTo(final Long dcId, final HypervisorType type, final Command c
358362 return null ;
359363 }
360364
361- protected int getPingInterval () {
362- return PingInterval .value ();
363- }
364-
365365 @ Override
366366 public Answer send (final Long hostId , final Command cmd ) throws AgentUnavailableException , OperationTimedoutException {
367367 final Commands cmds = new Commands (Command .OnError .Stop );
@@ -623,7 +623,7 @@ public boolean start() {
623623 }
624624 }
625625
626- _monitorExecutor .scheduleWithFixedDelay (new MonitorTask (), PingInterval . value (), PingInterval . value (), TimeUnit .SECONDS );
626+ _monitorExecutor .scheduleWithFixedDelay (new MonitorTask (), getPingInterval (), getPingInterval (), TimeUnit .SECONDS );
627627
628628 return true ;
629629 }
@@ -1515,7 +1515,7 @@ public boolean handleDirectConnectAgent(final Host host, final StartupCommand[]
15151515 attache = createAttacheForDirectConnect (host , resource );
15161516 final StartupAnswer [] answers = new StartupAnswer [cmds .length ];
15171517 for (int i = 0 ; i < answers .length ; i ++) {
1518- answers [i ] = new StartupAnswer (cmds [i ], attache .getId (), PingInterval . value ());
1518+ answers [i ] = new StartupAnswer (cmds [i ], attache .getId (), getPingInterval ());
15191519 }
15201520 attache .process (answers );
15211521
0 commit comments