Optimize the close and connect operations of AbstractClient#3435
Optimize the close and connect operations of AbstractClient#3435manzhizhen merged 7 commits intoapache:masterfrom
Conversation
…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 Report
@@ 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 Continue to review full report at Codecov.
|
|
|
||
| try { | ||
|
|
||
| if (isClosed()) { |
There was a problem hiding this comment.
in case of reconnect would it create any issue? as reconnect call the connect method?
There was a problem hiding this comment.
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成功。
) * 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>
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.