public boolean compareAndSet(PeerId peer, String key, long expect, long newVal) throws InterruptedException {
        try {
            final CompareAndSetCommand request = new CompareAndSetCommand();
            request.setKey(key);
            request.setNewValue(newVal);
            request.setExpect(expect);
            final Object response = this.rpcClient.invokeSync(peer.getEndpoint(), request,
                cliOptions.getRpcDefaultTimeout());
            final BooleanCommand cmd = (BooleanCommand) response;
            return cmd.isSuccess();
        } 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