-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use multiple separate counters for the single service with multiple protocols. #222
Conversation
Codecov Report
@@ Coverage Diff @@
## 5.4 #222 +/- ##
============================================
+ Coverage 71.13% 71.49% +0.35%
Complexity 961 961
============================================
Files 341 341
Lines 13654 14238 +584
Branches 2208 2290 +82
============================================
+ Hits 9713 10179 +466
- Misses 2763 2865 +102
- Partials 1178 1194 +16
Continue to review full report at Codecov.
|
String protocol = serverConfig.getProtocol(); | ||
String key = providerConfig.buildKey() + ":" + protocol; | ||
AtomicInteger cnt = EXPORTED_KEYS.get(key); // 计数器 | ||
if (cnt != null && cnt.get() > 0) { |
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.
这里应该记录下已经增加的计数器,而不是全部计数器。 例如发布A、B、C协议,发到 B 的时候失败,应该只需要减去 A 的计数器即可,B 和 C 的计数器都不需要减。
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.
这个抛出异常的时候,比较难记录.. register();因为这行代码可能跑错.
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.
如果 register()
抛错, 那说明 A B C 都发布完了。 我举的例子应该是还在发 B 协议的时候。
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.
改掉了.
@@ -164,6 +176,7 @@ private void doExport() { | |||
if (serverConfig.isAutoStart()) { | |||
server.start(); | |||
} | |||
hasExportedInCurrent.put(serverConfig.getProtocol(), true); |
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.
我看计数器加1的地方是在 131 行的地方加的,在这个位置记录加1的情况应该会有不对应的问题。
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.
这个地方是为了记录本次 export 成功了哪个协议.是一个局部的操作.
|
||
Assert.fail(); | ||
} catch (Throwable e) { | ||
Assert.assertTrue(true); |
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.
这行没用
Motivation:
Fix sofastack/sofa-rpc-boot-projects#67
Modification:
Describe the idea and modifications you've done.
Result:
Fixes sofastack/sofa-rpc-boot-projects#67