dubbo Zookeeper node sessionTimeout in provider side

uyhoqukh  于 4个月前  发布在  Zookeeper
关注(0)|答案(2)|浏览(117)

请问 CuratorFrameworkUtils 这个类的 buildCuratorFramework 方法中创建 CuratorFramework 时为什么没有执行 builder.sessionTimeoutMs(connectionURL.getParameter(SESSION_KEY, DEFAULT_SESSION_TIMEOUT_MS)) 方法,不能自己设置 sessionTimeout 呢

public class ZookeeperServiceDiscovery extends AbstractServiceDiscovery {
    // ......
  
    public ZookeeperServiceDiscovery(ApplicationModel applicationModel, URL registryURL) {
        super(applicationModel, registryURL);
        try {
            this.curatorFramework = buildCuratorFramework(registryURL, this);
            // ......
        } catch (Exception e) {
            throw new IllegalStateException("Create zookeeper service discovery failed.", e);
        }
    }

    public static CuratorFramework buildCuratorFramework(URL connectionURL, ZookeeperServiceDiscovery serviceDiscovery) throws Exception {
        CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
            .connectString(connectionURL.getBackupAddress())
            .retryPolicy(buildRetryPolicy(connectionURL));
        String userInformation = connectionURL.getUserInformation();
        if (StringUtils.isNotEmpty(userInformation)) {
            builder = builder.authorization("digest", userInformation.getBytes());
            builder.aclProvider(new ACLProvider() {
                @Override
                public List<ACL> getDefaultAcl() {
                    return ZooDefs.Ids.CREATOR_ALL_ACL;
                }

                @Override
                public List<ACL> getAclForPath(String path) {
                    return ZooDefs.Ids.CREATOR_ALL_ACL;
                }
            });
        }
        CuratorFramework curatorFramework = builder.build();
        // ......
        return curatorFramework;
    }
   // ......

作为 provider,当该 provider 下线之后,/services/xxx 节点仍然存在,等到默认 60s 之后才会删除,这期间当consumer 端请求该 provider 时就会报如下错误

org.apache.dubbo.rpc.StatusRpcException: DEADLINE_EXCEEDED : Waiting server-side response timeout by scan timer. start time: 2023-06-09 17:00:09.431, end time: 2023-06-09 17:00:12.447, timeout: 3000 ms, service: xxx.xxx.xxx

现在想改短一点 sessionTimeout 就只能修改 zookeeper 配置中的 maxSessionTimeout 或 tickTime 了吗

zpf6vheq

zpf6vheq2#

May fixed in

这个 #9317 中的 CuratorZookeeperClient 应该是控制 /dubbo/xxx.xxx/providers 节点的,而 ZookeeperServiceDiscovery 中的 CuratorFramework 是控制 /services/xxx 节点的,这是两个客户端,我很疑惑,为什么在 CuratorZookeeperClient 中是设置了 sessiontimeout 的,在 ZookeeperServiceDiscovery 中没有设置 sessiontimeout。但是 consumer 端是只有在 /dubbo/xxx.xxx.providers/ 节点和 /services/xxx 节点都不存在时才认为该 provider 不存在了,所以这两个节点的 sessiontimeout 应该要保持一致才对

相关问题