Search in sources :

Example 1 with ChangeAgentCommand

use of com.cloud.legacymodel.communication.command.ChangeAgentCommand in project cosmic by MissionCriticalCloud.

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 = this._clusterMgr.execute(msPeer, agentId, this._gson.toJson(cmds), true);
    if (ansStr == null) {
        throw new AgentUnavailableException(agentId);
    }
    final Answer[] answers = this._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 : Answer(com.cloud.legacymodel.communication.answer.Answer) ChangeAgentAnswer(com.cloud.legacymodel.communication.answer.ChangeAgentAnswer) ScheduleHostScanTaskCommand(com.cloud.legacymodel.communication.command.ScheduleHostScanTaskCommand) CancelCommand(com.cloud.legacymodel.communication.command.CancelCommand) Command(com.cloud.legacymodel.communication.command.Command) PropagateResourceEventCommand(com.cloud.legacymodel.communication.command.PropagateResourceEventCommand) TransferAgentCommand(com.cloud.legacymodel.communication.command.TransferAgentCommand) ChangeAgentCommand(com.cloud.legacymodel.communication.command.ChangeAgentCommand) AgentUnavailableException(com.cloud.legacymodel.exceptions.AgentUnavailableException) ChangeAgentCommand(com.cloud.legacymodel.communication.command.ChangeAgentCommand)

Aggregations

Answer (com.cloud.legacymodel.communication.answer.Answer)1 ChangeAgentAnswer (com.cloud.legacymodel.communication.answer.ChangeAgentAnswer)1 CancelCommand (com.cloud.legacymodel.communication.command.CancelCommand)1 ChangeAgentCommand (com.cloud.legacymodel.communication.command.ChangeAgentCommand)1 Command (com.cloud.legacymodel.communication.command.Command)1 PropagateResourceEventCommand (com.cloud.legacymodel.communication.command.PropagateResourceEventCommand)1 ScheduleHostScanTaskCommand (com.cloud.legacymodel.communication.command.ScheduleHostScanTaskCommand)1 TransferAgentCommand (com.cloud.legacymodel.communication.command.TransferAgentCommand)1 AgentUnavailableException (com.cloud.legacymodel.exceptions.AgentUnavailableException)1