Search in sources :

Example 1 with ChangeAgentCommand

use of com.cloud.agent.api.ChangeAgentCommand in project cloudstack by apache.

the class ClusteredAgentManagerImpl method propagateAgentEvent.

public Boolean propagateAgentEvent(final long agentId, final Event event) throws AgentUnavailableException {
    final String msPeer = getPeerName(agentId);
    if (msPeer == null) {
        return null;
    }
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Propagating agent change request event:" + event.toString() + " to agent:" + agentId);
    }
    final Command[] cmds = new Command[1];
    cmds[0] = new ChangeAgentCommand(agentId, event);
    final String ansStr = _clusterMgr.execute(msPeer, agentId, _gson.toJson(cmds), true);
    if (ansStr == null) {
        throw new AgentUnavailableException(agentId);
    }
    final Answer[] answers = _gson.fromJson(ansStr, Answer[].class);
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Result for agent change is " + answers[0].getResult());
    }
    return answers[0].getResult();
}
Also used : ChangeAgentAnswer(com.cloud.agent.api.ChangeAgentAnswer) Answer(com.cloud.agent.api.Answer) CancelCommand(com.cloud.agent.api.CancelCommand) PropagateResourceEventCommand(com.cloud.agent.api.PropagateResourceEventCommand) ScheduleHostScanTaskCommand(com.cloud.agent.api.ScheduleHostScanTaskCommand) TransferAgentCommand(com.cloud.agent.api.TransferAgentCommand) ChangeAgentCommand(com.cloud.agent.api.ChangeAgentCommand) Command(com.cloud.agent.api.Command) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) ChangeAgentCommand(com.cloud.agent.api.ChangeAgentCommand)

Aggregations

Answer (com.cloud.agent.api.Answer)1 CancelCommand (com.cloud.agent.api.CancelCommand)1 ChangeAgentAnswer (com.cloud.agent.api.ChangeAgentAnswer)1 ChangeAgentCommand (com.cloud.agent.api.ChangeAgentCommand)1 Command (com.cloud.agent.api.Command)1 PropagateResourceEventCommand (com.cloud.agent.api.PropagateResourceEventCommand)1 ScheduleHostScanTaskCommand (com.cloud.agent.api.ScheduleHostScanTaskCommand)1 TransferAgentCommand (com.cloud.agent.api.TransferAgentCommand)1 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1