use of com.cloud.agent.api.StartupAnswer in project cloudstack by apache.
the class DirectAgentAttache method send.
@Override
public void send(Request req) throws AgentUnavailableException {
req.logD("Executing: ", true);
if (req instanceof Response) {
Response resp = (Response) req;
Answer[] answers = resp.getAnswers();
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));
}
} else {
Command[] cmds = req.getCommands();
if (cmds.length > 0 && !(cmds[0] instanceof CronCommand)) {
queueTask(new Task(req));
scheduleFromQueue();
} else {
CronCommand cmd = (CronCommand) cmds[0];
_futures.add(_agentMgr.getCronJobPool().scheduleAtFixedRate(new CronTask(req), cmd.getInterval(), cmd.getInterval(), TimeUnit.SECONDS));
}
}
}
Aggregations