/** * Stores an exception encountered during RPC invocation so it can be passed back through to the * client. * * @param controller the controller instance provided by the client when calling the service * @param ioe the exception encountered */ public static void setControllerException(RpcController controller, IOException ioe) { if (controller != null) { if (controller instanceof ServerRpcController) { ((ServerRpcController) controller).setFailedOn(ioe); } else { controller.setFailed(StringUtils.stringifyException(ioe)); } } }
public List<Result> call(IndexCoprocessorInMemService instance) throws IOException { ServerRpcController controller = new ServerRpcController(); BlockingRpcCallback<IndexedQueryResponse> rpcCallback = new BlockingRpcCallback<IndexedQueryResponse>(); instance.execIndexedQuery(controller, indexQuery, rpcCallback); IndexedQueryResponse response = rpcCallback.get(); if (controller.failedOnException()) { throw controller.getFailedOn(); } if (response.getResultCount() > 0) { List<ProtoResult> protoResultList = response.getResultList(); List<Result> result; // = new ArrayList<Result>(protoResultList.size()); result = Util.toResults(protoResultList); return result; } return new ArrayList<Result>(0); }