You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "kexianjun (GitHub)" <gi...@apache.org> on 2019/01/12 11:36:24 UTC
[GitHub] [incubator-dubbo] kexianjun opened pull request #3213:
[Dubbo 3151] Optimize heartbeat mechanism
## What is the purpose of the change
Optimize heartbeat mechanism
fix #3151
## Brief changelog
0. adjust hashedWheelTimer's instance, make it only one instance for heartbeat tasks and reconnect tasks, and make it's per tick duration to 1 second.
1. initialize heartbeat task and reconnect task for each channel when it is connected.
2. initialize hashedWheelTimer on HeartbeatHandler instinstead of that when HeaderExchangeServer or HeaderExchangeClient initialize.
3. recalculate next tick duration for heartbeat task and reconnect task when it's task has done instead of using fixed duration.
and also I have provided a version of this optimization with detail log when heartbeat task or reconnect task has triggered in https://github.com/kexianjun/incubator-dubbo/tree/optimize_heart_with_log to make it convenient to test this optimization.
## Verifying this change
XXXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
- [x] Make sure there is a [GITHUB_issue](https://github.com/apache/incubator-dubbo/issues) field for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
- [x] Format the pull request title like `[Dubbo-XXX] Fix UnknownException when host config not exist #XXX`. Each commit in the pull request should have a meaningful subject line and body.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/incubator-dubbo/tree/master/dubbo-test).
- [ ] Run `mvn clean install -DskipTests=false` & `mvn clean test-compile failsafe:integration-test` to make sure unit-test and integration-test pass.
- [ ] If this contribution is large, please follow the [Software Donation Guide](https://github.com/apache/incubator-dubbo/wiki/Software-donation-guide).
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3213 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] khanimteyaz commented on pull request
#3213: [Dubbo 3151] Optimize heartbeat mechanism
Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
I think 1000 (second argument) we can defined as constant as DEFAULT_TICK_DURATION=1000; and use it. It will provide a better readability. What do you say?
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3213 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] codecov-io commented on issue #3213:
[Dubbo 3151] Optimize heartbeat mechanism
Posted by "codecov-io (GitHub)" <gi...@apache.org>.
# [Codecov](https://codecov.io/gh/apache/incubator-dubbo/pull/3213?src=pr&el=h1) Report
> Merging [#3213](https://codecov.io/gh/apache/incubator-dubbo/pull/3213?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-dubbo/commit/5298afdf401185876edd49b0ad5755f8f618e4cb?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `86.84%`.
[](https://codecov.io/gh/apache/incubator-dubbo/pull/3213?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #3213 +/- ##
============================================
- Coverage 63.67% 63.65% -0.02%
Complexity 75 75
============================================
Files 652 652
Lines 28200 28151 -49
Branches 4781 4777 -4
============================================
- Hits 17955 17919 -36
+ Misses 7985 7980 -5
+ Partials 2260 2252 -8
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-dubbo/pull/3213?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...c/main/java/org/apache/dubbo/common/Constants.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3213/diff?src=pr&el=tree#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb21tb24vQ29uc3RhbnRzLmphdmE=) | `92.85% <ø> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [.../exchange/support/header/HeaderExchangeClient.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3213/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L2hlYWRlci9IZWFkZXJFeGNoYW5nZUNsaWVudC5qYXZh) | `64.28% <100%> (-16.6%)` | `0 <0> (ø)` | |
| [...oting/exchange/support/header/HeaderExchanger.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3213/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L2hlYWRlci9IZWFkZXJFeGNoYW5nZXIuamF2YQ==) | `100% <100%> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [...ubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3213/diff?src=pr&el=tree#diff-ZHViYm8tcnBjL2R1YmJvLXJwYy1kdWJiby9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZHViYm8vcnBjL3Byb3RvY29sL2R1YmJvL0NoYW5uZWxXcmFwcGVkSW52b2tlci5qYXZh) | `47.91% <100%> (-2.09%)` | `0 <0> (ø)` | |
| [.../exchange/support/header/HeaderExchangeServer.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3213/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L2hlYWRlci9IZWFkZXJFeGNoYW5nZVNlcnZlci5qYXZh) | `61.25% <100%> (+1.42%)` | `0 <0> (ø)` | :arrow_down: |
| [...ting/exchange/support/header/HeartbeatHandler.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3213/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L2hlYWRlci9IZWFydGJlYXRIYW5kbGVyLmphdmE=) | `83.33% <77.77%> (-1.12%)` | `0 <0> (ø)` | |
| [...ing/exchange/support/header/AbstractTimerTask.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3213/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L2hlYWRlci9BYnN0cmFjdFRpbWVyVGFzay5qYXZh) | `68.42% <80%> (+1.75%)` | `0 <0> (ø)` | :arrow_down: |
| [...ng/exchange/support/header/ReconnectTimerTask.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3213/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L2hlYWRlci9SZWNvbm5lY3RUaW1lclRhc2suamF2YQ==) | `80.95% <88.88%> (-2.39%)` | `0 <0> (ø)` | |
| [...ng/exchange/support/header/HeartbeatTimerTask.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3213/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L2hlYWRlci9IZWFydGJlYXRUaW1lclRhc2suamF2YQ==) | `88.46% <90.9%> (+14.77%)` | `0 <0> (ø)` | :arrow_down: |
| ... and [20 more](https://codecov.io/gh/apache/incubator-dubbo/pull/3213/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-dubbo/pull/3213?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-dubbo/pull/3213?src=pr&el=footer). Last update [5298afd...9c77d1f](https://codecov.io/gh/apache/incubator-dubbo/pull/3213?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3213 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] khanimteyaz commented on pull request
#3213: [Dubbo 3151] Optimize heartbeat mechanism
Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
I think we should not allowed to override getTick, if sub class implement this and set value as zero then we might cause issue where we are using tick value for reput , e.g see HeartbeatTimerTask.java doTask method where we are checking whether heart beat value is > getTick and then creating request.
Could you double check this one, I might be wrong.
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3213 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] kexianjun closed pull request #3213:
[Dubbo 3151] Optimize heartbeat mechanism
Posted by "kexianjun (GitHub)" <gi...@apache.org>.
[ pull request closed by kexianjun ]
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3213 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] kexianjun commented on issue #3213: [Dubbo
3151] Optimize heartbeat mechanism
Posted by "kexianjun (GitHub)" <gi...@apache.org>.
> Seems like just put the heartbeat into pipeline.
> Personally think that Header's abstraction is better, and about the heartbeat operation (on, off) I think it should still be done in the Header layer. Regarding the details of the heartbeat (check, reconnect), we can implement it in other ways.
I think it's more appropriate to put and start heartbeat in HeartbeatHandler,since its responsibility is as its name described, do something about heartbeat,such as record the last read and write time for recalculating the next heartbeat(or reconnect) task's trigger time, when a channel is connected, start heartbeat tasks for it, and handler heartbeat packets.And as I've suggested in #3151 , each channel has its own heartbeat tasks, we should put heartbeat into handler chain.
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3213 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] khanimteyaz commented on pull request
#3213: [Dubbo 3151] Optimize heartbeat mechanism
Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
Same as above, separate Assert check with specific message.
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3213 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] khanimteyaz commented on pull request
#3213: [Dubbo 3151] Optimize heartbeat mechanism
Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
I think putting both the null check together make it defficult to trace for which this exception has been raised.
I think we should refactor this to
```
Assert.notNull(channel,"Channel can't be null');
Assert.notNull(tick,"Tick can't be null");
```
Assert is under package of org.apache.dubbo.common.utils. They way it works is, if the given first argument is null then it throws IllegalArgumentException with messaged getting passed here as second argument.
What do you say?
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3213 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] khanimteyaz commented on pull request
#3213: [Dubbo 3151] Optimize heartbeat mechanism
Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
Are we expecting reput to be gets overriden by subclass. If getting overridern then expectation of not having null value in timeout may break, because subclass may allow it be null. EIther we sould explicity document to be not null value or make it final method so that sub class may not override it.
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3213 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] kexianjun commented on issue #3213: [Dubbo
3151] Optimize heartbeat mechanism
Posted by "kexianjun (GitHub)" <gi...@apache.org>.
closed since some opinions not yet reached
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3213 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org