-
Notifications
You must be signed in to change notification settings - Fork 780
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 #506
Conversation
# Conflicts: # adapter/adapter-common/src/main/java/org/dromara/dynamictp/adapter/common/DtpAdapterListener.java # core/src/main/java/org/dromara/dynamictp/core/monitor/collector/MicroMeterCollector.java # core/src/main/java/org/dromara/dynamictp/core/monitor/collector/jmx/JMXCollector.java # example/example-nacos-cloud/src/main/resources/dynamic-tp-nacos-cloud-demo-dtp-dev.yml # extension/extension-limiter-redis/src/main/java/org/dromara/dynamictp/extension/limiter/redis/ratelimiter/NotifyRedisRateLimiterFilter.java # spring/src/main/java/org/dromara/dynamictp/spring/DtpPostProcessor.java # spring/src/main/java/org/dromara/dynamictp/spring/annotation/DtpBeanDefinitionRegistrar.java # test/test-core/src/test/resources/postprocessor-dtp-dev.yml
example/example-nacos-cloud/pom.xml
Outdated
<dependency> | ||
<groupId>org.dromara.dynamictp</groupId> | ||
<artifactId>dynamic-tp-spring</artifactId> | ||
<scope>compile</scope> |
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.
为啥加这依赖呢,删掉吧
<groupId>javax.annotation</groupId> | ||
<artifactId>javax.annotation-api</artifactId> | ||
<scope>compile</scope> | ||
</dependency> |
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.
还有这个,没用到不要引入
这个就是因为报错说找不到相关的依赖idea让我加的,上面那个也是的
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.
这个模块压根没用到这个依赖,为啥让引入呢,就是因为引入了这个依赖,没有指定版本,才导致级联报错
不晓得啊,就是idea让加之后就没报错了。。。
<dependency> | ||
<groupId>org.dromara.dynamictp</groupId> | ||
<artifactId>dynamic-tp-spring</artifactId> | ||
<scope>compile</scope> |
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.
同上
@@ -0,0 +1,21 @@ | |||
package org.dromara.dynamictp.core.monitor.collector.jmx; |
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.
新的文件需要加上License,可以使用idea插件checkstyle,导入.github中的checkstyle.xml校验下
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.
好的
*/ | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public class VTExecutorStats extends Metrics { |
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.
不要单独建VTExecutorStats,还是复用之前的ThreadPoolStats,可以改名为ExecutorStats,新加executorName、executorAliasName字段,同时保留poolName、poolAliasName,并设置为@deprecated,在后续版本移除掉
@@ -227,8 +227,10 @@ private static void doRefresh(ExecutorWrapper executorWrapper, DtpExecutorProps | |||
if (!Objects.equals(executor.allowsCoreThreadTimeOut(), props.isAllowCoreThreadTimeOut())) { | |||
executor.allowCoreThreadTimeOut(props.isAllowCoreThreadTimeOut()); | |||
} | |||
// update queue | |||
updateQueueProps(executor, props); | |||
if (!executorWrapper.isVirtualThreadExecutor()) { |
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.
不用加判断单独处理了吧,虚拟线程执行该方法也不会有副作用
if (!Objects.equals(currentRejectHandlerType, props.getRejectedHandlerType())) { | ||
val rejectHandler = RejectHandlerGetter.buildRejectedHandler(props.getRejectedHandlerType()); | ||
executorWrapper.setRejectHandler(rejectHandler); | ||
if (!executorWrapper.isVirtualThreadExecutor()) { |
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.
|
||
if (!wrapper.isVirtualThreadExecutor()) { |
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
@@ -44,7 +45,7 @@ public final class CollectorHandler { | |||
|
|||
private CollectorHandler() { | |||
List<MetricsCollector> loadedCollectors = ExtensionServiceLoader.get(MetricsCollector.class); | |||
loadedCollectors.forEach(collector -> COLLECTORS.put(collector.type().toLowerCase(), collector)); | |||
loadedCollectors.forEach(collector -> COLLECTORS.put(collector.type(), collector)); |
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.
解决冲突有问题?toLowerCase()咋删了
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.
没印象了😂
* @create 2024/11/5 18:29 | ||
*/ | ||
public class VTExecutorStatsJMX implements VTExecutorStatsMXBean { | ||
|
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.
可以删掉
@@ -177,6 +180,8 @@ public void initialize() { | |||
AwareManager.register(this); | |||
} else if (isThreadPoolExecutor()) { | |||
AwareManager.register(this); | |||
} else if (isVirtualThreadExecutor()) { | |||
AwareManager.register(this); |
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.
用 || 关系就行了
dependencies/pom.xml
Outdated
@@ -15,8 +15,8 @@ | |||
<revision>1.1.9.1-3.x</revision> | |||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |||
|
|||
<maven.compiler.source>17</maven.compiler.source> | |||
<maven.compiler.target>17</maven.compiler.target> | |||
<maven.compiler.source>21</maven.compiler.source> |
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.
编译打包还是用17,保证前后兼容
BlockingQueue<Runnable> taskQueue; | ||
if (clazz.equals(EagerDtpExecutor.class)) { | ||
taskQueue = new TaskQueue(props.getQueueCapacity()); | ||
} else if (clazz.equals(PriorityDtpExecutor.class)) { | ||
taskQueue = new PriorityBlockingQueue<>(props.getQueueCapacity(), PriorityDtpExecutor.getRunnableComparator()); | ||
} else if (clazz.equals(VirtualThreadExecutorProxy.class)) { | ||
if (!VersionUtil.getVersion().equals(JDK_VERSION_21)) { | ||
log.warn("DynamicTp virtual thread executor {} register warn: update your JDK version or don't use virtual thread executor!", props.getThreadPoolName()); |
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.
应该是 >= 21
@Override | ||
public void execute(Runnable command) { | ||
command = getEnhancedTask(command); | ||
EnhancedRunnable.of(command, this); |
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.
包装后返回值没用?
No description provided.