-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: support triple thread monitor #711
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
feat: support triple thread monitor #711
Conversation
Codecov Report
@@ Coverage Diff @@
## master #711 +/- ##
=============================================
+ Coverage 51.74% 70.56% +18.82%
- Complexity 78 84 +6
=============================================
Files 291 296 +5
Lines 8187 8317 +130
Branches 1142 1157 +15
=============================================
+ Hits 4236 5869 +1633
+ Misses 3500 1759 -1741
- Partials 451 689 +238 Continue to review full report at Codecov.
|
|
|
||
| if (threadPoolExecutor != null) { | ||
| new RpcThreadPoolMonitor(threadPoolExecutor).start(); | ||
| new RpcThreadPoolMonitor(threadPoolExecutor, LoggerConstant.BOLT_THREAD_LOGGER_NAME) |
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.
这个对象要记录下来,start 的时候 new 出来的话, stop 的时候要销毁
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.
已修复 @ujjboy
| ThreadPoolExecutor threadPoolExecutor = tripleServer.getBizThreadPool(); | ||
|
|
||
| // 加入线程监测? | ||
| new RpcThreadPoolMonitor(threadPoolExecutor, LoggerConstant.TRIPLE_THREAD_LOGGER_NAME) |
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.
这个对象要记录下来,start 的时候 new 出来的话, stop 的时候要销毁
Codecov Report
@@ Coverage Diff @@
## master #711 +/- ##
=============================================
+ Coverage 51.74% 70.68% +18.94%
- Complexity 78 84 +6
=============================================
Files 291 296 +5
Lines 8187 8350 +163
Branches 1142 1163 +21
=============================================
+ Hits 4236 5902 +1666
+ Misses 3500 1758 -1742
- Partials 451 690 +239 Continue to review full report at Codecov.
|
| sleep(30000); | ||
| } catch (InterruptedException e) { | ||
| LOGGER.error("Error happen the thread pool watch sleep "); | ||
| logger.error("Error happen the thread pool watch sleep "); |
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.
这句错误的英文改下吧,读起来不通顺啊。
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.
已修改
| } | ||
|
|
||
| try { | ||
| sleep(30000); |
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.
这个值 30000 建议做成一个属性 或者一个配置项
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.
已修改
...t-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/common/RpcThreadPoolMonitor.java
Outdated
Show resolved
Hide resolved
| if (this.monitor != null) { | ||
| this.monitor.interrupt(); | ||
| } | ||
| this.threadPoolExecutor = null; |
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.
start() stop() 能随意调的话,这个 threadPoolExecutor 可能不需要置为 null。
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.
我添加了 threadPoolExecutor 的set方法,每次调用前重新设置 threadPoolExecutor 吧
| } | ||
|
|
||
| public void stop() { | ||
| this.active = false; |
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.
想了下 start() stop() 如果被并发调的话, active 换成 AtomicBoolean 是不是更合理一些?
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.
改成AtomicBoolean 也不能保证并发情况下的线程安全,我在 start 和 stop 方法上加了两个 synchronized 锁来保证线程安全
ujjboy
left a comment
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.
LGTM
glmapper
left a comment
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.
LGTM
feat: support triple thread monitor.