From b1c24c42fe378b7e60bc1e3477b9393136062290 Mon Sep 17 00:00:00 2001 From: yangsanity Date: Thu, 2 Mar 2023 10:36:45 +0800 Subject: [PATCH] rename maxPoolNum to maximumPoolSize --- .../support/AbstractBuildThreadPoolTemplate.java | 12 +++++++++--- .../core/executor/support/ThreadPoolBuilder.java | 12 ++++++++++-- .../adpter/ThreadPoolTaskExecutorAdapter.java | 2 +- .../service/AbstractDynamicThreadPoolService.java | 2 +- .../core/DynamicThreadPoolSubscribeConfig.java | 2 +- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/AbstractBuildThreadPoolTemplate.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/AbstractBuildThreadPoolTemplate.java index 8f463319613..ab797d3423a 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/AbstractBuildThreadPoolTemplate.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/AbstractBuildThreadPoolTemplate.java @@ -63,7 +63,7 @@ public static ThreadPoolExecutor buildPool(ThreadPoolInitParam initParam) { ThreadPoolExecutor executorService; try { executorService = new ThreadPoolExecutorTemplate(initParam.getCorePoolNum(), - initParam.getMaxPoolNum(), + initParam.getMaximumPoolSize(), initParam.getKeepAliveTime(), initParam.getTimeUnit(), initParam.getWorkQueue(), @@ -97,7 +97,7 @@ public static ThreadPoolExecutor buildFastPool(ThreadPoolInitParam initParam) { FastThreadPoolExecutor fastThreadPoolExecutor; try { fastThreadPoolExecutor = new FastThreadPoolExecutor(initParam.getCorePoolNum(), - initParam.getMaxPoolNum(), + initParam.getMaximumPoolSize(), initParam.getKeepAliveTime(), initParam.getTimeUnit(), taskQueue, @@ -123,7 +123,7 @@ public static DynamicThreadPoolExecutor buildDynamicPool(ThreadPoolInitParam ini try { dynamicThreadPoolExecutor = new DynamicThreadPoolExecutor( initParam.getCorePoolNum(), - initParam.getMaxPoolNum(), + initParam.getMaximumPoolSize(), initParam.getKeepAliveTime(), initParam.getTimeUnit(), initParam.getExecuteTimeOut(), @@ -150,8 +150,14 @@ public static class ThreadPoolInitParam { private Integer corePoolNum; + /** + * @deprecated use {@link #maximumPoolSize} + */ + @Deprecated private Integer maxPoolNum; + private Integer maximumPoolSize; + private Long keepAliveTime; private TimeUnit timeUnit; diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ThreadPoolBuilder.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ThreadPoolBuilder.java index b1a830f9c0f..d7df8525dde 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ThreadPoolBuilder.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ThreadPoolBuilder.java @@ -150,13 +150,21 @@ public ThreadPoolBuilder corePoolSize(int corePoolSize) { return this; } + /** + * @deprecated Use {@link #maximumPoolSize} + */ + @Deprecated + public ThreadPoolBuilder maxPoolNum(int maxPoolSize) { + return this.maximumPoolSize(maxPoolSize); + } + /** * Max pool num. * * @param maxPoolSize max pool num * @return thread-pool builder */ - public ThreadPoolBuilder maxPoolNum(int maxPoolSize) { + public ThreadPoolBuilder maximumPoolSize(int maxPoolSize) { this.maxPoolSize = maxPoolSize; if (maxPoolSize < this.corePoolSize) { this.corePoolSize = maxPoolSize; @@ -438,7 +446,7 @@ private static AbstractBuildThreadPoolTemplate.ThreadPoolInitParam buildInitPara initParam = new AbstractBuildThreadPoolTemplate.ThreadPoolInitParam(builder.threadFactory); } initParam.setCorePoolNum(builder.corePoolSize) - .setMaxPoolNum(builder.maxPoolSize) + .setMaximumPoolSize(builder.maxPoolSize) .setKeepAliveTime(builder.keepAliveTime) .setCapacity(builder.capacity) .setExecuteTimeOut(builder.executeTimeOut) diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/adpter/ThreadPoolTaskExecutorAdapter.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/adpter/ThreadPoolTaskExecutorAdapter.java index 3dea2eb1f07..283942db4e2 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/adpter/ThreadPoolTaskExecutorAdapter.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/adpter/ThreadPoolTaskExecutorAdapter.java @@ -79,7 +79,7 @@ public DynamicThreadPoolExecutor unwrap(Object executor) { ThreadPoolBuilder threadPoolBuilder = ThreadPoolBuilder.builder() .dynamicPool() .corePoolSize(threadPoolTaskExecutor.getCorePoolSize()) - .maxPoolNum(threadPoolTaskExecutor.getMaxPoolSize()) + .maximumPoolSize(threadPoolTaskExecutor.getMaxPoolSize()) .keepAliveTime(threadPoolTaskExecutor.getKeepAliveSeconds()) .timeUnit(TimeUnit.SECONDS) .allowCoreThreadTimeOut(threadPoolExecutor.allowsCoreThreadTimeOut()) diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/service/AbstractDynamicThreadPoolService.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/service/AbstractDynamicThreadPoolService.java index abf6e989aa1..4057f98700d 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/service/AbstractDynamicThreadPoolService.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/service/AbstractDynamicThreadPoolService.java @@ -40,7 +40,7 @@ public ThreadPoolExecutor buildDynamicThreadPoolExecutor(DynamicThreadPoolRegist ThreadPoolExecutor dynamicThreadPoolExecutor = ThreadPoolBuilder.builder() .threadPoolId(registerParameter.getThreadPoolId()) .corePoolSize(registerParameter.getCorePoolSize()) - .maxPoolNum(registerParameter.getMaximumPoolSize()) + .maximumPoolSize(registerParameter.getMaximumPoolSize()) .workQueue(BlockingQueueTypeEnum.createBlockingQueue(registerParameter.getBlockingQueueType().getType(), registerParameter.getCapacity())) .threadFactory(registerParameter.getThreadNamePrefix()) .threadFactory(registerParameter.getThreadFactory()) diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DynamicThreadPoolSubscribeConfig.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DynamicThreadPoolSubscribeConfig.java index 5a087427de7..804c0864454 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DynamicThreadPoolSubscribeConfig.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DynamicThreadPoolSubscribeConfig.java @@ -43,7 +43,7 @@ public class DynamicThreadPoolSubscribeConfig { private final ExecutorService configRefreshExecutorService = ThreadPoolBuilder.builder() .corePoolSize(1) - .maxPoolNum(2) + .maximumPoolSize(2) .keepAliveTime(2000) .timeUnit(TimeUnit.MILLISECONDS) .workQueue(BlockingQueueTypeEnum.SYNCHRONOUS_QUEUE)