import java.util.Arrays;
import java.util.Collection;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
-import org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeSerializer;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node;
import org.opendaylight.controller.remote.rpc.messages.ExecuteRpc;
import org.opendaylight.controller.remote.rpc.messages.RpcResponse;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Actor to initiate execution of remote RPC on other nodes of the cluster.
*/
public class RpcBroker extends AbstractUntypedActor {
-
- private static final Logger LOG = LoggerFactory.getLogger(RpcBroker.class);
private final DOMRpcService rpcService;
private RpcBroker(final DOMRpcService rpcService) {
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void executeRpc(final ExecuteRpc msg) {
LOG.debug("Executing rpc {}", msg.getRpc());
final NormalizedNode<?, ?> input = RemoteRpcInput.from(msg.getInputNormalizedNode());
Futures.addCallback(future, new FutureCallback<DOMRpcResult>() {
@Override
public void onSuccess(final DOMRpcResult result) {
- if (result.getErrors() != null && (!result.getErrors().isEmpty())) {
+ if (result.getErrors() != null && !result.getErrors().isEmpty()) {
final String message = String.format("Execution of RPC %s failed", msg.getRpc());
Collection<RpcError> errors = result.getErrors();
if (errors == null || errors.size() == 0) {
sender.tell(new akka.actor.Status.Failure(new RpcErrorsException(message, errors)), self);
} else {
- final Node serializedResultNode;
- if (result.getResult() == null) {
- serializedResultNode = null;
- } else {
- serializedResultNode = NormalizedNodeSerializer.serialize(result.getResult());
- }
-
LOG.debug("Sending response for execute rpc : {}", msg.getRpc());
- sender.tell(new RpcResponse(serializedResultNode), self);
+ sender.tell(new RpcResponse(result.getResult()), self);
}
}
@Override
- public void onFailure(final Throwable t) {
- LOG.error("executeRpc for {} failed with root cause: {}. For exception details, enable Debug logging.",
- msg.getRpc(), Throwables.getRootCause(t));
- if(LOG.isDebugEnabled()) {
- LOG.debug("Detailed exception for execute RPC failure :{}", t);
+ public void onFailure(final Throwable failure) {
+ LOG.error(
+ "executeRpc for {} failed with root cause: {}. For exception details, enable Debug logging.",
+ msg.getRpc(), Throwables.getRootCause(failure));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Detailed exception for execute RPC failure :{}", failure);
}
- sender.tell(new akka.actor.Status.Failure(t), self);
+ sender.tell(new akka.actor.Status.Failure(failure), self);
}
});
- } catch (final Exception e) {
+ } catch (final RuntimeException e) {
sender.tell(new akka.actor.Status.Failure(e), sender);
}
}