private Map<byte [], String> hello(final Table table, final String send, final byte [] start, final byte [] end) throws ServiceException, Throwable { return table.coprocessorService(PingProtos.PingService.class, start, end, new Batch.Call<PingProtos.PingService, String>() { @Override public String call(PingProtos.PingService instance) throws IOException { BlockingRpcCallback<PingProtos.HelloResponse> rpcCallback = new BlockingRpcCallback<PingProtos.HelloResponse>(); PingProtos.HelloRequest.Builder builder = PingProtos.HelloRequest.newBuilder(); if (send != null) builder.setName(send); instance.hello(null, builder.build(), rpcCallback); PingProtos.HelloResponse r = rpcCallback.get(); return r != null && r.hasResponse()? r.getResponse(): null; } }); }
private Map<byte [], String> compoundOfHelloAndPing(final Table table, final byte [] start, final byte [] end) throws ServiceException, Throwable { return table.coprocessorService(PingProtos.PingService.class, start, end, new Batch.Call<PingProtos.PingService, String>() { @Override public String call(PingProtos.PingService instance) throws IOException { BlockingRpcCallback<PingProtos.HelloResponse> rpcCallback = new BlockingRpcCallback<PingProtos.HelloResponse>(); PingProtos.HelloRequest.Builder builder = PingProtos.HelloRequest.newBuilder(); // Call ping on same instance. Use result calling hello on same instance. builder.setName(doPing(instance)); instance.hello(null, builder.build(), rpcCallback); PingProtos.HelloResponse r = rpcCallback.get(); return r != null && r.hasResponse()? r.getResponse(): null; } }); }
private Map<byte [], String> hello(final HTable table, final String send, final byte [] start, final byte [] end) throws ServiceException, Throwable { return table.coprocessorService(PingProtos.PingService.class, start, end, new Batch.Call<PingProtos.PingService, String>() { @Override public String call(PingProtos.PingService instance) throws IOException { BlockingRpcCallback<PingProtos.HelloResponse> rpcCallback = new BlockingRpcCallback<PingProtos.HelloResponse>(); PingProtos.HelloRequest.Builder builder = PingProtos.HelloRequest.newBuilder(); if (send != null) builder.setName(send); instance.hello(null, builder.build(), rpcCallback); PingProtos.HelloResponse r = rpcCallback.get(); return r != null && r.hasResponse()? r.getResponse(): null; } }); }
private Map<byte [], String> compoundOfHelloAndPing(final HTable table, final byte [] start, final byte [] end) throws ServiceException, Throwable { return table.coprocessorService(PingProtos.PingService.class, start, end, new Batch.Call<PingProtos.PingService, String>() { @Override public String call(PingProtos.PingService instance) throws IOException { BlockingRpcCallback<PingProtos.HelloResponse> rpcCallback = new BlockingRpcCallback<PingProtos.HelloResponse>(); PingProtos.HelloRequest.Builder builder = PingProtos.HelloRequest.newBuilder(); // Call ping on same instance. Use result calling hello on same instance. builder.setName(doPing(instance)); instance.hello(null, builder.build(), rpcCallback); PingProtos.HelloResponse r = rpcCallback.get(); return r != null && r.hasResponse()? r.getResponse(): null; } }); }
private Map<byte [], String> hello(final Table table, final String send, final byte [] start, final byte [] end) throws ServiceException, Throwable { return table.coprocessorService(PingProtos.PingService.class, start, end, new Batch.Call<PingProtos.PingService, String>() { @Override public String call(PingProtos.PingService instance) throws IOException { CoprocessorRpcUtils.BlockingRpcCallback<PingProtos.HelloResponse> rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>(); PingProtos.HelloRequest.Builder builder = PingProtos.HelloRequest.newBuilder(); if (send != null) builder.setName(send); instance.hello(null, builder.build(), rpcCallback); PingProtos.HelloResponse r = rpcCallback.get(); return r != null && r.hasResponse()? r.getResponse(): null; } }); }
private Map<byte [], String> compoundOfHelloAndPing(final Table table, final byte [] start, final byte [] end) throws ServiceException, Throwable { return table.coprocessorService(PingProtos.PingService.class, start, end, new Batch.Call<PingProtos.PingService, String>() { @Override public String call(PingProtos.PingService instance) throws IOException { CoprocessorRpcUtils.BlockingRpcCallback<PingProtos.HelloResponse> rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>(); PingProtos.HelloRequest.Builder builder = PingProtos.HelloRequest.newBuilder(); // Call ping on same instance. Use result calling hello on same instance. builder.setName(doPing(instance)); instance.hello(null, builder.build(), rpcCallback); PingProtos.HelloResponse r = rpcCallback.get(); return r != null && r.hasResponse()? r.getResponse(): null; } }); }
@Override public void hello(RpcController controller, HelloRequest request, RpcCallback<HelloResponse> done) { if (!request.hasName()) done.run(HelloResponse.newBuilder().setResponse(WHOAREYOU).build()); else if (request.getName().equals(NOBODY)) done.run(HelloResponse.newBuilder().build()); else done.run(HelloResponse.newBuilder().setResponse(HELLO + request.getName()).build()); }
@Override public void hello(RpcController controller, HelloRequest request, RpcCallback<HelloResponse> callback) { callback.run(HelloResponse.newBuilder().setResponse("Hello!").build()); }