instance must be started before calling this method

这几天写测试用例,测试的时候出了error

java.lang.IllegalStateException: instance must be started before calling this method

分析下原因本地测试的时候引用了dubbo服务,注册中心用的zk,zk 客户端使用的是 Apache 的 Curator

具体问题栈如下

java.lang.IllegalStateException: instance must be started before calling this method at org.apache.curator.shaded.com.google.common.base.Preconditions.checkState(Preconditions.java:176) ~[curator-client-2.13.0.jar:na]

at org.apache.curator.framework.imps.CuratorFrameworkImpl.getData(CuratorFrameworkImpl.java:375) ~[curator-framework-2.13.0.jar:na]

at org.apache.curator.framework.recipes.cache.TreeCache$TreeNode.doRefreshData(TreeCache.java:269) ~[curator-recipes-2.13.0.jar:na]

at org.apache.curator.framework.recipes.cache.TreeCache$TreeNode.refreshData(TreeCache.java:253) ~[curator-recipes-2.13.0.jar:na]

at org.apache.curator.framework.recipes.cache.TreeCache$TreeNode.process(TreeCache.java:349) ~[curator-recipes-2.13.0.jar:na]

at org.apache.curator.framework.imps.NamespaceWatcher.process(NamespaceWatcher.java:62) ~[curator-framework-2.13.0.jar:na]

at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:530) ~[zookeeper-3.4.8.jar:3.4.8--1]

at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:505) ~[zookeeper-3.4.8.jar:3.4.8--1]

2021-07-28 20:56:59.612 INFO 16596 --- [ain-EventThread] org.apache.zookeeper.ClientCnxn : EventThread shut down for session: 0x17ae7370b350bc1

Process finished with exit code 0

后面测试的时候又能正常运行

 

问题出在这个地方

bboShutdownHook

涉及dubbo优雅停机的问题,需要满足

  1. 新的请求不能再发往正在停机的 Dubbo 服务提供者。
  2. 若关闭服务提供者,已经接收到服务请求,需要处理完毕才能下线服务。
  3. 若关闭服务消费者,已经发出的服务请求,需要等待响应返回。

结合自身情况分析

1、zk在的那台机器性能过差(这次为了应用迷你化分配了很低的机器性能有时候60000的超时都不够)

2、 业务组内有人和我一起再调用那个dubbo的服务

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值