@Override
    public void watchInstances(final String key, final ChangedEventListener listener) {
        try {
            CuratorCache treeCache = client.addCache(key, (type, oldData, data) -> {
                if (!Objects.nonNull(data) || !Objects.nonNull(data.getData())) {
                    return;
                }
                String currentPath = data.getPath();
                String currentData = new String(data.getData(), StandardCharsets.UTF_8);
                LOGGER.info("zookeeper registry watch find resultData ={}", currentData);
                Stat stat = data.getStat();
                boolean isEphemeral = Objects.nonNull(stat) && stat.getEphemeralOwner() > 0;
                if (!isEphemeral) {
                    LOGGER.info("zookeeper registry watch Ignore non-ephemeral node changes path {}", currentPath);
                    return;
                }
                switch (type) {
                    case NODE_CREATED:
                        listener.onEvent(currentPath, currentData, ChangedEventListener.Event.ADDED);
                        break;
                    case NODE_CHANGED:
                        listener.onEvent(currentPath, currentData, ChangedEventListener.Event.UPDATED);
                        break;
                    case NODE_DELETED:
                        listener.onEvent(currentPath, currentData, ChangedEventListener.Event.DELETED);
                        break;
                    default:
                        listener.onEvent(currentPath, currentData, ChangedEventListener.Event.IGNORED);
                        break;
                }
            });
            cacheMap.put(key, treeCache);
            LOGGER.info("zookeeper registry subscribed to eureka updates for key: {}", key);
        } catch (Exception e) {
            LOGGER.error("zookeeper registry error watching key: {}", key, e);
            throw new ShenyuException(e);
        }
    }
The type Zookeeper instance register repository.
shenyu-registry/shenyu-registry-zookeeper/src/main/java/org/apache/shenyu/registry/zookeeper/ZookeeperInstanceRegisterRepository.java