From 97f4bd9ebd0c67f65ed2b66cc6d448cdc5f833eb Mon Sep 17 00:00:00 2001 From: "1115900427@qq.com" <1115900427@qq.com> Date: Sat, 24 Aug 2024 12:54:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Djdk8=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E4=B8=8D=E5=85=BC=E5=AE=B9springboot2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/META-INF/spring.factories | 3 +++ .../src/main/resources/META-INF/spring.factories | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 snail-job-client-starter/src/main/resources/META-INF/spring.factories create mode 100644 snail-job-common/snail-job-common-core/src/main/resources/META-INF/spring.factories diff --git a/snail-job-client-starter/src/main/resources/META-INF/spring.factories b/snail-job-client-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..13d6c7414 --- /dev/null +++ b/snail-job-client-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +com.aizuda.snailjob.client.starter.SnailJobClientJobCoreAutoConfiguration,\ +com.aizuda.snailjob.client.starter.SnailJobClientRetryCoreAutoConfiguration \ No newline at end of file diff --git a/snail-job-common/snail-job-common-core/src/main/resources/META-INF/spring.factories b/snail-job-common/snail-job-common-core/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..7dac528ec --- /dev/null +++ b/snail-job-common/snail-job-common-core/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +com.aizuda.snailjob.common.core.CommonCoreConfigure \ No newline at end of file From eb2bc6324070763f968f0f293016422452c2b5c9 Mon Sep 17 00:00:00 2001 From: "1115900427@qq.com" <1115900427@qq.com> Date: Fri, 6 Sep 2024 00:00:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E6=B1=A0=EF=BC=8C=E5=BD=93work=E8=8A=82=E7=82=B9=E6=9C=89?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=89=B9=E6=AC=A1=E4=BB=BB=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=EF=BC=8C=E5=86=8D=E5=90=AF=E5=8A=A8=E5=B9=B6?= =?UTF-8?q?=E8=A1=8C=E5=BA=A6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../snailjob/client/job/core/cache/ThreadPoolCache.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/snail-job-client/snail-job-client-job-core/src/main/java/com/aizuda/snailjob/client/job/core/cache/ThreadPoolCache.java b/snail-job-client/snail-job-client-job-core/src/main/java/com/aizuda/snailjob/client/job/core/cache/ThreadPoolCache.java index e22d96512..3a5d4a3c1 100644 --- a/snail-job-client/snail-job-client-job-core/src/main/java/com/aizuda/snailjob/client/job/core/cache/ThreadPoolCache.java +++ b/snail-job-client/snail-job-client-job-core/src/main/java/com/aizuda/snailjob/client/job/core/cache/ThreadPoolCache.java @@ -24,13 +24,16 @@ public class ThreadPoolCache { public static ThreadPoolExecutor createThreadPool(Long taskBatchId, int parallelNum) { if (CACHE_THREAD_POOL.containsKey(taskBatchId)) { - return CACHE_THREAD_POOL.get(taskBatchId); + ThreadPoolExecutor threadPoolExecutor = CACHE_THREAD_POOL.get(taskBatchId); + threadPoolExecutor.setCorePoolSize(parallelNum); + threadPoolExecutor.setMaximumPoolSize(parallelNum); + return threadPoolExecutor; } Supplier supplier = () -> { ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( - parallelNum, parallelNum, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), + 1, 1, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new CustomizableThreadFactory(MessageFormat.format("snail-job-job-{0}-", taskBatchId))); threadPoolExecutor.allowCoreThreadTimeOut(true); return threadPoolExecutor; From 1e0f6a88a0bebd0d108e846147b81d90c707b3a4 Mon Sep 17 00:00:00 2001 From: "1115900427@qq.com" <1115900427@qq.com> Date: Fri, 6 Sep 2024 21:25:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?work=E7=BA=BF=E7=A8=8B=E6=B1=A0=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../snailjob/client/job/core/cache/ThreadPoolCache.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/snail-job-client/snail-job-client-job-core/src/main/java/com/aizuda/snailjob/client/job/core/cache/ThreadPoolCache.java b/snail-job-client/snail-job-client-job-core/src/main/java/com/aizuda/snailjob/client/job/core/cache/ThreadPoolCache.java index 3a5d4a3c1..d883c2f8e 100644 --- a/snail-job-client/snail-job-client-job-core/src/main/java/com/aizuda/snailjob/client/job/core/cache/ThreadPoolCache.java +++ b/snail-job-client/snail-job-client-job-core/src/main/java/com/aizuda/snailjob/client/job/core/cache/ThreadPoolCache.java @@ -25,8 +25,12 @@ public class ThreadPoolCache { public static ThreadPoolExecutor createThreadPool(Long taskBatchId, int parallelNum) { if (CACHE_THREAD_POOL.containsKey(taskBatchId)) { ThreadPoolExecutor threadPoolExecutor = CACHE_THREAD_POOL.get(taskBatchId); - threadPoolExecutor.setCorePoolSize(parallelNum); - threadPoolExecutor.setMaximumPoolSize(parallelNum); + if (threadPoolExecutor.getCorePoolSize() == parallelNum) { + return threadPoolExecutor; + } else { + threadPoolExecutor.setCorePoolSize(parallelNum); + threadPoolExecutor.setMaximumPoolSize(parallelNum); + } return threadPoolExecutor; }