-
Notifications
You must be signed in to change notification settings - Fork 26.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module config no support unexport #10380
Module config no support unexport #10380
Conversation
Codecov Report
@@ Coverage Diff @@
## 3.0 #10380 +/- ##
============================================
- Coverage 65.72% 65.65% -0.08%
+ Complexity 319 318 -1
============================================
Files 1233 1234 +1
Lines 53721 53859 +138
Branches 8119 8154 +35
============================================
+ Hits 35309 35359 +50
- Misses 14564 14642 +78
- Partials 3848 3858 +10
Help us with your feedback. Take ten seconds to tell us how you rate us. |
@Override | ||
public void unexport() { | ||
ModuleModel moduleModel = DubboBeanUtils.getModuleModel(applicationContext); | ||
moduleModel.getConfigManager().removeConfig(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it only destroy call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你可以试下 unexport 然后再export 同样的service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
正常就应该是在ModuleModel销毁的时候对configManger做清空操作的。
ServiceConfig的export和unexport内部都不应该对configManager进行添加或者移除操作。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该这个词有点太随便了
当一个ref unexport的时候
- config里面是否还要保留着这个ref相关的信息
- 因为保存了相关的信息那么同样接口的ref就无法再创建了,是否合适
当然这个都是要跟设计有关,但是从来没说过一个service和ref是单例的,只有在destroy才需要销毁,至少2.7.x的service和ref的生命周期是跟unexport相关的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
写这里原因是,加入是bean做的,所以删除也由它管理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加入和删除一起迁移到父类我觉得是OK的
目前还是保持统一在bean中加入和删除更合适
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该这个词有点太随便了 当一个ref unexport的时候
- config里面是否还要保留着这个ref相关的信息
- 因为保存了相关的信息那么同样接口的ref就无法再创建了,是否合适
当然这个都是要跟设计有关,但是从来没说过一个service和ref是单例的,只有在destroy才需要销毁,至少2.7.x的service和ref的生命周期是跟unexport相关的
我又想了下,针对你上面提到的。在ModuleDeployer销毁的时候,在每个ServiceConfig#unexport发生之后就立马做了configManager的remove操作(所以你说的12情况都不存在),只是这个时机没有放在unexport里面。而且目前unexport操作目前基本都是在ModuleDeployer销毁时调用的,除非说使用者自己去执行了unexport,才出现你说的情况,但一般使用者不会去这么做。
目前的设计是执行export之前,ServiceConfig已经加入到了configManager,unexport之后才将ServiceConfig从configManager移除,即export和unexport内部都没有关注对configManager的添加或移除操作。
不过按照目前的修改,将ServiceConfig的从configManager的移除逻辑放在unexport方法中也没问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要考虑下循环依赖的问题,ModuleModel.destroy -> foreach -> ServiceBean.unexport -> ModuleModel.remove
@Override | ||
public void unexport() { | ||
ModuleModel moduleModel = DubboBeanUtils.getModuleModel(applicationContext); | ||
moduleModel.getConfigManager().removeConfig(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要考虑下循环依赖的问题,ModuleModel.destroy -> foreach -> ServiceBean.unexport -> ModuleModel.remove
还有一个问题是 ServiceBean 的 unexport 方法是谁调用的,理论上用户不会直接使用 ServiceBean 的,一般都是使用的 ReferenceConfig。如果 ServiceBean 的 unexport 是来自框架的调用,那么应该由外面的销毁管理器来统一清理。 |
我这边要做的就是service和ref的一个热加载的功能,service mesh里面控制面肯定也是需要这块的
针对ServiceBean的代码增加我看了#8789 #8867 没有完全理解
|
这里在 3.0 的最新版本中,最好是和 ModuleModel 一起来做的,一次热发布绑定到 ModuleModel 的生命周期。目前 Spring Context 也支持绑定到 ModuleModel 上,在 Spring Context 关闭后也会自动关闭 ModuleModel,然后连带清理环境。当然单个的 Config 也是支持独立热发布的。
这里想到一个方式,是否可以 ServiceConfig 向 ConfigManager 发送初始化或者销毁的通知,由 ConfigManager 来决策是否销毁这个引用。 |
这样是可以的 |
多实例化改造之后ModuleModel持有了 ConfigManager 和 ServiceRepository。和配置相关的放在 ConfigManager,和发布后服务相关的放在 ServiceRepositorory。Deployer 直接存储 exportedService 应该是有问题,最后都要收口到 ConfigManager 和 ServiceRepository。 |
unexport add remove config