use of org.opendaylight.mdsal.dom.api.DefaultDOMRpcException in project netconf by opendaylight.
the class NetconfDeviceRpc method invokeRpc.
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public ListenableFuture<DOMRpcResult> invokeRpc(final QName type, final NormalizedNode input) {
final ListenableFuture<RpcResult<NetconfMessage>> delegateFuture = communicator.sendRequest(transformer.toRpcRequest(type, input), type);
final SettableFuture<DOMRpcResult> ret = SettableFuture.create();
Futures.addCallback(delegateFuture, new FutureCallback<RpcResult<NetconfMessage>>() {
@Override
public void onSuccess(final RpcResult<NetconfMessage> result) {
try {
ret.set(result.isSuccessful() ? transformer.toRpcResult(result.getResult(), type) : new DefaultDOMRpcResult(result.getErrors()));
} catch (Exception cause) {
ret.setException(new DefaultDOMRpcException("Unable to parse rpc reply. type: " + type + " input: " + input, cause));
}
}
@Override
public void onFailure(final Throwable cause) {
ret.setException(new DOMRpcImplementationNotAvailableException(cause, "Unable to invoke rpc %s", type));
}
}, MoreExecutors.directExecutor());
return ret;
}
Aggregations