@Override
    public void getSequence(final byte[] seqKey, final int step, final KVStoreClosure closure) {
        final Timer.Context timeCtx = getTimeContext("GET_SEQUENCE");
        final Lock readLock = this.readWriteLock.readLock();
        readLock.lock();
        try {
            final byte[] prevBytesVal = this.db.get(this.sequenceHandle, seqKey);
            long startVal;
            if (prevBytesVal == null) {
                startVal = 0;
            } else {
                startVal = Bits.getLong(prevBytesVal, 0);
            }
            if (step < 0) {
                // never get here
                setFailure(closure, "Fail to [GET_SEQUENCE], step must >= 0");
                return;
            }
            if (step == 0) {
                setSuccess(closure, new Sequence(startVal, startVal));
                return;
            }
            final long endVal = getSafeEndValueForSequence(startVal, step);
            if (startVal != endVal) {
                final byte[] newBytesVal = new byte[8];
                Bits.putLong(newBytesVal, 0, endVal);
                this.db.put(this.sequenceHandle, this.writeOptions, seqKey, newBytesVal);
            }
            setSuccess(closure, new Sequence(startVal, endVal));
        } catch (final Exception e) {
            LOG.error("Fail to [GET_SEQUENCE], [key = {}, step = {}], {}.", BytesUtil.toHex(seqKey), step,
                StackTraceUtil.stackTrace(e));
            setCriticalError(closure, "Fail to [GET_SEQUENCE]", e);
        } finally {
            readLock.unlock();
            timeCtx.stop();
        }
    }
Local KV store based on RocksDB

@author dennis
@author jiachun.fjc
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RocksRawKVStore.java