/** * Sets the RPC response, and unblocks all threads waiting on {@link #get()} * or {@link #get(long, TimeUnit)}. * @param result the RPC result to set. */ @Override public void handleResult(T result) { this.result = result; latch.countDown(); if (chainedCallback != null) { chainedCallback.handleResult(result); } }
@Override public void onNext(Object value) { if (value instanceof Throwable) { callback.handleError((Throwable) value); } else { callback.handleResult((T) value); } }
@Override public void messageReceived(ChannelHandlerContext ctx, final MessageEvent e) { NettyDataPack dataPack = (NettyDataPack)e.getMessage(); Callback<List<ByteBuffer>> callback = requests.get(dataPack.getSerial()); if (callback==null) { throw new RuntimeException("Missing previous call info"); } try { callback.handleResult(dataPack.getDatas()); } finally { requests.remove(dataPack.getSerial()); } }
/** * Called by {@link Requestor#request(String,Object,Callback)} for two-way messages using callbacks. */ public void transceive(List<ByteBuffer> request, Callback<List<ByteBuffer>> callback) throws IOException { // The default implementation works synchronously try { List<ByteBuffer> response = transceive(request); callback.handleResult(response); } catch (IOException e) { callback.handleError(e); } }
callback.handleResult((T)responseObject);
t.writeBuffers(request.getBytes()); if (callback != null) { callback.handleResult(null);
/** * Sets the RPC response, and unblocks all threads waiting on {@link #get()} * or {@link #get(long, TimeUnit)}. * @param result the RPC result to set. */ @Override public void handleResult(T result) { this.result = result; latch.countDown(); if (chainedCallback != null) { chainedCallback.handleResult(result); } }
@Override public void messageReceived(ChannelHandlerContext ctx, final MessageEvent e) { NettyDataPack dataPack = (NettyDataPack)e.getMessage(); Callback<List<ByteBuffer>> callback = requests.get(dataPack.getSerial()); if (callback==null) { throw new RuntimeException("Missing previous call info"); } try { callback.handleResult(dataPack.getDatas()); } finally { requests.remove(dataPack.getSerial()); } }
/** * Called by {@link Requestor#request(String,Object,Callback)} for two-way messages using callbacks. */ public void transceive(List<ByteBuffer> request, Callback<List<ByteBuffer>> callback) throws IOException { // The default implementation works synchronously try { List<ByteBuffer> response = transceive(request); callback.handleResult(response); } catch (IOException e) { callback.handleError(e); } }
callback.handleResult((T)responseObject);
t.writeBuffers(request.getBytes()); if (callback != null) { callback.handleResult(null);