Search in sources :

Example 6 with StartupAnswer

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));
        }
    }
}
Also used : Response(com.cloud.agent.transport.Response) StartupAnswer(com.cloud.agent.api.StartupAnswer) StartupAnswer(com.cloud.agent.api.StartupAnswer) Answer(com.cloud.agent.api.Answer) Command(com.cloud.agent.api.Command) PingCommand(com.cloud.agent.api.PingCommand) CronCommand(com.cloud.agent.api.CronCommand) CronCommand(com.cloud.agent.api.CronCommand)

Aggregations

StartupAnswer (com.cloud.agent.api.StartupAnswer)6 Command (com.cloud.agent.api.Command)2 PingCommand (com.cloud.agent.api.PingCommand)2 Response (com.cloud.agent.transport.Response)2 AgentControlCommand (com.cloud.agent.api.AgentControlCommand)1 Answer (com.cloud.agent.api.Answer)1 CheckHealthCommand (com.cloud.agent.api.CheckHealthCommand)1 CronCommand (com.cloud.agent.api.CronCommand)1 PingRoutingCommand (com.cloud.agent.api.PingRoutingCommand)1 ReadyCommand (com.cloud.agent.api.ReadyCommand)1 SetHostParamsCommand (com.cloud.agent.api.SetHostParamsCommand)1 ShutdownCommand (com.cloud.agent.api.ShutdownCommand)1 StartupCommand (com.cloud.agent.api.StartupCommand)1 StartupProxyCommand (com.cloud.agent.api.StartupProxyCommand)1 StartupRoutingCommand (com.cloud.agent.api.StartupRoutingCommand)1 StartupSecondaryStorageCommand (com.cloud.agent.api.StartupSecondaryStorageCommand)1 StartupStorageCommand (com.cloud.agent.api.StartupStorageCommand)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1