This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git
The following commit(s) were added to refs/heads/master by this push:
new 1203a8c01 Rename jobExecutorServiceHandlerType to
jobExecutorThreadPoolSizeProviderType (#2313)
1203a8c01 is described below
commit 1203a8c018a0c9b059224062c81e8ca839f187f7
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Oct 25 23:20:02 2023 +0800
Rename jobExecutorServiceHandlerType to
jobExecutorThreadPoolSizeProviderType (#2313)
* Refactor JobExecutorServiceHandler to JobExecutorThreadPoolSizeProvider
* Refactor jobExecutorServiceHandlerType to
jobExecutorThreadPoolSizeProviderType
* Refactor ExecutorServiceReloadable
---
.../annotation/ElasticJobConfiguration.java | 6 +--
.../elasticjob/api/JobConfiguration.java | 14 ++---
.../elasticjob/api/JobConfigurationTest.java | 6 +--
docs/content/dev-manual/thread-pool.cn.md | 14 ++---
docs/content/dev-manual/thread-pool.en.md | 14 ++---
.../content/user-manual/configuration/_index.cn.md | 42 +++++++--------
.../content/user-manual/configuration/_index.en.md | 42 +++++++--------
.../user-manual/configuration/java-api.cn.md | 62 +++++++++++-----------
.../user-manual/configuration/java-api.en.md | 44 +++++++--------
.../concurrent/ExecutorServiceReloadable.java | 22 ++++----
.../threadpool}/ElasticJobExecutorService.java | 2 +-
...java => JobExecutorThreadPoolSizeProvider.java} | 17 +++---
.../impl/AbstractJobExecutorServiceHandler.java | 36 -------------
...CPUUsageJobExecutorThreadPoolSizeProvider.java} | 10 ++--
...leThreadJobExecutorThreadPoolSizeProvider.java} | 10 ++--
.../infra/pojo/JobConfigurationPOJO.java | 6 +--
...r.threadpool.JobExecutorThreadPoolSizeProvider} | 4 +-
.../concurrent/ElasticJobExecutorServiceTest.java | 1 +
.../concurrent/ExecutorServiceReloadableTest.java | 12 ++---
...sageJobExecutorThreadPoolSizeProviderTest.java} | 10 ++--
...readJobExecutorThreadPoolSizeProviderTest.java} | 10 ++--
.../infra/pojo/JobConfigurationPOJOTest.java | 16 +++---
.../internal/annotation/JobAnnotationBuilder.java | 2 +-
.../annotation/JobAnnotationBuilderTest.java | 2 +-
.../job/ElasticJobConfigurationProperties.java | 4 +-
.../job/ElasticJobConfigurationPropertiesTest.java | 4 +-
26 files changed, 188 insertions(+), 224 deletions(-)
diff --git
a/api/src/main/java/org/apache/shardingsphere/elasticjob/annotation/ElasticJobConfiguration.java
b/api/src/main/java/org/apache/shardingsphere/elasticjob/annotation/ElasticJobConfiguration.java
index 7526c8c38..b9ddc3211 100644
---
a/api/src/main/java/org/apache/shardingsphere/elasticjob/annotation/ElasticJobConfiguration.java
+++
b/api/src/main/java/org/apache/shardingsphere/elasticjob/annotation/ElasticJobConfiguration.java
@@ -125,11 +125,11 @@ public @interface ElasticJobConfiguration {
String jobShardingStrategyType() default "";
/**
- * Job thread pool handler type.
+ * Job executor thread pool size provider type.
*
- * @return job executor service handler type
+ * @return job executor thread pool size provider type
*/
- String jobExecutorServiceHandlerType() default "";
+ String jobExecutorThreadPoolSizeProviderType() default "";
/**
* Job thread pool handler type.
diff --git
a/api/src/main/java/org/apache/shardingsphere/elasticjob/api/JobConfiguration.java
b/api/src/main/java/org/apache/shardingsphere/elasticjob/api/JobConfiguration.java
index 17e384bcd..c48dee1e5 100644
---
a/api/src/main/java/org/apache/shardingsphere/elasticjob/api/JobConfiguration.java
+++
b/api/src/main/java/org/apache/shardingsphere/elasticjob/api/JobConfiguration.java
@@ -61,7 +61,7 @@ public final class JobConfiguration {
private final String jobShardingStrategyType;
- private final String jobExecutorServiceHandlerType;
+ private final String jobExecutorThreadPoolSizeProviderType;
private final String jobErrorHandlerType;
@@ -119,7 +119,7 @@ public final class JobConfiguration {
private String jobShardingStrategyType;
- private String jobExecutorServiceHandlerType;
+ private String jobExecutorThreadPoolSizeProviderType;
private String jobErrorHandlerType;
@@ -291,13 +291,13 @@ public final class JobConfiguration {
}
/**
- * Set job executor service handler type.
+ * Set job executor thread pool size provider type.
*
- * @param jobExecutorServiceHandlerType job executor service handler
type
+ * @param jobExecutorThreadPoolSizeProviderType job executor thread
pool size provider type
* @return job configuration builder
*/
- public Builder jobExecutorServiceHandlerType(final String
jobExecutorServiceHandlerType) {
- this.jobExecutorServiceHandlerType = jobExecutorServiceHandlerType;
+ public Builder jobExecutorThreadPoolSizeProviderType(final String
jobExecutorThreadPoolSizeProviderType) {
+ this.jobExecutorThreadPoolSizeProviderType =
jobExecutorThreadPoolSizeProviderType;
return this;
}
@@ -421,7 +421,7 @@ public final class JobConfiguration {
Preconditions.checkArgument(shardingTotalCount > 0,
"shardingTotalCount should larger than zero.");
return new JobConfiguration(jobName, cron, timeZone,
shardingTotalCount, shardingItemParameters, jobParameter,
monitorExecution, failover, misfire, maxTimeDiffSeconds,
reconcileIntervalMinutes,
- jobShardingStrategyType, jobExecutorServiceHandlerType,
jobErrorHandlerType, jobListenerTypes,
+ jobShardingStrategyType,
jobExecutorThreadPoolSizeProviderType, jobErrorHandlerType, jobListenerTypes,
extraConfigurations, description, props, disabled,
overwrite, label, staticSharding);
}
}
diff --git
a/api/src/test/java/org/apache/shardingsphere/elasticjob/api/JobConfigurationTest.java
b/api/src/test/java/org/apache/shardingsphere/elasticjob/api/JobConfigurationTest.java
index 6fda7ad19..8e044086b 100644
---
a/api/src/test/java/org/apache/shardingsphere/elasticjob/api/JobConfigurationTest.java
+++
b/api/src/test/java/org/apache/shardingsphere/elasticjob/api/JobConfigurationTest.java
@@ -36,7 +36,7 @@ class JobConfigurationTest {
.shardingItemParameters("0=a,1=b,2=c").jobParameter("param")
.monitorExecution(false).failover(true).misfire(false)
.maxTimeDiffSeconds(1000).reconcileIntervalMinutes(60)
-
.jobShardingStrategyType("AVG_ALLOCATION").jobExecutorServiceHandlerType("SINGLE_THREAD").jobErrorHandlerType("IGNORE")
+
.jobShardingStrategyType("AVG_ALLOCATION").jobExecutorThreadPoolSizeProviderType("SINGLE_THREAD").jobErrorHandlerType("IGNORE")
.description("desc").setProperty("key", "value")
.disabled(true).overwrite(true).build();
assertThat(actual.getJobName(), is("test_job"));
@@ -51,7 +51,7 @@ class JobConfigurationTest {
assertThat(actual.getMaxTimeDiffSeconds(), is(1000));
assertThat(actual.getReconcileIntervalMinutes(), is(60));
assertThat(actual.getJobShardingStrategyType(), is("AVG_ALLOCATION"));
- assertThat(actual.getJobExecutorServiceHandlerType(),
is("SINGLE_THREAD"));
+ assertThat(actual.getJobExecutorThreadPoolSizeProviderType(),
is("SINGLE_THREAD"));
assertThat(actual.getJobErrorHandlerType(), is("IGNORE"));
assertThat(actual.getDescription(), is("desc"));
assertThat(actual.getProps().getProperty("key"), is("value"));
@@ -74,7 +74,7 @@ class JobConfigurationTest {
assertThat(actual.getMaxTimeDiffSeconds(), is(-1));
assertThat(actual.getReconcileIntervalMinutes(), is(10));
assertNull(actual.getJobShardingStrategyType());
- assertNull(actual.getJobExecutorServiceHandlerType());
+ assertNull(actual.getJobExecutorThreadPoolSizeProviderType());
assertNull(actual.getJobErrorHandlerType());
assertThat(actual.getDescription(), is(""));
assertTrue(actual.getProps().isEmpty());
diff --git a/docs/content/dev-manual/thread-pool.cn.md
b/docs/content/dev-manual/thread-pool.cn.md
index 136a978d3..bf0fd0e87 100644
--- a/docs/content/dev-manual/thread-pool.cn.md
+++ b/docs/content/dev-manual/thread-pool.cn.md
@@ -6,11 +6,11 @@ weight = 2
线程池策略,用于执行作业的线程池创建。
-| *SPI 名称* | *详细说明* |
-| ------------------------------------- | --------------------------------- |
-| JobExecutorServiceHandler | 作业执行线程池策略 |
+| *SPI 名称* | *详细说明* |
+|-----------------------------------|--------------|
+| JobExecutorThreadPoolSizeProvider | 作业执行线程数量提供策略 |
-| *已知实现类* | *详细说明* |
-| ------------------------------------- | --------------------------------- |
-| CPUUsageJobExecutorServiceHandler | 根据 CPU 核数 * 2 创建作业处理线程池 |
-| SingleThreadJobExecutorServiceHandler | 使用单线程处理作业 |
+| *已知实现类* | *详细说明* |
+|-----------------------------------------------|-------------------------|
+| CPUUsageJobExecutorThreadPoolSizeProvider | 根据 CPU 核数 * 2 创建作业处理线程池 |
+| SingleThreadJobExecutorThreadPoolSizeProvider | 使用单线程处理作业 |
diff --git a/docs/content/dev-manual/thread-pool.en.md
b/docs/content/dev-manual/thread-pool.en.md
index dc53ba8e6..4b1a3a05a 100644
--- a/docs/content/dev-manual/thread-pool.en.md
+++ b/docs/content/dev-manual/thread-pool.en.md
@@ -6,11 +6,11 @@ weight = 2
Thread pool strategy, used to create thread pool for job execution.
-| *SPI Name* | *Description*
|
-| ------------------------------------- |
------------------------------------------------------ |
-| JobExecutorServiceHandler | Job executor service handler
|
+| *SPI Name* | *Description* |
+|-----------------------------------|----------------------------------------|
+| JobExecutorThreadPoolSizeProvider | Job executor thread pool size provider |
-| *Implementation Class* | *Description*
|
-| ------------------------------------- |
------------------------------------------------------ |
-| CPUUsageJobExecutorServiceHandler | Use CPU available processors * 2 to
create thread pool |
-| SingleThreadJobExecutorServiceHandler | Use single thread to execute job
|
+| *Implementation Class* | *Description*
|
+|-----------------------------------------------|--------------------------------------------------------|
+| CPUUsageJobExecutorThreadPoolSizeProvider | Use CPU available processors
* 2 to create thread pool |
+| SingleThreadJobExecutorThreadPoolSizeProvider | Use single thread to execute
job |
diff --git a/docs/content/user-manual/configuration/_index.cn.md
b/docs/content/user-manual/configuration/_index.cn.md
index 9acd9fba7..19c1225cc 100644
--- a/docs/content/user-manual/configuration/_index.cn.md
+++ b/docs/content/user-manual/configuration/_index.cn.md
@@ -37,26 +37,26 @@ ElasticJob 提供了 3 种配置方式,用于不同的使用场景。
### 可配置属性
-| 属性名 | 类型 | 缺省值 | 描述
|
-|-------------------------------|:-----------|:---------------|:---------------------|
-| jobName | String | | 作业名称
|
-| shardingTotalCount | int | | 作业分片总数
|
-| cron | String | | CRON
表达式,用于控制作业触发时间 |
-| timeZone | String | | CRON 的时区设置
|
-| shardingItemParameters | String | | 个性化分片参数
|
-| jobParameter | String | | 作业自定义参数
|
-| monitorExecution | boolean | true | 监控作业运行时状态
|
-| failover | boolean | false | 是否开启任务执行失效转移
|
-| misfire | boolean | true | 是否开启错过任务重新执行
|
-| maxTimeDiffSeconds | int | -1(不检查) |
最大允许的本机与注册中心的时间误差秒数 |
-| reconcileIntervalMinutes | int | 10 |
修复作业服务器不一致状态服务调度间隔分钟 |
-| jobShardingStrategyType | String | AVG_ALLOCATION | 作业分片策略类型
|
-| jobExecutorServiceHandlerType | String | CPU | 作业线程池处理策略
|
-| jobErrorHandlerType | String | | 作业错误处理策略
|
-| description | String | | 作业描述信息
|
-| props | Properties | | 作业属性配置信息
|
-| disabled | boolean | false | 作业是否禁止启动
|
-| overwrite | boolean | false |
本地配置是否可覆盖注册中心配置 |
+| 属性名 | 类型 | 缺省值 | 描述
|
+|-----------------------------------|:-----------|:---------------|:---------------------|
+| jobName | String | | 作业名称
|
+| shardingTotalCount | int | | 作业分片总数
|
+| cron | String | | CRON
表达式,用于控制作业触发时间 |
+| timeZone | String | | CRON 的时区设置
|
+| shardingItemParameters | String | | 个性化分片参数
|
+| jobParameter | String | | 作业自定义参数
|
+| monitorExecution | boolean | true | 监控作业运行时状态
|
+| failover | boolean | false |
是否开启任务执行失效转移 |
+| misfire | boolean | true |
是否开启错过任务重新执行 |
+| maxTimeDiffSeconds | int | -1(不检查) |
最大允许的本机与注册中心的时间误差秒数 |
+| reconcileIntervalMinutes | int | 10 |
修复作业服务器不一致状态服务调度间隔分钟 |
+| jobShardingStrategyType | String | AVG_ALLOCATION | 作业分片策略类型
|
+| jobExecutorThreadPoolSizeProvider | String | CPU | 作业线程池处理策略
|
+| jobErrorHandlerType | String | | 作业错误处理策略
|
+| description | String | | 作业描述信息
|
+| props | Properties | | 作业属性配置信息
|
+| disabled | boolean | false | 作业是否禁止启动
|
+| overwrite | boolean | false |
本地配置是否可覆盖注册中心配置 |
### 核心配置项说明
@@ -92,7 +92,7 @@ ElasticJob 提供了 3 种配置方式,用于不同的使用场景。
详情请参见[内置分片策略列表](/cn/user-manual/elasticjob/configuration/built-in-strategy/sharding)。
-**jobExecutorServiceHandlerType:**
+**jobExecutorThreadPoolSizeProviderType:**
详情请参见[内置线程池策略列表](/cn/user-manual/elasticjob/configuration/built-in-strategy/thread-pool)。
diff --git a/docs/content/user-manual/configuration/_index.en.md
b/docs/content/user-manual/configuration/_index.en.md
index c437e417a..8ea1858e0 100644
--- a/docs/content/user-manual/configuration/_index.en.md
+++ b/docs/content/user-manual/configuration/_index.en.md
@@ -36,26 +36,26 @@ Include IP and port, multiple addresses are separated by
commas, such as: `host1
### Configuration
-| Name | Data Type | Default Value | Description
|
-|-------------------------------|:-----------|:---------------|:------------------------------------------------------------------------------------|
-| jobName | String | | Job name
|
-| shardingTotalCount | int | | Sharding total
count |
-| cron | String | | CRON
expression, control the job trigger time |
-| timeZone | String | | time zone of
CRON |
-| shardingItemParameters | String | | Sharding item
parameters |
-| jobParameter | String | | Job parameter
|
-| monitorExecution | boolean | true | Monitor job
execution status |
-| failover | boolean | false | Enable or
disable job failover |
-| misfire | boolean | true | Enable or
disable the missed task to re-execute |
-| maxTimeDiffSeconds | int | -1(no check) | The maximum
value for time difference between server and registry center in seconds |
-| reconcileIntervalMinutes | int | 10 | Service
scheduling interval in minutes for repairing job server inconsistent state |
-| jobShardingStrategyType | String | AVG_ALLOCATION | Job sharding
strategy type |
-| jobExecutorServiceHandlerType | String | CPU | Job thread
pool handler type |
-| jobErrorHandlerType | String | | Job error
handler type |
-| description | String | | Job
description
|
-| props | Properties | | Job properties
|
-| disabled | boolean | false | Enable or
disable start the job |
-| overwrite | boolean | false | Enable or
disable local configuration override registry center configuration |
+| Name | Data Type | Default Value |
Description
|
+|-----------------------------------|:-----------|:---------------|:------------------------------------------------------------------------------------|
+| jobName | String | | Job name
|
+| shardingTotalCount | int | | Sharding
total count |
+| cron | String | | CRON
expression, control the job trigger time |
+| timeZone | String | | time zone
of CRON |
+| shardingItemParameters | String | | Sharding
item parameters |
+| jobParameter | String | | Job
parameter
|
+| monitorExecution | boolean | true | Monitor
job execution status |
+| failover | boolean | false | Enable or
disable job failover |
+| misfire | boolean | true | Enable or
disable the missed task to re-execute |
+| maxTimeDiffSeconds | int | -1(no check) | The
maximum value for time difference between server and registry center in seconds
|
+| reconcileIntervalMinutes | int | 10 | Service
scheduling interval in minutes for repairing job server inconsistent state |
+| jobShardingStrategyType | String | AVG_ALLOCATION | Job
sharding strategy type
|
+| jobExecutorThreadPoolSizeProvider | String | CPU | Job thread
pool handler type |
+| jobErrorHandlerType | String | | Job error
handler type |
+| description | String | | Job
description
|
+| props | Properties | | Job
properties
|
+| disabled | boolean | false | Enable or
disable start the job |
+| overwrite | boolean | false | Enable or
disable local configuration override registry center configuration |
### Core Configuration Description
@@ -91,7 +91,7 @@ Less than `1` means no repair is performed.
For details, see[Job Sharding
Strategy](/en/user-manual/elasticjob/configuration/built-in-strategy/sharding)。
-**jobExecutorServiceHandlerType:**
+**jobExecutorThreadPoolSizeProviderType:**
For details, see[Thread Pool
Strategy](/en/user-manual/elasticjob/configuration/built-in-strategy/thread-pool)。
diff --git a/docs/content/user-manual/configuration/java-api.cn.md
b/docs/content/user-manual/configuration/java-api.cn.md
index 02c3d2b5f..9431341a7 100644
--- a/docs/content/user-manual/configuration/java-api.cn.md
+++ b/docs/content/user-manual/configuration/java-api.cn.md
@@ -12,16 +12,16 @@ chapter = true
可配置属性:
-| 属性名 | 构造器注入 |
-| ----------------------------- |:--------- |
-| serverLists | 是 |
-| namespace | 是 |
-| baseSleepTimeMilliseconds | 否 |
-| maxSleepTimeMilliseconds | 否 |
-| maxRetries | 否 |
-| sessionTimeoutMilliseconds | 否 |
-| connectionTimeoutMilliseconds | 否 |
-| digest | 否 |
+| 属性名 | 构造器注入 |
+|-------------------------------|:------|
+| serverLists | 是 |
+| namespace | 是 |
+| baseSleepTimeMilliseconds | 否 |
+| maxSleepTimeMilliseconds | 否 |
+| maxRetries | 否 |
+| sessionTimeoutMilliseconds | 否 |
+| connectionTimeoutMilliseconds | 否 |
+| digest | 否 |
## 作业配置
@@ -29,24 +29,24 @@ chapter = true
可配置属性:
-| 属性名 | 构造器注入 |
-| ----------------------------- |:--------- |
-| jobName | 是 |
-| shardingTotalCount | 是 |
-| cron | 否 |
-| timeZone | 否 |
-| shardingItemParameters | 否 |
-| jobParameter | 否 |
-| monitorExecution | 否 |
-| failover | 否 |
-| misfire | 否 |
-| maxTimeDiffSeconds | 否 |
-| reconcileIntervalMinutes | 否 |
-| jobShardingStrategyType | 否 |
-| jobExecutorServiceHandlerType | 否 |
-| jobErrorHandlerType | 否 |
-| jobListenerTypes | 否 |
-| description | 否 |
-| props | 否 |
-| disabled | 否 |
-| overwrite | 否 |
+| 属性名 | 构造器注入 |
+|-----------------------------------|:------|
+| jobName | 是 |
+| shardingTotalCount | 是 |
+| cron | 否 |
+| timeZone | 否 |
+| shardingItemParameters | 否 |
+| jobParameter | 否 |
+| monitorExecution | 否 |
+| failover | 否 |
+| misfire | 否 |
+| maxTimeDiffSeconds | 否 |
+| reconcileIntervalMinutes | 否 |
+| jobShardingStrategyType | 否 |
+| jobExecutorThreadPoolSizeProvider | 否 |
+| jobErrorHandlerType | 否 |
+| jobListenerTypes | 否 |
+| description | 否 |
+| props | 否 |
+| disabled | 否 |
+| overwrite | 否 |
diff --git a/docs/content/user-manual/configuration/java-api.en.md
b/docs/content/user-manual/configuration/java-api.en.md
index 3670e0b4d..f7a4bc1a9 100644
--- a/docs/content/user-manual/configuration/java-api.en.md
+++ b/docs/content/user-manual/configuration/java-api.en.md
@@ -13,7 +13,7 @@ Class name:
`org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfigu
Configuration:
| Name | Constructor injection |
-| ----------------------------- |:--------------------- |
+|-------------------------------|:----------------------|
| serverLists | Yes |
| namespace | Yes |
| baseSleepTimeMilliseconds | No |
@@ -29,24 +29,24 @@ Class name:
`org.apache.shardingsphere.elasticjob.api.JobConfiguration`
Configuration:
-| Name | Constructor injection |
-| ----------------------------- |:--------------------- |
-| jobName | Yes |
-| shardingTotalCount | Yes |
-| cron | No |
-| timeZone | No |
-| shardingItemParameters | No |
-| jobParameter | No |
-| monitorExecution | No |
-| failover | No |
-| misfire | No |
-| maxTimeDiffSeconds | No |
-| reconcileIntervalMinutes | No |
-| jobShardingStrategyType | No |
-| jobExecutorServiceHandlerType | No |
-| jobErrorHandlerType | No |
-| jobListenerTypes | No |
-| description | No |
-| props | No |
-| disabled | No |
-| overwrite | No |
+| Name | Constructor injection |
+|-----------------------------------|:----------------------|
+| jobName | Yes |
+| shardingTotalCount | Yes |
+| cron | No |
+| timeZone | No |
+| shardingItemParameters | No |
+| jobParameter | No |
+| monitorExecution | No |
+| failover | No |
+| misfire | No |
+| maxTimeDiffSeconds | No |
+| reconcileIntervalMinutes | No |
+| jobShardingStrategyType | No |
+| jobExecutorThreadPoolSizeProvider | No |
+| jobErrorHandlerType | No |
+| jobListenerTypes | No |
+| description | No |
+| props | No |
+| disabled | No |
+| overwrite | No |
diff --git
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadable.java
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadable.java
index f504f9662..0ab4e17ad 100644
---
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadable.java
+++
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadable.java
@@ -20,7 +20,8 @@ package org.apache.shardingsphere.elasticjob.infra.concurrent;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.infra.context.Reloadable;
-import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorServiceHandler;
+import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.ElasticJobExecutorService;
+import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorThreadPoolSizeProvider;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import java.util.Optional;
@@ -32,29 +33,30 @@ import java.util.concurrent.ExecutorService;
@Slf4j
public final class ExecutorServiceReloadable implements
Reloadable<ExecutorService> {
- private JobExecutorServiceHandler jobExecutorServiceHandler;
+ private String jobExecutorThreadPoolSizeProviderType;
private ExecutorService executorService;
@Override
public void init(final JobConfiguration jobConfig) {
- jobExecutorServiceHandler =
TypedSPILoader.getService(JobExecutorServiceHandler.class,
jobConfig.getJobExecutorServiceHandlerType());
- executorService =
jobExecutorServiceHandler.createExecutorService(jobConfig.getJobName());
+ JobExecutorThreadPoolSizeProvider jobExecutorThreadPoolSizeProvider =
TypedSPILoader.getService(JobExecutorThreadPoolSizeProvider.class,
jobConfig.getJobExecutorThreadPoolSizeProviderType());
+ jobExecutorThreadPoolSizeProviderType =
jobExecutorThreadPoolSizeProvider.getType();
+ executorService = new ElasticJobExecutorService("elasticjob-" +
jobConfig.getJobName(),
jobExecutorThreadPoolSizeProvider.getSize()).createExecutorService();
}
@Override
public synchronized void reloadIfNecessary(final JobConfiguration
jobConfig) {
- if
(jobExecutorServiceHandler.getType().equals(jobConfig.getJobExecutorServiceHandlerType()))
{
+ if
(jobExecutorThreadPoolSizeProviderType.equals(jobConfig.getJobExecutorThreadPoolSizeProviderType()))
{
return;
}
- log.debug("JobExecutorServiceHandler reload occurred in the job '{}'.
Change from '{}' to '{}'.",
- jobConfig.getJobName(), jobExecutorServiceHandler.getType(),
jobConfig.getJobExecutorServiceHandlerType());
- reload(jobConfig.getJobExecutorServiceHandlerType(),
jobConfig.getJobName());
+ log.debug("Reload occurred in the job '{}'. Change from '{}' to
'{}'.", jobConfig.getJobName(), jobExecutorThreadPoolSizeProviderType,
jobConfig.getJobExecutorThreadPoolSizeProviderType());
+ reload(jobConfig.getJobExecutorThreadPoolSizeProviderType(),
jobConfig.getJobName());
}
- private void reload(final String jobExecutorServiceHandlerType, final
String jobName) {
+ private void reload(final String jobExecutorThreadPoolSizeProviderType,
final String jobName) {
executorService.shutdown();
- executorService =
TypedSPILoader.getService(JobExecutorServiceHandler.class,
jobExecutorServiceHandlerType).createExecutorService(jobName);
+ executorService = new ElasticJobExecutorService(
+ "elasticjob-" + jobName,
TypedSPILoader.getService(JobExecutorThreadPoolSizeProvider.class,
jobExecutorThreadPoolSizeProviderType).getSize()).createExecutorService();
}
@Override
diff --git
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorService.java
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/ElasticJobExecutorService.java
similarity index 97%
rename from
infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorService.java
rename to
infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/ElasticJobExecutorService.java
index 90f91e908..b9f67fd58 100644
---
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorService.java
+++
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/ElasticJobExecutorService.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.infra.concurrent;
+package org.apache.shardingsphere.elasticjob.infra.handler.threadpool;
import com.google.common.util.concurrent.MoreExecutors;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
diff --git
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/JobExecutorServiceHandler.java
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/JobExecutorThreadPoolSizeProvider.java
similarity index 77%
rename from
infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/JobExecutorServiceHandler.java
rename to
infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/JobExecutorThreadPoolSizeProvider.java
index 4b26511fd..aaf4b9d69 100644
---
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/JobExecutorServiceHandler.java
+++
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/JobExecutorThreadPoolSizeProvider.java
@@ -20,20 +20,19 @@ package
org.apache.shardingsphere.elasticjob.infra.handler.threadpool;
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
-import java.util.concurrent.ExecutorService;
-
/**
- * Job executor service handler.
+ * Job executor thread pool size provider.
*/
@SingletonSPI
-public interface JobExecutorServiceHandler extends TypedSPI {
+public interface JobExecutorThreadPoolSizeProvider extends TypedSPI {
/**
- * Create executor service.
- *
- * @param jobName job name
+ * Get thread pool size.
*
- * @return executor service
+ * @return thread pool size
*/
- ExecutorService createExecutorService(String jobName);
+ int getSize();
+
+ @Override
+ String getType();
}
diff --git
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/AbstractJobExecutorServiceHandler.java
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/AbstractJobExecutorServiceHandler.java
deleted file mode 100644
index f28d060ff..000000000
---
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/AbstractJobExecutorServiceHandler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.infra.handler.threadpool.impl;
-
-import
org.apache.shardingsphere.elasticjob.infra.concurrent.ElasticJobExecutorService;
-import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorServiceHandler;
-
-import java.util.concurrent.ExecutorService;
-
-/**
- * Abstract job executor service handler.
- **/
-public abstract class AbstractJobExecutorServiceHandler implements
JobExecutorServiceHandler {
-
- @Override
- public ExecutorService createExecutorService(final String jobName) {
- return new ElasticJobExecutorService("elasticjob-" + jobName,
getPoolSize()).createExecutorService();
- }
-
- protected abstract int getPoolSize();
-}
diff --git
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/CPUUsageJobExecutorServiceHandler.java
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/CPUUsageJobExecutorThreadPoolSizeProvider.java
similarity index 77%
rename from
infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/CPUUsageJobExecutorServiceHandler.java
rename to
infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/CPUUsageJobExecutorThreadPoolSizeProvider.java
index 70d39ce64..341a1c48b 100644
---
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/CPUUsageJobExecutorServiceHandler.java
+++
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/CPUUsageJobExecutorThreadPoolSizeProvider.java
@@ -15,15 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.infra.handler.threadpool.impl;
+package org.apache.shardingsphere.elasticjob.infra.handler.threadpool.type;
+
+import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorThreadPoolSizeProvider;
/**
- * Job executor service handler with use CPU available processors.
+ * Job executor pool size provider with use CPU available processors.
*/
-public final class CPUUsageJobExecutorServiceHandler extends
AbstractJobExecutorServiceHandler {
+public final class CPUUsageJobExecutorThreadPoolSizeProvider implements
JobExecutorThreadPoolSizeProvider {
@Override
- protected int getPoolSize() {
+ public int getSize() {
return Runtime.getRuntime().availableProcessors() * 2;
}
diff --git
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/SingleThreadJobExecutorServiceHandler.java
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/SingleThreadJobExecutorThreadPoolSizeProvider.java
similarity index 76%
rename from
infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/SingleThreadJobExecutorServiceHandler.java
rename to
infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/SingleThreadJobExecutorThreadPoolSizeProvider.java
index c81e2d373..de1da05b8 100644
---
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/SingleThreadJobExecutorServiceHandler.java
+++
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/SingleThreadJobExecutorThreadPoolSizeProvider.java
@@ -15,15 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.infra.handler.threadpool.impl;
+package org.apache.shardingsphere.elasticjob.infra.handler.threadpool.type;
+
+import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorThreadPoolSizeProvider;
/**
- * Job executor service handler with single thread.
+ * Job executor pool size provider with single thread.
*/
-public final class SingleThreadJobExecutorServiceHandler extends
AbstractJobExecutorServiceHandler {
+public final class SingleThreadJobExecutorThreadPoolSizeProvider implements
JobExecutorThreadPoolSizeProvider {
@Override
- protected int getPoolSize() {
+ public int getSize() {
return 1;
}
diff --git
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJO.java
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJO.java
index 6b9dd2cef..b0838af17 100644
---
a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJO.java
+++
b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJO.java
@@ -61,7 +61,7 @@ public final class JobConfigurationPOJO {
private String jobShardingStrategyType;
- private String jobExecutorServiceHandlerType;
+ private String jobExecutorThreadPoolSizeProviderType;
private String jobErrorHandlerType;
@@ -91,7 +91,7 @@ public final class JobConfigurationPOJO {
.cron(cron).timeZone(timeZone).shardingItemParameters(shardingItemParameters).jobParameter(jobParameter)
.monitorExecution(monitorExecution).failover(failover).misfire(misfire)
.maxTimeDiffSeconds(maxTimeDiffSeconds).reconcileIntervalMinutes(reconcileIntervalMinutes)
-
.jobShardingStrategyType(jobShardingStrategyType).jobExecutorServiceHandlerType(jobExecutorServiceHandlerType)
+
.jobShardingStrategyType(jobShardingStrategyType).jobExecutorThreadPoolSizeProviderType(jobExecutorThreadPoolSizeProviderType)
.jobErrorHandlerType(jobErrorHandlerType).jobListenerTypes(jobListenerTypes.toArray(new
String[]{})).description(description)
.disabled(disabled).overwrite(overwrite).label(label).staticSharding(staticSharding).build();
jobExtraConfigurations.stream().map(YamlConfiguration::toConfiguration).forEach(result.getExtraConfigurations()::add);
@@ -122,7 +122,7 @@ public final class JobConfigurationPOJO {
result.setMaxTimeDiffSeconds(jobConfig.getMaxTimeDiffSeconds());
result.setReconcileIntervalMinutes(jobConfig.getReconcileIntervalMinutes());
result.setJobShardingStrategyType(jobConfig.getJobShardingStrategyType());
-
result.setJobExecutorServiceHandlerType(jobConfig.getJobExecutorServiceHandlerType());
+
result.setJobExecutorThreadPoolSizeProviderType(jobConfig.getJobExecutorThreadPoolSizeProviderType());
result.setJobErrorHandlerType(jobConfig.getJobErrorHandlerType());
result.setJobListenerTypes(jobConfig.getJobListenerTypes());
jobConfig.getExtraConfigurations().stream()
diff --git
a/infra/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorServiceHandler
b/infra/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorThreadPoolSizeProvider
similarity index 77%
rename from
infra/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorServiceHandler
rename to
infra/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorThreadPoolSizeProvider
index 0aa42ea46..4064541bc 100644
---
a/infra/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorServiceHandler
+++
b/infra/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorThreadPoolSizeProvider
@@ -15,5 +15,5 @@
# limitations under the License.
#
-org.apache.shardingsphere.elasticjob.infra.handler.threadpool.impl.CPUUsageJobExecutorServiceHandler
-org.apache.shardingsphere.elasticjob.infra.handler.threadpool.impl.SingleThreadJobExecutorServiceHandler
+org.apache.shardingsphere.elasticjob.infra.handler.threadpool.type.CPUUsageJobExecutorThreadPoolSizeProvider
+org.apache.shardingsphere.elasticjob.infra.handler.threadpool.type.SingleThreadJobExecutorThreadPoolSizeProvider
diff --git
a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java
b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java
index b6eeb74f3..6f4160adf 100644
---
a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java
+++
b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.elasticjob.infra.concurrent;
+import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.ElasticJobExecutorService;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
diff --git
a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadableTest.java
b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadableTest.java
index 4c30370b8..10f67a114 100644
---
a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadableTest.java
+++
b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadableTest.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.elasticjob.infra.concurrent;
import lombok.SneakyThrows;
import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
-import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorServiceHandler;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
@@ -33,9 +32,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
class ExecutorServiceReloadableTest {
@@ -46,8 +43,7 @@ class ExecutorServiceReloadableTest {
@Test
void assertInitialize() {
try (ExecutorServiceReloadable executorServiceReloadable = new
ExecutorServiceReloadable()) {
- String jobExecutorServiceHandlerType = "SINGLE_THREAD";
- JobConfiguration jobConfig = JobConfiguration.newBuilder("job",
1).jobExecutorServiceHandlerType(jobExecutorServiceHandlerType).build();
+ JobConfiguration jobConfig = JobConfiguration.newBuilder("job",
1).jobExecutorThreadPoolSizeProviderType("SINGLE_THREAD").build();
assertNull(executorServiceReloadable.getInstance());
executorServiceReloadable.init(jobConfig);
ExecutorService actual = executorServiceReloadable.getInstance();
@@ -61,9 +57,7 @@ class ExecutorServiceReloadableTest {
@Test
void assertReload() {
ExecutorServiceReloadable executorServiceReloadable = new
ExecutorServiceReloadable();
- JobExecutorServiceHandler jobExecutorServiceHandler =
mock(JobExecutorServiceHandler.class);
- when(jobExecutorServiceHandler.getType()).thenReturn("mock");
- setField(executorServiceReloadable, "jobExecutorServiceHandler",
jobExecutorServiceHandler);
+ setField(executorServiceReloadable,
"jobExecutorThreadPoolSizeProviderType", "mock");
setField(executorServiceReloadable, "executorService",
mockExecutorService);
JobConfiguration jobConfig = JobConfiguration.newBuilder("job",
1).build();
executorServiceReloadable.reloadIfNecessary(jobConfig);
@@ -77,7 +71,7 @@ class ExecutorServiceReloadableTest {
@Test
void assertUnnecessaryToReload() {
try (ExecutorServiceReloadable executorServiceReloadable = new
ExecutorServiceReloadable()) {
- JobConfiguration jobConfig = JobConfiguration.newBuilder("job",
1).jobExecutorServiceHandlerType("CPU").build();
+ JobConfiguration jobConfig = JobConfiguration.newBuilder("job",
1).jobExecutorThreadPoolSizeProviderType("CPU").build();
executorServiceReloadable.init(jobConfig);
ExecutorService expected = executorServiceReloadable.getInstance();
executorServiceReloadable.reloadIfNecessary(jobConfig);
diff --git
a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/CPUUsageJobExecutorServiceHandlerTest.java
b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/CPUUsageJobExecutorThreadPoolSizeProviderTest.java
similarity index 78%
rename from
infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/CPUUsageJobExecutorServiceHandlerTest.java
rename to
infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/CPUUsageJobExecutorThreadPoolSizeProviderTest.java
index ff9d77639..45b0b6f9d 100644
---
a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/CPUUsageJobExecutorServiceHandlerTest.java
+++
b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/CPUUsageJobExecutorThreadPoolSizeProviderTest.java
@@ -15,19 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.infra.handler.threadpool.impl;
+package org.apache.shardingsphere.elasticjob.infra.handler.threadpool.type;
-import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorServiceHandler;
+import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorThreadPoolSizeProvider;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class CPUUsageJobExecutorServiceHandlerTest {
+class CPUUsageJobExecutorThreadPoolSizeProviderTest {
@Test
- void assertGetPoolSizeAndType() {
- assertThat(((CPUUsageJobExecutorServiceHandler)
TypedSPILoader.getService(JobExecutorServiceHandler.class,
"CPU")).getPoolSize(), is(Runtime.getRuntime().availableProcessors() * 2));
+ void assertGetPoolSize() {
+
assertThat((TypedSPILoader.getService(JobExecutorThreadPoolSizeProvider.class,
"CPU")).getSize(), is(Runtime.getRuntime().availableProcessors() * 2));
}
}
diff --git
a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/SingleThreadJobExecutorServiceHandlerTest.java
b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/SingleThreadJobExecutorThreadPoolSizeProviderTest.java
similarity index 79%
rename from
infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/SingleThreadJobExecutorServiceHandlerTest.java
rename to
infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/SingleThreadJobExecutorThreadPoolSizeProviderTest.java
index 45f754a15..ea92a32e5 100644
---
a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/SingleThreadJobExecutorServiceHandlerTest.java
+++
b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/type/SingleThreadJobExecutorThreadPoolSizeProviderTest.java
@@ -15,19 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.infra.handler.threadpool.impl;
+package org.apache.shardingsphere.elasticjob.infra.handler.threadpool.type;
-import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorServiceHandler;
+import
org.apache.shardingsphere.elasticjob.infra.handler.threadpool.JobExecutorThreadPoolSizeProvider;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class SingleThreadJobExecutorServiceHandlerTest {
+class SingleThreadJobExecutorThreadPoolSizeProviderTest {
@Test
- void assertGetPoolSizeAndType() {
- assertThat(((SingleThreadJobExecutorServiceHandler)
TypedSPILoader.getService(JobExecutorServiceHandler.class,
"SINGLE_THREAD")).getPoolSize(), is(1));
+ void assertGetPoolSize() {
+
assertThat((TypedSPILoader.getService(JobExecutorThreadPoolSizeProvider.class,
"SINGLE_THREAD")).getSize(), is(1));
}
}
diff --git
a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java
b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java
index 6414aef99..b0dd373c5 100644
---
a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java
+++
b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java
@@ -37,7 +37,7 @@ class JobConfigurationPOJOTest {
+ "disabled: false\n"
+ "failover: false\n"
+ "jobErrorHandlerType: IGNORE\n"
- + "jobExecutorServiceHandlerType: CPU\n"
+ + "jobExecutorThreadPoolSizeProviderType: CPU\n"
+ "jobName: test_job\n"
+ "jobParameter: param\n"
+ "jobShardingStrategyType: AVG_ALLOCATION\n"
@@ -76,7 +76,7 @@ class JobConfigurationPOJOTest {
pojo.setFailover(true);
pojo.setMisfire(true);
pojo.setJobShardingStrategyType("AVG_ALLOCATION");
- pojo.setJobExecutorServiceHandlerType("CPU");
+ pojo.setJobExecutorThreadPoolSizeProviderType("CPU");
pojo.setJobErrorHandlerType("IGNORE");
pojo.setJobListenerTypes(Collections.singletonList("LOG"));
pojo.setDescription("Job description");
@@ -93,7 +93,7 @@ class JobConfigurationPOJOTest {
assertTrue(actual.isFailover());
assertTrue(actual.isMisfire());
assertThat(actual.getJobShardingStrategyType(), is("AVG_ALLOCATION"));
- assertThat(actual.getJobExecutorServiceHandlerType(), is("CPU"));
+ assertThat(actual.getJobExecutorThreadPoolSizeProviderType(),
is("CPU"));
assertThat(actual.getJobErrorHandlerType(), is("IGNORE"));
assertThat(actual.getJobListenerTypes(), hasItem("LOG"));
assertThat(actual.getDescription(), is("Job description"));
@@ -108,7 +108,7 @@ class JobConfigurationPOJOTest {
.cron("0/1 * * * * ?")
.shardingItemParameters("0=A,1=B,2=C").jobParameter("param")
.monitorExecution(true).failover(true).misfire(true)
-
.jobShardingStrategyType("AVG_ALLOCATION").jobExecutorServiceHandlerType("CPU").jobErrorHandlerType("IGNORE")
+
.jobShardingStrategyType("AVG_ALLOCATION").jobExecutorThreadPoolSizeProviderType("CPU").jobErrorHandlerType("IGNORE")
.jobListenerTypes("LOG").description("Job
description").setProperty("key", "value")
.disabled(true).overwrite(true).build();
JobConfigurationPOJO actual =
JobConfigurationPOJO.fromJobConfiguration(jobConfig);
@@ -121,7 +121,7 @@ class JobConfigurationPOJOTest {
assertTrue(actual.isFailover());
assertTrue(actual.isMisfire());
assertThat(actual.getJobShardingStrategyType(), is("AVG_ALLOCATION"));
- assertThat(actual.getJobExecutorServiceHandlerType(), is("CPU"));
+ assertThat(actual.getJobExecutorThreadPoolSizeProviderType(),
is("CPU"));
assertThat(actual.getJobErrorHandlerType(), is("IGNORE"));
assertThat(actual.getJobListenerTypes(), hasItem("LOG"));
assertThat(actual.getDescription(), is("Job description"));
@@ -140,7 +140,7 @@ class JobConfigurationPOJOTest {
actual.setJobParameter("param");
actual.setMaxTimeDiffSeconds(-1);
actual.setJobShardingStrategyType("AVG_ALLOCATION");
- actual.setJobExecutorServiceHandlerType("CPU");
+ actual.setJobExecutorThreadPoolSizeProviderType("CPU");
actual.setJobErrorHandlerType("IGNORE");
actual.setDescription("Job description");
actual.getProps().setProperty("key", "value");
@@ -169,7 +169,7 @@ class JobConfigurationPOJOTest {
assertFalse(actual.isFailover());
assertFalse(actual.isMisfire());
assertThat(actual.getJobShardingStrategyType(), is("AVG_ALLOCATION"));
- assertThat(actual.getJobExecutorServiceHandlerType(), is("CPU"));
+ assertThat(actual.getJobExecutorThreadPoolSizeProviderType(),
is("CPU"));
assertThat(actual.getJobErrorHandlerType(), is("IGNORE"));
assertThat(actual.getDescription(), is("Job description"));
assertThat(actual.getProps().getProperty("key"), is("value"));
@@ -187,7 +187,7 @@ class JobConfigurationPOJOTest {
assertFalse(actual.isFailover());
assertFalse(actual.isMisfire());
assertNull(actual.getJobShardingStrategyType());
- assertNull(actual.getJobExecutorServiceHandlerType());
+ assertNull(actual.getJobExecutorThreadPoolSizeProviderType());
assertNull(actual.getJobErrorHandlerType());
assertNull(actual.getDescription());
assertTrue(actual.getProps().isEmpty());
diff --git
a/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/annotation/JobAnnotationBuilder.java
b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/annotation/JobAnnotationBuilder.java
index 616e55e2f..93d5b6446 100644
---
a/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/annotation/JobAnnotationBuilder.java
+++
b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/annotation/JobAnnotationBuilder.java
@@ -54,7 +54,7 @@ public final class JobAnnotationBuilder {
.maxTimeDiffSeconds(annotation.maxTimeDiffSeconds())
.reconcileIntervalMinutes(annotation.reconcileIntervalMinutes())
.jobShardingStrategyType(Strings.isNullOrEmpty(annotation.jobShardingStrategyType())
? null : annotation.jobShardingStrategyType())
-
.jobExecutorServiceHandlerType(Strings.isNullOrEmpty(annotation.jobExecutorServiceHandlerType())
? null : annotation.jobExecutorServiceHandlerType())
+
.jobExecutorThreadPoolSizeProviderType(Strings.isNullOrEmpty(annotation.jobExecutorThreadPoolSizeProviderType())
? null : annotation.jobExecutorThreadPoolSizeProviderType())
.jobErrorHandlerType(Strings.isNullOrEmpty(annotation.jobErrorHandlerType()) ?
null : annotation.jobErrorHandlerType())
.jobListenerTypes(annotation.jobListenerTypes())
.description(annotation.description())
diff --git
a/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/annotation/JobAnnotationBuilderTest.java
b/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/annotation/JobAnnotationBuilderTest.java
index 579cde474..201e7ad76 100644
---
a/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/annotation/JobAnnotationBuilderTest.java
+++
b/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/annotation/JobAnnotationBuilderTest.java
@@ -42,7 +42,7 @@ class JobAnnotationBuilderTest {
assertThat(jobConfig.getMaxTimeDiffSeconds(), is(-1));
assertThat(jobConfig.getReconcileIntervalMinutes(), is(10));
assertNull(jobConfig.getJobShardingStrategyType());
- assertNull(jobConfig.getJobExecutorServiceHandlerType());
+ assertNull(jobConfig.getJobExecutorThreadPoolSizeProviderType());
assertNull(jobConfig.getJobErrorHandlerType());
assertThat(jobConfig.getDescription(), is("desc"));
assertThat(jobConfig.getProps().getProperty("print.title"), is("test
title"));
diff --git
a/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/job/ElasticJobConfigurationProperties.java
b/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/job/ElasticJobConfigurationProperties.java
index f3ef7bcea..b1ab7691f 100644
---
a/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/job/ElasticJobConfigurationProperties.java
+++
b/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/job/ElasticJobConfigurationProperties.java
@@ -61,7 +61,7 @@ public final class ElasticJobConfigurationProperties {
private String jobShardingStrategyType;
- private String jobExecutorServiceHandlerType;
+ private String jobExecutorThreadPoolSizeProviderType;
private String jobErrorHandlerType;
@@ -86,7 +86,7 @@ public final class ElasticJobConfigurationProperties {
.cron(cron).timeZone(timeZone).shardingItemParameters(shardingItemParameters).jobParameter(jobParameter)
.monitorExecution(monitorExecution).failover(failover).misfire(misfire)
.maxTimeDiffSeconds(maxTimeDiffSeconds).reconcileIntervalMinutes(reconcileIntervalMinutes)
-
.jobShardingStrategyType(jobShardingStrategyType).jobExecutorServiceHandlerType(jobExecutorServiceHandlerType).jobErrorHandlerType(jobErrorHandlerType)
+
.jobShardingStrategyType(jobShardingStrategyType).jobExecutorThreadPoolSizeProviderType(jobExecutorThreadPoolSizeProviderType).jobErrorHandlerType(jobErrorHandlerType)
.jobListenerTypes(jobListenerTypes.toArray(new
String[0])).description(description).disabled(disabled).overwrite(overwrite).build();
props.stringPropertyNames().forEach(each ->
result.getProps().setProperty(each, props.getProperty(each)));
return result;
diff --git
a/spring/boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/spring/boot/job/ElasticJobConfigurationPropertiesTest.java
b/spring/boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/spring/boot/job/ElasticJobConfigurationPropertiesTest.java
index 19f2e81a6..a098059d0 100644
---
a/spring/boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/spring/boot/job/ElasticJobConfigurationPropertiesTest.java
+++
b/spring/boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/spring/boot/job/ElasticJobConfigurationPropertiesTest.java
@@ -45,7 +45,7 @@ class ElasticJobConfigurationPropertiesTest {
properties.setMaxTimeDiffSeconds(1);
properties.setReconcileIntervalMinutes(2);
properties.setJobShardingStrategyType("strategyType");
- properties.setJobExecutorServiceHandlerType("executorType");
+ properties.setJobExecutorThreadPoolSizeProviderType("executorType");
properties.setJobErrorHandlerType("errorHandlerType");
properties.setJobListenerTypes(Collections.singleton("listenerType"));
properties.setDescription("test desc");
@@ -62,7 +62,7 @@ class ElasticJobConfigurationPropertiesTest {
assertThat(actual.getMaxTimeDiffSeconds(),
is(properties.getMaxTimeDiffSeconds()));
assertThat(actual.getReconcileIntervalMinutes(),
is(properties.getReconcileIntervalMinutes()));
assertThat(actual.getJobShardingStrategyType(),
is(properties.getJobShardingStrategyType()));
- assertThat(actual.getJobExecutorServiceHandlerType(),
is(properties.getJobExecutorServiceHandlerType()));
+ assertThat(actual.getJobExecutorThreadPoolSizeProviderType(),
is(properties.getJobExecutorThreadPoolSizeProviderType()));
assertThat(actual.getJobErrorHandlerType(),
is(properties.getJobErrorHandlerType()));
assertThat(actual.getJobListenerTypes().toArray(),
is(properties.getJobListenerTypes().toArray()));
assertThat(actual.getDescription(), is(properties.getDescription()));