Skip to content

Optimize the close and connect operations of AbstractClient#3435

Merged
manzhizhen merged 7 commits intoapache:masterfrom
manzhizhen:opti_client_close
Oct 15, 2020
Merged

Optimize the close and connect operations of AbstractClient#3435
manzhizhen merged 7 commits intoapache:masterfrom
manzhizhen:opti_client_close

Conversation

@manzhizhen
Copy link
Copy Markdown

What is the purpose of the change

使AbstractClient的close操作和connect、disconnect操作一样,受到锁的保护,降低由于操作冲突而产生不确定性的概率;connect操作先判断client的close状态,如果client已经关闭,那么该client不需要重连。

The AbstractClient close operation is the same as the connect and disconnect operations, and is protected by the lock, which reduces the probability of uncertainty due to operation conflicts; the connect operation first determines the close state of the client. If the client is closed, the client does not need to be reconnected.

…connect operations, and is protected by the lock, which reduces the probability of uncertainty due to operation conflicts; the connect operation first determines the close state of the client. If the client is closed, the client does not need to be reconnected.
@codecov-io
Copy link
Copy Markdown

codecov-io commented Feb 3, 2019

Codecov Report

Merging #3435 into master will decrease coverage by 0.05%.
The diff coverage is 51.42%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3435      +/-   ##
============================================
- Coverage     59.11%   59.06%   -0.06%     
+ Complexity      509      507       -2     
============================================
  Files          1028     1028              
  Lines         41522    41534      +12     
  Branches       6039     6041       +2     
============================================
- Hits          24547    24530      -17     
- Misses        14203    14225      +22     
- Partials       2772     2779       +7     
Impacted Files Coverage Δ Complexity Δ
...pache/dubbo/remoting/transport/AbstractClient.java 63.01% <51.42%> (+0.32%) 0.00 <0.00> (ø)
...rg/apache/dubbo/remoting/utils/PayloadDropper.java 15.38% <0.00%> (-30.77%) 0.00% <0.00%> (ø%)
...ng/exchange/support/header/ReconnectTimerTask.java 50.00% <0.00%> (-9.10%) 0.00% <0.00%> (ø%)
...e/dubbo/remoting/transport/netty/NettyChannel.java 52.27% <0.00%> (-7.96%) 19.00% <0.00%> (-2.00%)
...mmon/threadpool/support/AbortPolicyWithReport.java 85.00% <0.00%> (-5.00%) 0.00% <0.00%> (ø%)
.../apache/dubbo/remoting/transport/AbstractPeer.java 63.04% <0.00%> (-4.35%) 0.00% <0.00%> (ø%)
...pache/dubbo/registry/support/AbstractRegistry.java 77.77% <0.00%> (-2.97%) 0.00% <0.00%> (ø%)
...a/org/apache/dubbo/monitor/dubbo/DubboMonitor.java 88.57% <0.00%> (-0.96%) 16.00% <0.00%> (-1.00%)
...ava/org/apache/dubbo/config/ServiceConfigBase.java 53.17% <0.00%> (-0.58%) 0.00% <0.00%> (ø%)
...apache/dubbo/common/extension/ExtensionLoader.java 75.33% <0.00%> (-0.23%) 0.00% <0.00%> (ø%)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d06e5e...fa863d9. Read the comment docs.


try {

if (isClosed()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case of reconnect would it create any issue? as reconnect call the connect method?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The client can't be reused, it can only be closed once. So, if you decide to close a client, then when you close it, even if this is reconnecting the client, you can't make reconnect successful.

client其实是不能复用的,只能关闭一次,所以,如果决定关闭一个client,那么将其close时,哪怕这是正在对这个client进行reconnect,也不能让reconnect成功。

@manzhizhen manzhizhen merged commit 7039c98 into apache:master Oct 15, 2020
chickenlj pushed a commit to chickenlj/incubator-dubbo that referenced this pull request Nov 25, 2020
)

* The AbstractClient close operation is the same as the connect and disconnect operations, and is protected by the lock, which reduces the probability of uncertainty due to operation conflicts; the connect operation first determines the close state of the client. If the client is closed, the client does not need to be reconnected.

* The judgment conditions of strengthening connect and close methods

Co-authored-by: Xin Wang <xin.victorwang@gmail.com>
AlbumenJ added a commit to AlbumenJ/dubbo that referenced this pull request May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants