Search in sources :

Example 1 with IncrementAndGetRequest

use of com.alipay.sofa.jraft.example.counter.rpc.CounterOutter.IncrementAndGetRequest in project sofa-jraft by sofastack.

the class CounterClient method incrementAndGet.

private static void incrementAndGet(final CliClientServiceImpl cliClientService, final PeerId leader, final long delta, CountDownLatch latch) throws RemotingException, InterruptedException {
    IncrementAndGetRequest request = IncrementAndGetRequest.newBuilder().setDelta(delta).build();
    cliClientService.getRpcClient().invokeAsync(leader.getEndpoint(), request, new InvokeCallback() {

        @Override
        public void complete(Object result, Throwable err) {
            if (err == null) {
                latch.countDown();
                System.out.println("incrementAndGet result:" + result);
            } else {
                err.printStackTrace();
                latch.countDown();
            }
        }

        @Override
        public Executor executor() {
            return null;
        }
    }, 5000);
}
Also used : InvokeCallback(com.alipay.sofa.jraft.rpc.InvokeCallback) Executor(java.util.concurrent.Executor) IncrementAndGetRequest(com.alipay.sofa.jraft.example.counter.rpc.CounterOutter.IncrementAndGetRequest)

Aggregations

IncrementAndGetRequest (com.alipay.sofa.jraft.example.counter.rpc.CounterOutter.IncrementAndGetRequest)1 InvokeCallback (com.alipay.sofa.jraft.rpc.InvokeCallback)1 Executor (java.util.concurrent.Executor)1