-
Notifications
You must be signed in to change notification settings - Fork 783
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 #483] Virtual thread compatible #508
Changes from 44 commits
f5f25f5
cc83c79
0d0c160
74f64c6
17a913b
706d887
f05dd26
a85826c
4a93554
4495be0
a729e11
6a1e1a9
3755c8b
db44cd8
0a38447
f4b5804
c791fd2
ebc5e0e
e29ebd4
554f3f1
3dc7ee6
0b18056
4154092
d9b5d4d
119d2e2
7944b9b
33a4214
fe40c63
f449863
c40e854
4027731
2f7a99d
a812aff
a96658e
b4e5dcb
7eaf4ca
15929e1
8457c52
69ec089
84d4d30
21e3b41
d063f36
36dc4c4
36cd88a
64afeae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,17 +29,17 @@ | |
**/ | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public class ThreadPoolStats extends Metrics { | ||
public class ExecutorStats extends Metrics { | ||
|
||
/** | ||
* 线程池名字 | ||
* 执行器名字 | ||
*/ | ||
private String poolName; | ||
private String executorName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JMXCollector没有用到此名字 |
||
|
||
/** | ||
* 线程池别名 | ||
* 执行器别名 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这两个名字字段如果标注@deprecated的话需要兼容,不然直接改名就好? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
行,我看看要是没有其他地方用到这两个字段我就去掉算了 |
||
*/ | ||
private String poolAliasName; | ||
private String executorAliasName; | ||
|
||
/** | ||
* 核心线程数 | ||
|
@@ -51,6 +51,31 @@ public class ThreadPoolStats extends Metrics { | |
*/ | ||
private int maximumPoolSize; | ||
|
||
/** | ||
* 正在执行任务的活跃线程大致总数 | ||
*/ | ||
private int activeCount; | ||
|
||
/** | ||
* 大致任务总数 | ||
*/ | ||
private long taskCount; | ||
|
||
/** | ||
* 执行超时任务数量 | ||
*/ | ||
private long runTimeoutCount; | ||
|
||
/** | ||
* 是否为DtpExecutor | ||
*/ | ||
private boolean dynamic; | ||
|
||
/** | ||
* 是否为虚拟线程执行器 | ||
*/ | ||
private boolean isVirtualExecutor; | ||
|
||
/** | ||
* 空闲时间 (ms) | ||
*/ | ||
|
@@ -81,16 +106,6 @@ public class ThreadPoolStats extends Metrics { | |
*/ | ||
private int queueRemainingCapacity; | ||
|
||
/** | ||
* 正在执行任务的活跃线程大致总数 | ||
*/ | ||
private int activeCount; | ||
|
||
/** | ||
* 大致任务总数 | ||
*/ | ||
private long taskCount; | ||
|
||
/** | ||
* 已执行完成的大致任务总数 | ||
*/ | ||
|
@@ -121,16 +136,6 @@ public class ThreadPoolStats extends Metrics { | |
*/ | ||
private String rejectHandlerName; | ||
|
||
/** | ||
* 是否DtpExecutor线程池 | ||
*/ | ||
private boolean dynamic; | ||
|
||
/** | ||
* 执行超时任务数量 | ||
*/ | ||
private long runTimeoutCount; | ||
|
||
/** | ||
* 在队列等待超时任务数量 | ||
*/ | ||
|
@@ -185,4 +190,5 @@ public class ThreadPoolStats extends Metrics { | |
* 满足99.9%的任务执行所需的最低耗时 | ||
*/ | ||
private double tp999; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,5 @@ | |
**/ | ||
@Data | ||
public class Metrics { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
package org.dromara.dynamictp.core.converter; | ||
|
||
import lombok.val; | ||
import org.dromara.dynamictp.common.entity.ThreadPoolStats; | ||
import org.dromara.dynamictp.common.entity.ExecutorStats; | ||
import org.dromara.dynamictp.common.entity.TpMainFields; | ||
import org.dromara.dynamictp.core.executor.DtpExecutor; | ||
import org.dromara.dynamictp.core.monitor.PerformanceProvider; | ||
|
@@ -53,37 +53,39 @@ public static TpMainFields toMainFields(ExecutorWrapper executorWrapper) { | |
return mainFields; | ||
} | ||
|
||
public static ThreadPoolStats toMetrics(ExecutorWrapper wrapper) { | ||
public static ExecutorStats toMetrics(ExecutorWrapper wrapper) { | ||
ExecutorAdapter<?> executor = wrapper.getExecutor(); | ||
if (executor == null) { | ||
return null; | ||
} | ||
ThreadPoolStatProvider provider = wrapper.getThreadPoolStatProvider(); | ||
PerformanceProvider performanceProvider = provider.getPerformanceProvider(); | ||
val performanceSnapshot = performanceProvider.getSnapshotAndReset(); | ||
ThreadPoolStats poolStats = convertCommon(executor); | ||
poolStats.setPoolName(wrapper.getThreadPoolName()); | ||
poolStats.setPoolAliasName(wrapper.getThreadPoolAliasName()); | ||
poolStats.setRunTimeoutCount(provider.getRunTimeoutCount()); | ||
poolStats.setQueueTimeoutCount(provider.getQueueTimeoutCount()); | ||
poolStats.setRejectCount(provider.getRejectedTaskCount()); | ||
poolStats.setDynamic(executor instanceof DtpExecutor); | ||
ExecutorStats executorStats = convertCommon(executor); | ||
executorStats.setExecutorName(wrapper.getThreadPoolName()); | ||
executorStats.setExecutorAliasName(wrapper.getThreadPoolAliasName()); | ||
executorStats.setRunTimeoutCount(provider.getRunTimeoutCount()); | ||
executorStats.setQueueTimeoutCount(provider.getQueueTimeoutCount()); | ||
executorStats.setRejectCount(provider.getRejectedTaskCount()); | ||
|
||
poolStats.setTps(performanceSnapshot.getTps()); | ||
poolStats.setAvg(performanceSnapshot.getAvg()); | ||
poolStats.setMaxRt(performanceSnapshot.getMaxRt()); | ||
poolStats.setMinRt(performanceSnapshot.getMinRt()); | ||
poolStats.setTp50(performanceSnapshot.getTp50()); | ||
poolStats.setTp75(performanceSnapshot.getTp75()); | ||
poolStats.setTp90(performanceSnapshot.getTp90()); | ||
poolStats.setTp95(performanceSnapshot.getTp95()); | ||
poolStats.setTp99(performanceSnapshot.getTp99()); | ||
poolStats.setTp999(performanceSnapshot.getTp999()); | ||
return poolStats; | ||
executorStats.setVirtualExecutor(wrapper.isVirtualThreadExecutor()); | ||
|
||
executorStats.setDynamic(executor instanceof DtpExecutor); | ||
executorStats.setTps(performanceSnapshot.getTps()); | ||
executorStats.setAvg(performanceSnapshot.getAvg()); | ||
executorStats.setMaxRt(performanceSnapshot.getMaxRt()); | ||
executorStats.setMinRt(performanceSnapshot.getMinRt()); | ||
executorStats.setTp50(performanceSnapshot.getTp50()); | ||
executorStats.setTp75(performanceSnapshot.getTp75()); | ||
executorStats.setTp90(performanceSnapshot.getTp90()); | ||
executorStats.setTp95(performanceSnapshot.getTp95()); | ||
executorStats.setTp99(performanceSnapshot.getTp99()); | ||
executorStats.setTp999(performanceSnapshot.getTp999()); | ||
return executorStats; | ||
} | ||
|
||
private static ThreadPoolStats convertCommon(ExecutorAdapter<?> executor) { | ||
ThreadPoolStats poolStats = new ThreadPoolStats(); | ||
private static ExecutorStats convertCommon(ExecutorAdapter<?> executor) { | ||
ExecutorStats poolStats = new ExecutorStats(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 变量名也改了 |
||
poolStats.setCorePoolSize(executor.getCorePoolSize()); | ||
poolStats.setMaximumPoolSize(executor.getMaximumPoolSize()); | ||
poolStats.setPoolSize(executor.getPoolSize()); | ||
|
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.
OK