Search in sources :

Example 1 with TransferAgentCommand

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

the class ClusteredAgentManagerImpl method sendRebalanceCommand.

private Answer[] sendRebalanceCommand(final long peer, final long agentId, final long currentOwnerId, final long futureOwnerId, final Event event) {
    final TransferAgentCommand transfer = new TransferAgentCommand(agentId, currentOwnerId, futureOwnerId, event);
    final Commands commands = new Commands(Command.OnError.Stop);
    commands.addCommand(transfer);
    final Command[] cmds = commands.toCommands();
    try {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Forwarding " + cmds[0].toString() + " to " + peer);
        }
        final String peerName = Long.toString(peer);
        final String cmdStr = _gson.toJson(cmds);
        final String ansStr = _clusterMgr.execute(peerName, agentId, cmdStr, true);
        final Answer[] answers = _gson.fromJson(ansStr, Answer[].class);
        return answers;
    } catch (final Exception e) {
        s_logger.warn("Caught exception while talking to " + currentOwnerId, e);
        return null;
    }
}
Also used : TransferAgentCommand(com.cloud.agent.api.TransferAgentCommand) 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) TaskExecutionException(com.cloud.utils.exception.TaskExecutionException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) UnsupportedVersionException(com.cloud.exception.UnsupportedVersionException)

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 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)1 UnsupportedVersionException (com.cloud.exception.UnsupportedVersionException)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 TaskExecutionException (com.cloud.utils.exception.TaskExecutionException)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 ConfigurationException (javax.naming.ConfigurationException)1