zookeeper实现分布式锁

本文根据zk的临时有序节点特性,实现分布式场景下的读写锁,所谓读写锁(读写有序),就是读写互斥,写写互斥,可以连续读,提高读的并发。

大概原理如下::

1、创建跟节点,也就是锁的主题

2、获取锁时,现在根节点下创建临时节点,注意(锁有读锁和写锁区分,读READ 写WRITE)

3、创建节点成功,则进行获取锁资源判断

4、获得所有的节点,按照需要升序排序

5、如果第一个节点就是当前节点,则获取锁

6、如果当前节点是写节点,则直接监听此节点的上一个节点即可

7、如果是读节点,则判断比自己小的节点是否存在写节点,不存在获取锁

8、存在写节点,则监听最近的写节点,

代码如下:

package com.ribbon.demo.lock.zookeeper;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.beans.factory.annotation.Value;

import java.util.concurrent.CountDownLatch;

@Configuration
public class ZookeeperConfig {
    private static final Logger logger = LoggerFactory.getLogger(ZookeeperConfig.class);

    @Value("${zookeeper.address}")
    private String connect;

    @Value("${zookeeper.timeout}")
    private int timeout;
    /**
     * zookeeper client
     * @return
     */
    @Bean(name = "zkClient")
    public ZooKeeper zkClient() {
        ZooKeeper zooKeeper = null;
        try {
            final CountDownLatch countDownLatch = new CountDownLatch(1);
            //连接成功后,会回调watcher监听,此连接操作是异步的,执行完new语句后,直接调用后续代码
            zooKeeper = new ZooKeeper(connect, timeout, new Watcher() {
                @Override
                public void process(WatchedEvent event) {
                    if (Event.KeeperState.SyncConnected == event.getState()) {
                        //如果收到了服务端的响应事件,连接成功
                        countDownLatch.countDown();
                    }
                }
            });
            countDownLatch.await();
            logger.info("【初始化ZooKeeper连接状态....】={}", zooKeeper.getState());
        } catch (Exception e) {
            logger.error("初始化ZooKeeper连接异常....】={}", e);
        }
        return zooKeeper;
    }

}

package com.ribbon.demo.lock.zookeeper;


import lombok.Data;

@Data
public class LockNode {
    private String lockId;
    private String path;
    private boolean active;
    public LockNode(String lockId, String path) {
        this.lockId = lockId;
        this.path = path;
    }


}

package com.ribbon.demo.lock.zookeeper;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.*;
import org.apache.zookeeper.data.Stat;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * TODO
 *
 * @author yyl
 * @date 2022/8/2 22:25
 * @desc
 */
@Component
@Slf4j
public class ZookeeperLock implements InitializingBean {

    @Autowired
    private ZooKeeper zooKeeperClient;

    private  static final String  rootPath = "/test-lock";
    private  static final String WRITE = "WRITE";
    private  static final String READ = "READ";

    @Override
    public void afterPropertiesSet() throws Exception {
        Stat rootPathExists = zooKeeperClient.exists(rootPath, false);
        if (rootPathExists == null) {
            //不存在节点 则创建根节点
            zooKeeperClient.create(rootPath,null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        }
    }


    /**
     * 获取锁
     */
    @SneakyThrows
    public LockNode lock(String lockId, long timeOut){
        // 创建临时节点
        LockNode lockNode = createLockNode(lockId);
        tryActiveLock(lockNode);
        //没有获得锁,进入超时等待
        if (!lockNode.isActive()) {
            synchronized (lockNode) {
                log.info("当前线程等待:{}",lockNode.getPath());
                lockNode.wait(timeOut);
               log.info("当前线程唤醒:{}",lockNode.getPath());
            }
        }

        if (!lockNode.isActive()) {
            throw new RuntimeException(" lock  timeout");
        }
//      log.info("当前获得锁{}",lockNode);
        return lockNode;
    }


    /**
     * 释放锁
     */
    @SneakyThrows
    public void unlock(LockNode lockNode) {
        if (lockNode.isActive()) {
            //version参数指定要更新的数据的版本, 如果version和真实的版本不同, 更新操作将失败. 指定version为-1则忽略版本检查
            zooKeeperClient.delete(lockNode.getPath(),-1);
//            log.info("释放锁:{}",lockNode.getPath());
        }
    }

    /**
     * 创建临时有序节点
     * @param lockId
     * @return
     */
    @SneakyThrows
    private LockNode createLockNode(String lockId) {
        String nodePath = zooKeeperClient.create(rootPath + "/" + lockId, null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
        return new LockNode(lockId, nodePath);
    }



    /**
     *尝试激活锁
     */
    @SneakyThrows
    public void tryActiveLock(LockNode lockNode){
//        log.info("当前节点:{}",lockNode);
        //获取所有子节点数据
        List childrens= zooKeeperClient.getChildren(rootPath, false);
        //根据节点顺序进行升序排序
        List sortRealPathChildrens = childrens.stream().sorted(Comparator.comparing(x->x.replace(WRITE,"").replace(READ,""))).map(p -> rootPath + "/" + p).collect(Collectors.toList());
//        log.info("当前根节点下子节点排序后:{}",sortRealPathChildrens);
        //最小的节点是否是自己
        if(sortRealPathChildrens.get(0).equals(lockNode.getPath())){
            lockNode.setActive(true);
            return;
        }
        //当前节点是读还是写
        if(lockNode.getPath().contains(WRITE)){
            //当前是写节点,监控最后一个节点即可
            String watchNodePath = sortRealPathChildrens.get(sortRealPathChildrens.indexOf(lockNode.getPath()) - 1);
            this.watchNode(watchNodePath,lockNode);
            return;
        }
        //非写节点,找里自己最近的一个写节点监听
        List minWriteNodepath = sortRealPathChildrens.subList(0, sortRealPathChildrens.indexOf(lockNode.getPath())).stream().filter(x -> x.contains(WRITE)).collect(Collectors.toList());
//        List writeNodes = sortRealPathChildrens.stream().filter(x -> x.contains(WRITE)).collect(Collectors.toList());
        //如果不存在写节点,则可以获取锁
        if(CollectionUtils.isEmpty(minWriteNodepath)){
//            log.info("当前读操作,前面没有写节点",lockNode.getPath());
            lockNode.setActive(true);
            return;
        }
        //之前的节点存在写节点 需要监听比自己节点大点的写节点
//        log.info("当前读操作,监控的写节点",minWriteNodepath);
        String watchNodePath = minWriteNodepath.get(minWriteNodepath.size() - 1);
        this.watchNode(watchNodePath,lockNode);
    }


    @SneakyThrows
    private void watchNode(String watchNodePath,LockNode lockNode) {
//        log.info("当前节点:{},需要监听节点:{}",lockNode.getPath(),watchNodePath);
        //AddWatchMode.PERSISTENT: 表示只关心当前节点的删除、数据变更,创建,一级子节点的创建、删除;无法感知子节点的子节点创建、删除,无法感知子节点的数据变更
        //AddWatchMode.PERSISTENT_RECURSIVE: 相当于递归监听,改节点及其子节点的所有变更都监听
        //当节点出现创建/删除 或者 新增数据时,触发watcher回调
        Stat exists = zooKeeperClient.exists(watchNodePath, new Watcher() {
            @Override
            public void process(WatchedEvent watchedEvent) {
                Event.EventType type = watchedEvent.getType();
//                log.info("节点变更::{}", type);
                tryActiveLock(lockNode);
                synchronized (lockNode) {
                    if (lockNode.isActive()) {
                        log.info("唤醒当前线程:{}", lockNode.getPath());
                        lockNode.notify();
                    }
                }

            }
        });
//        log.info("监听结果:{}", exists);
        //防止监听的时候,正好节点删除,那么则重新获取锁
        if(exists == null){
            tryActiveLock(lockNode);
        }
        /* zooKeeperClient.addWatch(watchNodePath,watchedEvent -> {
        }, AddWatchMode.PERSISTENT);*/

    }

}

测试结果:

2022-08-06 11:58:34.424  INFO 11236 --- [      Thread-18] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000367, active=true)
2022-08-06 11:58:34.429  INFO 11236 --- [      Thread-14] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000368, active=true)
2022-08-06 11:58:34.551  INFO 11236 --- [      Thread-13] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000366, active=true)
2022-08-06 11:58:34.554  INFO 11236 --- [      Thread-17] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000369, active=true)
============
2022-08-06 11:58:34.772  INFO 11236 --- [      Thread-15] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000370, active=true)
2022-08-06 11:58:39.440  INFO 11236 --- [      Thread-18] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000367, active=true)
2022-08-06 11:58:39.442  INFO 11236 --- [      Thread-14] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000368, active=true)
2022-08-06 11:58:39.562  INFO 11236 --- [      Thread-13] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000366, active=true)
2022-08-06 11:58:39.565  INFO 11236 --- [      Thread-17] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000369, active=true)
2022-08-06 11:58:39.785  INFO 11236 --- [      Thread-15] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000370, active=true)
2022-08-06 11:58:39.798  INFO 11236 --- [      Thread-16] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000371, active=true)
2022-08-06 11:58:44.811  INFO 11236 --- [      Thread-16] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000371, active=true)
2022-08-06 11:58:44.826  INFO 11236 --- [       Thread-9] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000372, active=true)
2022-08-06 11:58:49.846  INFO 11236 --- [       Thread-9] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000372, active=true)
2022-08-06 11:58:49.863  INFO 11236 --- [      Thread-77] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000373, active=true)
2022-08-06 11:58:54.874  INFO 11236 --- [      Thread-77] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000373, active=true)
2022-08-06 11:58:54.890  INFO 11236 --- [       Thread-5] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000374, active=true)
2022-08-06 11:58:59.904  INFO 11236 --- [       Thread-5] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000374, active=true)
2022-08-06 11:58:59.916  INFO 11236 --- [       Thread-7] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000375, active=true)
2022-08-06 11:59:04.986  INFO 11236 --- [       Thread-7] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000375, active=true)
2022-08-06 11:59:05.013  INFO 11236 --- [      Thread-11] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000376, active=true)
2022-08-06 11:59:10.025  INFO 11236 --- [      Thread-11] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000376, active=true)
2022-08-06 11:59:10.037  INFO 11236 --- [       Thread-3] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000377, active=true)
2022-08-06 11:59:15.051  INFO 11236 --- [       Thread-3] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000377, active=true)
2022-08-06 11:59:15.063  INFO 11236 --- [      Thread-73] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000378, active=true)
2022-08-06 11:59:20.090  INFO 11236 --- [      Thread-73] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000378, active=true)
2022-08-06 11:59:20.108  INFO 11236 --- [      Thread-21] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000379, active=true)
2022-08-06 11:59:25.237  INFO 11236 --- [      Thread-21] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000379, active=true)
2022-08-06 11:59:25.239  INFO 11236 --- [      Thread-69] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000380, active=true)
2022-08-06 11:59:30.254  INFO 11236 --- [      Thread-69] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000380, active=true)
2022-08-06 11:59:30.264  INFO 11236 --- [      Thread-78] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000381, active=true)
2022-08-06 11:59:35.275  INFO 11236 --- [      Thread-78] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000381, active=true)
2022-08-06 11:59:35.285  INFO 11236 --- [      Thread-19] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000382, active=true)
2022-08-06 11:59:40.298  INFO 11236 --- [      Thread-19] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000382, active=true)
2022-08-06 11:59:40.310  INFO 11236 --- [      Thread-74] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000383, active=true)
2022-08-06 11:59:45.324  INFO 11236 --- [      Thread-74] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000383, active=true)
2022-08-06 11:59:45.333  INFO 11236 --- [      Thread-70] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000384, active=true)
2022-08-06 11:59:50.346  INFO 11236 --- [      Thread-70] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000384, active=true)
2022-08-06 11:59:50.357  INFO 11236 --- [      Thread-26] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000385, active=true)
2022-08-06 11:59:55.367  INFO 11236 --- [      Thread-26] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000385, active=true)
2022-08-06 11:59:55.383  INFO 11236 --- [      Thread-24] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000386, active=true)
2022-08-06 12:00:00.393  INFO 11236 --- [      Thread-24] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000386, active=true)
2022-08-06 12:00:00.412  INFO 11236 --- [      Thread-44] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000388, active=true)
2022-08-06 12:00:00.425  INFO 11236 --- [      Thread-32] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000387, active=true)
2022-08-06 12:00:05.432  INFO 11236 --- [      Thread-44] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000388, active=true)
2022-08-06 12:00:05.438  INFO 11236 --- [      Thread-32] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000387, active=true)
2022-08-06 12:00:05.440  INFO 11236 --- [      Thread-36] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000389, active=true)
2022-08-06 12:00:10.457  INFO 11236 --- [      Thread-36] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000389, active=true)
2022-08-06 12:00:10.466  INFO 11236 --- [      Thread-45] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000390, active=true)
2022-08-06 12:00:15.477  INFO 11236 --- [      Thread-45] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000390, active=true)
2022-08-06 12:00:15.486  INFO 11236 --- [      Thread-79] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000391, active=true)
2022-08-06 12:00:20.500  INFO 11236 --- [      Thread-79] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000391, active=true)
2022-08-06 12:00:20.511  INFO 11236 --- [      Thread-66] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000392, active=true)
2022-08-06 12:00:25.526  INFO 11236 --- [      Thread-66] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000392, active=true)
2022-08-06 12:00:25.534  INFO 11236 --- [      Thread-31] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000393, active=true)
2022-08-06 12:00:25.551  INFO 11236 --- [      Thread-27] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000394, active=true)
2022-08-06 12:00:25.561  INFO 11236 --- [      Thread-35] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000395, active=true)
2022-08-06 12:00:30.542  INFO 11236 --- [      Thread-31] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000393, active=true)
2022-08-06 12:00:30.565  INFO 11236 --- [      Thread-27] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000394, active=true)
2022-08-06 12:00:30.574  INFO 11236 --- [      Thread-35] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000395, active=true)
2022-08-06 12:00:30.585  INFO 11236 --- [      Thread-62] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000396, active=true)
2022-08-06 12:00:35.597  INFO 11236 --- [      Thread-62] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000396, active=true)
2022-08-06 12:00:35.608  INFO 11236 --- [      Thread-58] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000397, active=true)
2022-08-06 12:00:40.620  INFO 11236 --- [      Thread-58] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000397, active=true)
2022-08-06 12:00:40.631  INFO 11236 --- [      Thread-54] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000398, active=true)
2022-08-06 12:00:45.643  INFO 11236 --- [      Thread-54] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000398, active=true)
2022-08-06 12:00:45.651  INFO 11236 --- [      Thread-50] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000399, active=true)
2022-08-06 12:00:45.662  INFO 11236 --- [      Thread-46] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000400, active=true)
2022-08-06 12:00:50.791  INFO 11236 --- [      Thread-50] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000399, active=true)
2022-08-06 12:00:50.792  INFO 11236 --- [      Thread-46] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000400, active=true)
2022-08-06 12:00:50.833  INFO 11236 --- [      Thread-42] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000401, active=true)
2022-08-06 12:00:55.864  INFO 11236 --- [      Thread-42] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000401, active=true)
2022-08-06 12:00:55.922  INFO 11236 --- [      Thread-38] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000402, active=true)
2022-08-06 12:01:00.936  INFO 11236 --- [      Thread-38] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000402, active=true)
2022-08-06 12:01:00.945  INFO 11236 --- [      Thread-34] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000403, active=true)
2022-08-06 12:01:06.016  INFO 11236 --- [      Thread-34] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000403, active=true)
2022-08-06 12:01:06.032  INFO 11236 --- [      Thread-30] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000404, active=true)
2022-08-06 12:01:11.047  INFO 11236 --- [      Thread-30] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000404, active=true)
2022-08-06 12:01:11.060  INFO 11236 --- [      Thread-22] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000405, active=true)
2022-08-06 12:01:16.073  INFO 11236 --- [      Thread-22] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000405, active=true)
2022-08-06 12:01:16.084  INFO 11236 --- [      Thread-49] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000406, active=true)
2022-08-06 12:01:21.100  INFO 11236 --- [      Thread-49] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000406, active=true)
2022-08-06 12:01:21.113  INFO 11236 --- [      Thread-53] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000409, active=true)
2022-08-06 12:01:21.121  INFO 11236 --- [      Thread-59] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000412, active=true)
2022-08-06 12:01:21.130  INFO 11236 --- [      Thread-47] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000411, active=true)
2022-08-06 12:01:21.138  INFO 11236 --- [      Thread-51] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000410, active=true)
2022-08-06 12:01:21.148  INFO 11236 --- [      Thread-55] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000408, active=true)
2022-08-06 12:01:21.179  INFO 11236 --- [      Thread-65] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000407, active=true)
2022-08-06 12:01:26.125  INFO 11236 --- [      Thread-53] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000409, active=true)
2022-08-06 12:01:26.135  INFO 11236 --- [      Thread-59] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000412, active=true)
2022-08-06 12:01:26.142  INFO 11236 --- [      Thread-47] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000411, active=true)
2022-08-06 12:01:26.147  INFO 11236 --- [      Thread-51] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000410, active=true)
2022-08-06 12:01:26.156  INFO 11236 --- [      Thread-55] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000408, active=true)
2022-08-06 12:01:26.191  INFO 11236 --- [      Thread-65] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000407, active=true)
2022-08-06 12:01:26.201  INFO 11236 --- [      Thread-57] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000413, active=true)
2022-08-06 12:01:31.212  INFO 11236 --- [      Thread-57] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000413, active=true)
2022-08-06 12:01:31.220  INFO 11236 --- [      Thread-43] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000414, active=true)
2022-08-06 12:01:36.234  INFO 11236 --- [      Thread-43] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000414, active=true)
2022-08-06 12:01:36.243  INFO 11236 --- [      Thread-63] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000415, active=true)
2022-08-06 12:01:41.252  INFO 11236 --- [      Thread-63] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000415, active=true)
2022-08-06 12:01:41.260  INFO 11236 --- [      Thread-61] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000416, active=true)
2022-08-06 12:01:46.272  INFO 11236 --- [      Thread-61] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000416, active=true)
2022-08-06 12:01:46.300  INFO 11236 --- [      Thread-39] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000417, active=true)
2022-08-06 12:01:51.311  INFO 11236 --- [      Thread-39] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000417, active=true)
2022-08-06 12:01:51.319  INFO 11236 --- [      Thread-67] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000418, active=true)
2022-08-06 12:01:56.332  INFO 11236 --- [      Thread-67] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000418, active=true)
2022-08-06 12:01:56.341  INFO 11236 --- [      Thread-23] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000419, active=true)
2022-08-06 12:02:01.350  INFO 11236 --- [      Thread-23] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000419, active=true)
2022-08-06 12:02:01.358  INFO 11236 --- [      Thread-41] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000420, active=true)
2022-08-06 12:02:06.376  INFO 11236 --- [      Thread-41] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000420, active=true)
2022-08-06 12:02:06.383  INFO 11236 --- [      Thread-71] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000421, active=true)
2022-08-06 12:02:06.391  INFO 11236 --- [      Thread-75] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000422, active=true)
2022-08-06 12:02:11.391  INFO 11236 --- [      Thread-71] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000421, active=true)
2022-08-06 12:02:11.400  INFO 11236 --- [      Thread-75] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000422, active=true)
2022-08-06 12:02:11.408  INFO 11236 --- [      Thread-29] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000423, active=true)
2022-08-06 12:02:16.421  INFO 11236 --- [      Thread-29] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000423, active=true)
2022-08-06 12:02:16.430  INFO 11236 --- [      Thread-37] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000424, active=true)
2022-08-06 12:02:21.439  INFO 11236 --- [      Thread-37] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000424, active=true)
2022-08-06 12:02:21.446  INFO 11236 --- [      Thread-25] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000425, active=true)
2022-08-06 12:02:26.457  INFO 11236 --- [      Thread-25] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000425, active=true)
2022-08-06 12:02:26.465  INFO 11236 --- [      Thread-33] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000426, active=true)
2022-08-06 12:02:31.474  INFO 11236 --- [      Thread-33] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000426, active=true)
2022-08-06 12:02:31.482  INFO 11236 --- [       Thread-8] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000427, active=true)
2022-08-06 12:02:36.491  INFO 11236 --- [       Thread-8] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000427, active=true)
2022-08-06 12:02:36.499  INFO 11236 --- [      Thread-28] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000428, active=true)
2022-08-06 12:02:41.508  INFO 11236 --- [      Thread-28] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000428, active=true)
2022-08-06 12:02:41.516  INFO 11236 --- [       Thread-4] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000429, active=true)
2022-08-06 12:02:46.526  INFO 11236 --- [       Thread-4] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000429, active=true)
2022-08-06 12:02:46.535  INFO 11236 --- [      Thread-10] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000431, active=true)
2022-08-06 12:02:46.544  INFO 11236 --- [      Thread-76] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000430, active=true)
2022-08-06 12:02:51.545  INFO 11236 --- [      Thread-10] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000431, active=true)
2022-08-06 12:02:51.556  INFO 11236 --- [      Thread-76] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000430, active=true)
2022-08-06 12:02:51.556  INFO 11236 --- [       Thread-2] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000432, active=true)
2022-08-06 12:02:56.570  INFO 11236 --- [       Thread-2] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000432, active=true)
2022-08-06 12:02:56.580  INFO 11236 --- [       Thread-6] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000433, active=true)
2022-08-06 12:03:01.592  INFO 11236 --- [       Thread-6] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000433, active=true)
2022-08-06 12:03:01.602  INFO 11236 --- [      Thread-12] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000434, active=true)
2022-08-06 12:03:06.612  INFO 11236 --- [      Thread-12] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000434, active=true)
2022-08-06 12:03:06.623  INFO 11236 --- [      Thread-72] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000435, active=true)
2022-08-06 12:03:11.632  INFO 11236 --- [      Thread-72] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000435, active=true)
2022-08-06 12:03:11.643  INFO 11236 --- [      Thread-56] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000439, active=true)
2022-08-06 12:03:11.651  INFO 11236 --- [      Thread-60] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000438, active=true)
2022-08-06 12:03:11.660  INFO 11236 --- [      Thread-68] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000436, active=true)
2022-08-06 12:03:11.672  INFO 11236 --- [      Thread-64] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000437, active=true)
2022-08-06 12:03:16.660  INFO 11236 --- [      Thread-56] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000439, active=true)
2022-08-06 12:03:16.666  INFO 11236 --- [      Thread-60] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000438, active=true)
2022-08-06 12:03:16.674  INFO 11236 --- [      Thread-68] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000436, active=true)
2022-08-06 12:03:16.681  INFO 11236 --- [      Thread-64] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000437, active=true)
2022-08-06 12:03:16.691  INFO 11236 --- [      Thread-52] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000440, active=true)
2022-08-06 12:03:21.701  INFO 11236 --- [      Thread-52] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000440, active=true)
2022-08-06 12:03:21.716  INFO 11236 --- [      Thread-48] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000441, active=true)
2022-08-06 12:03:26.727  INFO 11236 --- [      Thread-48] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000441, active=true)
2022-08-06 12:03:26.747  INFO 11236 --- [      Thread-40] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000442, active=true)
2022-08-06 12:03:31.790  INFO 11236 --- [      Thread-40] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000442, active=true)
2022-08-06 12:03:31.802  INFO 11236 --- [      Thread-20] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000443, active=true)
2022-08-06 12:03:36.816  INFO 11236 --- [      Thread-20] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000443, active=true)
2022-08-06 12:03:36.829  INFO 11236 --- [      Thread-81] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000444, active=true)
2022-08-06 12:03:41.906  INFO 11236 --- [      Thread-81] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000444, active=true)
2022-08-06 12:03:41.917  INFO 11236 --- [      Thread-85] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000445, active=true)
2022-08-06 12:03:46.933  INFO 11236 --- [      Thread-85] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000445, active=true)
2022-08-06 12:03:46.944  INFO 11236 --- [      Thread-95] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000446, active=true)
2022-08-06 12:03:46.952  INFO 11236 --- [      Thread-91] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000447, active=true)
2022-08-06 12:03:51.960  INFO 11236 --- [      Thread-95] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000446, active=true)
2022-08-06 12:03:51.963  INFO 11236 --- [      Thread-91] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000447, active=true)
2022-08-06 12:03:51.972  INFO 11236 --- [      Thread-87] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000448, active=true)
2022-08-06 12:03:56.983  INFO 11236 --- [      Thread-87] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000448, active=true)
2022-08-06 12:03:56.994  INFO 11236 --- [      Thread-83] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000449, active=true)
2022-08-06 12:04:02.009  INFO 11236 --- [      Thread-83] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000449, active=true)
2022-08-06 12:04:02.019  INFO 11236 --- [     Thread-100] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000450, active=true)
2022-08-06 12:04:07.030  INFO 11236 --- [     Thread-100] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000450, active=true)
2022-08-06 12:04:07.042  INFO 11236 --- [      Thread-96] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000451, active=true)
2022-08-06 12:04:12.111  INFO 11236 --- [      Thread-96] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000451, active=true)
2022-08-06 12:04:12.119  INFO 11236 --- [      Thread-92] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000452, active=true)
2022-08-06 12:04:17.154  INFO 11236 --- [      Thread-92] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000452, active=true)
2022-08-06 12:04:17.165  INFO 11236 --- [      Thread-88] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000453, active=true)
2022-08-06 12:04:22.176  INFO 11236 --- [      Thread-88] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000453, active=true)
2022-08-06 12:04:22.186  INFO 11236 --- [      Thread-84] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000454, active=true)
2022-08-06 12:04:27.197  INFO 11236 --- [      Thread-84] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000454, active=true)
2022-08-06 12:04:27.211  INFO 11236 --- [      Thread-80] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000455, active=true)
2022-08-06 12:04:32.223  INFO 11236 --- [      Thread-80] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000455, active=true)
2022-08-06 12:04:32.233  INFO 11236 --- [      Thread-98] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000456, active=true)
2022-08-06 12:04:37.245  INFO 11236 --- [      Thread-98] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000456, active=true)
2022-08-06 12:04:37.260  INFO 11236 --- [      Thread-94] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000457, active=true)
2022-08-06 12:04:42.274  INFO 11236 --- [      Thread-94] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000457, active=true)
2022-08-06 12:04:42.283  INFO 11236 --- [      Thread-90] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000458, active=true)
2022-08-06 12:04:47.301  INFO 11236 --- [      Thread-90] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000458, active=true)
2022-08-06 12:04:47.309  INFO 11236 --- [      Thread-86] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000459, active=true)
2022-08-06 12:04:47.324  INFO 11236 --- [      Thread-82] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000460, active=true)
2022-08-06 12:04:52.321  INFO 11236 --- [      Thread-86] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000459, active=true)
2022-08-06 12:04:52.334  INFO 11236 --- [      Thread-82] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000460, active=true)
2022-08-06 12:04:52.344  INFO 11236 --- [     Thread-101] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000461, active=true)
2022-08-06 12:04:57.353  INFO 11236 --- [     Thread-101] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000461, active=true)
2022-08-06 12:04:57.367  INFO 11236 --- [      Thread-97] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=READ, path=/test-lock/READ0000000462, active=true)
2022-08-06 12:05:02.377  INFO 11236 --- [      Thread-97] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=READ, path=/test-lock/READ0000000462, active=true)
2022-08-06 12:05:02.385  INFO 11236 --- [      Thread-93] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000463, active=true)
2022-08-06 12:05:07.394  INFO 11236 --- [      Thread-93] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000463, active=true)
2022-08-06 12:05:07.403  INFO 11236 --- [      Thread-99] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000464, active=true)
2022-08-06 12:05:12.412  INFO 11236 --- [      Thread-99] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000464, active=true)
2022-08-06 12:05:12.427  INFO 11236 --- [      Thread-89] com.ribbon.demo.DemoApplicationTests     : ---------成功获取锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000465, active=true)
2022-08-06 12:05:17.457  INFO 11236 --- [      Thread-89] com.ribbon.demo.DemoApplicationTests     : ---------释放锁:LockNode(lockId=WRITE, path=/test-lock/WRITE0000000465, active=true)

你可能感兴趣的:(zookeeper,分布式,java-zookeeper,zookeeper)