-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
[ISSUE#1815]Adding lifecycle interface and resolve the service downtime caused by thread leak #2927
Conversation
update 1.3.0 beta
…ome unit test cases.
@chuntaojun @yanlinly @wangweizZZ please help to review this pr's codes. |
client/src/main/java/com/alibaba/nacos/client/config/http/ServerHttpAgent.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/alibaba/nacos/common/lifecycle/ResourceLifeCycleManager.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public void doStart() throws Exception { | ||
this.serverHttpAgent.doStart(); |
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.
use this.serverHttpAgent.start()
|
||
@Override | ||
public void doStop() throws Exception { | ||
this.serverHttpAgent.doStop(); |
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.
use this.serverHttpAgent.stop()
public void register(AbstractLifeCycle instance) { | ||
if (!lifeCycleResources.contains(instance)) { | ||
synchronized(this) { | ||
lockers.put(instance, new Object()); |
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.
maybe need double check?
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.
Yes, you can see @chuntaojun 's review comments above.
提一个建议 |
Okay, good advice, I will optimize this pr's codes.Thanks. |
漏了一个建议,是不是可以弄个startable和closable,让lifecycle继承它们 |
In last new commit code, I have already defined the closeable interface. |
Ok节日快乐 |
…gService class level at the same time.
client/src/main/java/com/alibaba/nacos/client/config/http/ServerHttpAgent.java
Outdated
Show resolved
Hide resolved
client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java
Outdated
Show resolved
Hide resolved
client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java
Show resolved
Hide resolved
client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java
Outdated
Show resolved
Hide resolved
I adjust and optimize some codes, please help to review this pr again, thanks. @chuntaojun @yanlinly @wangweizZZ |
I'm sorry to have made so many suggestions, |
I optimzie original pr's codes, and think it's too complex.Because, Closeable interface is located in detailed implment class level, and lifecycle interface is aimed to be defined and implemented in configservice and namingservice.We put init logical codes in claas constructor method. |
This PR is really complicated, and it's a big change. I'm a Virgo. Maybe I'm a little picky. Smile |
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.
I have some suggestion for this PR.
- I think there no need to add
this
when using member normally. It's ok for usedthis
in the set method and constructor uniformly. - Why add
destroyXXXService
in factory? I think that it's enough for callingshutdown
ordestory
method directly. It is same as call factory.destoryXXXService(XXXService)
api/src/main/java/com/alibaba/nacos/api/config/ConfigFactory.java
Outdated
Show resolved
Hide resolved
api/src/main/java/com/alibaba/nacos/api/naming/NamingFactory.java
Outdated
Show resolved
Hide resolved
client/src/main/java/com/alibaba/nacos/client/config/http/ServerHttpAgent.java
Outdated
Show resolved
Hide resolved
My answer: |
… into feature_lifecycle
…d set method in the class and fix some unit test cases.
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 seems no large issues. Just one unused import.
api/src/main/java/com/alibaba/nacos/api/naming/NamingFactory.java
Outdated
Show resolved
Hide resolved
import com.alibaba.nacos.common.utils.JacksonUtils; | ||
|
||
import com.alibaba.nacos.common.utils.ThreadUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.util.*; |
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.
don't import *
api/src/main/java/com/alibaba/nacos/api/exception/NacosException.java
Outdated
Show resolved
Hide resolved
client/src/main/java/com/alibaba/nacos/client/config/http/HttpAgent.java
Outdated
Show resolved
Hide resolved
@@ -482,12 +499,21 @@ public void run() { | |||
|
|||
private void init(Properties properties) { | |||
|
|||
timeout = Math.max(NumberUtils.toInt(properties.getProperty(PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT), | |||
this.timeout = Math.max(ConvertUtils.toInt(properties.getProperty(PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT), |
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.
ConvertUtils 这块为什么要改呢
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.
再下一次提交中修改回原来的NumberUtils
common/src/main/java/com/alibaba/nacos/common/lifecycle/LifeCycle.java
Outdated
Show resolved
Hide resolved
client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java
Outdated
Show resolved
Hide resolved
client/src/main/java/com/alibaba/nacos/client/naming/backups/FailoverReactor.java
Show resolved
Hide resolved
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
Please do not create a Pull Request without creating an issue first.
What is the purpose of the change
The related issue is [ISSUE #1815 ]
(1)Adding lifecycle interface and resolve the service downtime caused by thread leak .
Brief changelog
(1)Define and implement the lifecycle interface and related abstract class codes.
(2)Add lifecycle related codes.
(3)Adjust the ServerHttpAgent and MetricsHttpAgent class to implement the lifecycle interface.
Verifying this change
I have already add the unit test codes.
Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.