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;
}
}
Aggregations