void writeSnapshot(final String snapshotPath) {
        final Timer.Context timeCtx = getTimeContext("WRITE_SNAPSHOT");
        final Lock writeLock = this.readWriteLock.writeLock();
        writeLock.lock();
        try (final Checkpoint checkpoint = Checkpoint.create(this.db)) {
            final String tempPath = snapshotPath + "_temp";
            final File tempFile = new File(tempPath);
            FileUtils.deleteDirectory(tempFile);
            checkpoint.createCheckpoint(tempPath);
            final File snapshotFile = new File(snapshotPath);
            FileUtils.deleteDirectory(snapshotFile);
            if (!Utils.atomicMoveFile(tempFile, snapshotFile, true)) {
                throw new StorageException("Fail to rename [" + tempPath + "] to [" + snapshotPath + "].");
            }
        } catch (final StorageException e) {
            throw e;
        } catch (final Exception e) {
            throw new StorageException("Fail to write snapshot at path: " + snapshotPath, e);
        } finally {
            writeLock.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