mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
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>
This commit is contained in:
parent
bb965649d9
commit
893f2af31f
@ -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);
|
||||
|
||||
|
||||
@ -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";
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user