public long addAndGet(PeerId peer, String key, long delta) throws InterruptedException {
        try {
            final IncrementAndGetCommand request = new IncrementAndGetCommand();
            request.setKey(key);
            request.setDetal(delta);
            final Object response = this.rpcClient.invokeSync(peer.getEndpoint(), request,
                cliOptions.getRpcDefaultTimeout());
            final BooleanCommand cmd = (BooleanCommand) response;
            if (cmd.isSuccess()) {
                return ((ValueCommand) cmd).getVlaue();
            } else {
                throw new IllegalStateException("Server error:" + cmd.getErrorMsg());
            }
        } catch (final Throwable t) {
            throw new IllegalStateException("Remoting error:" + t.getMessage());
        }
    }
A counter client
@author boyan (boyan@alibaba-inc.com)

2018-Apr-25 4:08:14 PM
jraft-test/src/main/java/com/alipay/sofa/jraft/test/atomic/client/AtomicClient.java