private long getNextFencingToken(final byte[] fencingKey) throws RocksDBException {
        final Timer.Context timeCtx = getTimeContext("FENCING_TOKEN");
        final Lock readLock = this.readWriteLock.readLock();
        readLock.lock();
        try {
            final byte[] realKey = BytesUtil.nullToEmpty(fencingKey);
            final byte[] prevBytesVal = this.db.get(this.fencingHandle, realKey);
            final long prevVal;
            if (prevBytesVal == null) {
                prevVal = 0; // init
            } else {
                prevVal = Bits.getLong(prevBytesVal, 0);
            }
            // Don't worry about the token number overflow.
            // It takes about 290,000 years for the 1 million TPS system
            // to use the numbers in the range [0 ~ Long.MAX_VALUE].
            final long newVal = prevVal + 1;
            final byte[] newBytesVal = new byte[8];
            Bits.putLong(newBytesVal, 0, newVal);
            this.db.put(this.fencingHandle, this.writeOptions, realKey, newBytesVal);
            return newVal;
        } 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