Search in sources :

Example 1 with TransferAgentCommand

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

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 = this._gson.toJson(cmds);
        final String ansStr = this._clusterMgr.execute(peerName, agentId, cmdStr, true);
        final Answer[] answers = this._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.legacymodel.communication.command.TransferAgentCommand) 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) UnsupportedVersionException(com.cloud.legacymodel.exceptions.UnsupportedVersionException) AgentUnavailableException(com.cloud.legacymodel.exceptions.AgentUnavailableException) ConfigurationException(javax.naming.ConfigurationException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) OperationTimedoutException(com.cloud.legacymodel.exceptions.OperationTimedoutException) TaskExecutionException(com.cloud.legacymodel.exceptions.TaskExecutionException) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException)

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