private ScheduledFuture<?> scheduleKeepingLease(final ScheduledExecutorService watchdog, final byte[] key,
                                                    final Acquirer acquirer, final long period) {
        return watchdog.scheduleAtFixedRate(() -> {
            try {
                if (this.mayCancelIfRunning) {
                    // last time fail to cancel
                    tryCancelScheduling();
                    return;
                }
                this.rheaKVStore.tryLockWith(key, true, acquirer).whenComplete((result, throwable) -> {
                    if (throwable != null) {
                        LOG.error("Fail to keeping lease with lock: {}, {}.", acquirer, StackTraceUtil.stackTrace(throwable));
                        tryCancelScheduling();
                        return;
                    }
                    if (!result.isSuccess()) {
                        LOG.warn("Fail to keeping lease with lock: {}, and result detail is: {}.", acquirer, result);
                        tryCancelScheduling();
                        return;
                    }
                    LOG.debug("Keeping lease with lock: {}.", acquirer);
                });
            } catch (final Throwable t) {
                LOG.error("Fail to keeping lease with lock: {}, {}.", acquirer, StackTraceUtil.stackTrace(t));
                tryCancelScheduling();
            }
        }, period, period, TimeUnit.MILLISECONDS);
    }
Default implementation with distributed lock.

@author jiachun.fjc
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/DefaultDistributedLock.java