@Override public <T> void request(String messageName, Object request, Callback<T> callback) throws IOException { try { super.request(messageName, request, callback); } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException)e; if (e instanceof IOException) throw (IOException)e; throw new AvroRemoteException(e); } }
@Override public Object request(String messageName, Object request) throws IOException { try { return super.request(messageName, request); } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException)e; if (e instanceof IOException) throw (IOException)e; throw new AvroRemoteException(e); } }
/** * Writes a request message and returns the result through a Callback. * Clients can also use a Future interface by creating a new CallFuture<T>, * passing it in as the Callback parameter, and then waiting on that Future. * @param <T> the return type of the message. * @param messageName the name of the message to invoke. * @param request the request data to send. * @param callback the callback which will be invoked when the response is returned * or an error occurs. * @throws Exception if an error occurs sending the message. */ public <T> void request(String messageName, Object request, Callback<T> callback) throws Exception { request(new Request(messageName, request, new RPCContext()), callback); }
/** Writes a request message and reads a response or error message. */ public Object request(String messageName, Object request) throws Exception { // Initialize request Request rpcRequest = new Request(messageName, request, new RPCContext()); CallFuture<Object> future = /* only need a Future for two-way messages */ rpcRequest.getMessage().isOneWay() ? null : new CallFuture<>(); // Send request request(rpcRequest, future); if (future == null) // the message is one-way, so return immediately return null; try { // the message is two-way, wait for the result return future.get(); } catch (ExecutionException e) { if (e.getCause() instanceof Exception) { throw (Exception)e.getCause(); } else { throw new AvroRemoteException(e.getCause()); } } }
@Override public <T> void request(String messageName, Object request, Callback<T> callback) throws IOException { try { super.request(messageName, request, callback); } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException)e; if (e instanceof IOException) throw (IOException)e; throw new AvroRemoteException(e); } }
@Override public Object request(String messageName, Object request) throws IOException { try { return super.request(messageName, request); } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException)e; if (e instanceof IOException) throw (IOException)e; throw new AvroRemoteException(e); } }
@Override public Object request(String messageName, Object request) throws IOException { try { return super.request(messageName, request); } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException)e; if (e instanceof IOException) throw (IOException)e; throw new AvroRemoteException(e); } }
@Override public Object request(String messageName, Object request) throws IOException { try { return super.request(messageName, request); } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException)e; if (e instanceof IOException) throw (IOException)e; throw new AvroRemoteException(e); } }
/** * Writes a request message and returns the result through a Callback. * Clients can also use a Future interface by creating a new CallFuture<T>, * passing it in as the Callback parameter, and then waiting on that Future. * @param <T> the return type of the message. * @param messageName the name of the message to invoke. * @param request the request data to send. * @param callback the callback which will be invoked when the response is returned * or an error occurs. * @throws Exception if an error occurs sending the message. */ public <T> void request(String messageName, Object request, Callback<T> callback) throws Exception { request(new Request(messageName, request, new RPCContext()), callback); }
/** Writes a request message and reads a response or error message. */ public Object request(String messageName, Object request) throws Exception { // Initialize request Request rpcRequest = new Request(messageName, request, new RPCContext()); CallFuture<Object> future = /* only need a Future for two-way messages */ rpcRequest.getMessage().isOneWay() ? null : new CallFuture<Object>(); // Send request request(rpcRequest, future); if (future == null) // the message is one-way, so return immediately return null; try { // the message is two-way, wait for the result return future.get(); } catch (ExecutionException e) { if (e.getCause() instanceof Exception) { throw (Exception)e.getCause(); } else { throw new AvroRemoteException(e.getCause()); } } }