You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/07/01 10:37:26 UTC
[shardingsphere-elasticjob-lite] branch master updated: Add
OneOffJobBootstrap (#879)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob-lite.git
The following commit(s) were added to refs/heads/master by this push:
new b15ba15 Add OneOffJobBootstrap (#879)
b15ba15 is described below
commit b15ba15c1e151aee3e8810cc30b41248c5ad6a61
Author: Liang Zhang <te...@163.com>
AuthorDate: Wed Jul 1 18:37:17 2020 +0800
Add OneOffJobBootstrap (#879)
* Simplify LiteJobFacade's constructor
* Rename JobScheduler to ScheduleJobBootstrap
* Add OneOffJobBootstrap
* move to bootstrap package
* Fix test cases
* use simple trigger for OneOffJobBootstrap
* use trigger job for second time with one off job
---
.../JobBootstrap.java} | 40 ++++++++++----------
.../bootstrap/OneOffJobBootstrap.java} | 40 ++++++++------------
.../bootstrap/ScheduleJobBootstrap.java} | 43 ++++++++++------------
.../elasticjob/lite/config/JobConfiguration.java | 1 -
.../lite/executor/ElasticJobExecutor.java | 12 +-----
.../internal/schedule/JobScheduleController.java | 27 ++++++++++++--
.../elasticjob/lite/internal/schedule/LiteJob.java | 4 +-
.../lite/internal/schedule/LiteJobFacade.java | 10 +----
.../lite/config/JobConfigurationTest.java | 5 ---
.../type/impl/DataflowJobExecutorTest.java | 2 +-
.../executor/type/impl/ScriptJobExecutorTest.java | 6 +--
.../executor/type/impl/SimpleJobExecutorTest.java | 4 +-
.../executor/type/impl/WrongJobExecutorTest.java | 2 +-
.../integrate/AbstractBaseStdJobAutoInitTest.java | 2 +-
.../lite/integrate/AbstractBaseStdJobTest.java | 15 ++++----
.../lite/integrate/std/simple/DisabledJobTest.java | 2 +-
.../lite/internal/schedule/LiteJobFacadeTest.java | 2 +-
.../common/AbstractJobBeanDefinitionParser.java | 6 +--
.../elasticjob/lite/example/JavaMain.java | 14 +++----
.../lite/example/config/DataflowJobConfig.java | 11 +++---
.../lite/example/config/SimpleJobConfig.java | 10 ++---
21 files changed, 121 insertions(+), 137 deletions(-)
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/JobBootstrap.java
similarity index 88%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java
rename to elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/JobBootstrap.java
index 002fa92..5784351 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/JobBootstrap.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,8 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.api;
+package org.apache.shardingsphere.elasticjob.lite.api.bootstrap;
+import lombok.Getter;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
import org.apache.shardingsphere.elasticjob.lite.api.listener.AbstractDistributeOnceElasticJobListener;
import org.apache.shardingsphere.elasticjob.lite.api.listener.ElasticJobListener;
import org.apache.shardingsphere.elasticjob.lite.api.script.ScriptJob;
@@ -44,9 +46,9 @@ import java.util.List;
import java.util.Properties;
/**
- * Job scheduler.
+ * Schedule job bootstrap.
*/
-public final class JobScheduler {
+public abstract class JobBootstrap {
private static final String REG_CENTER_DATA_MAP_KEY = "regCenter";
@@ -62,6 +64,7 @@ public final class JobScheduler {
private final ElasticJob elasticJob;
+ @Getter
private final JobConfiguration jobConfig;
private final List<ElasticJobListener> elasticJobListeners;
@@ -72,11 +75,11 @@ public final class JobScheduler {
private final SchedulerFacade schedulerFacade;
- public JobScheduler(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final JobConfiguration jobConfig, final ElasticJobListener... elasticJobListeners) {
+ public JobBootstrap(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final JobConfiguration jobConfig, final ElasticJobListener... elasticJobListeners) {
this(regCenter, elasticJob, jobConfig, null, elasticJobListeners);
}
- public JobScheduler(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final JobConfiguration jobConfig, final TracingConfiguration tracingConfig,
+ public JobBootstrap(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final JobConfiguration jobConfig, final TracingConfiguration tracingConfig,
final ElasticJobListener... elasticJobListeners) {
this.regCenter = regCenter;
this.elasticJob = elasticJob;
@@ -86,7 +89,6 @@ public final class JobScheduler {
schedulerFacade = new SchedulerFacade(regCenter, jobConfig.getJobName());
this.jobConfig = setUpFacade.setUpJobConfiguration(null == elasticJob ? ScriptJob.class.getName() : elasticJob.getClass().getName(), jobConfig);
setGuaranteeServiceForElasticJobListeners(regCenter, this.elasticJobListeners);
- registerStartUpInfo();
}
private void setGuaranteeServiceForElasticJobListeners(final CoordinatorRegistryCenter regCenter, final List<ElasticJobListener> elasticJobListeners) {
@@ -98,6 +100,13 @@ public final class JobScheduler {
}
}
+ protected final JobScheduleController createJobScheduleController() {
+ JobScheduleController result = new JobScheduleController(createScheduler(), createJobDetail(), getJobConfig().getJobName());
+ JobRegistry.getInstance().registerJob(getJobConfig().getJobName(), result);
+ registerStartUpInfo();
+ return result;
+ }
+
private void registerStartUpInfo() {
JobRegistry.getInstance().registerRegistryCenter(jobConfig.getJobName(), regCenter);
JobRegistry.getInstance().addJobInstance(jobConfig.getJobName(), new JobInstance());
@@ -105,15 +114,6 @@ public final class JobScheduler {
setUpFacade.registerStartUpInfo(!jobConfig.isDisabled());
}
- /**
- * Initialize job.
- */
- public void init() {
- JobScheduleController jobScheduleController = new JobScheduleController(createScheduler(), createJobDetail(), jobConfig.getJobName());
- JobRegistry.getInstance().registerJob(jobConfig.getJobName(), jobScheduleController);
- jobScheduleController.scheduleJob(jobConfig.getCron());
- }
-
private Scheduler createScheduler() {
Scheduler result;
try {
@@ -131,7 +131,7 @@ public final class JobScheduler {
Properties result = new Properties();
result.put("org.quartz.threadPool.class", SimpleThreadPool.class.getName());
result.put("org.quartz.threadPool.threadCount", "1");
- result.put("org.quartz.scheduler.instanceName", jobConfig.getJobName());
+ result.put("org.quartz.scheduler.instanceName", getJobConfig().getJobName());
result.put("org.quartz.jobStore.misfireThreshold", "1");
result.put("org.quartz.plugin.shutdownhook.class", JobShutdownHookPlugin.class.getName());
result.put("org.quartz.plugin.shutdownhook.cleanShutdown", Boolean.TRUE.toString());
@@ -139,9 +139,9 @@ public final class JobScheduler {
}
private JobDetail createJobDetail() {
- JobDetail result = JobBuilder.newJob(LiteJob.class).withIdentity(jobConfig.getJobName()).build();
+ JobDetail result = JobBuilder.newJob(LiteJob.class).withIdentity(getJobConfig().getJobName()).build();
result.getJobDataMap().put(REG_CENTER_DATA_MAP_KEY, regCenter);
- result.getJobDataMap().put(JOB_CONFIG_DATA_MAP_KEY, jobConfig);
+ result.getJobDataMap().put(JOB_CONFIG_DATA_MAP_KEY, getJobConfig());
result.getJobDataMap().put(JOB_LISTENERS_DATA_MAP_KEY, elasticJobListeners);
result.getJobDataMap().put(TRACING_CONFIG_DATA_MAP_KEY, tracingConfig);
if (null != elasticJob && !elasticJob.getClass().getName().equals(ScriptJob.class.getName())) {
@@ -153,7 +153,7 @@ public final class JobScheduler {
/**
* Shutdown job.
*/
- public void shutdown() {
+ public final void shutdown() {
schedulerFacade.shutdownInstance();
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJob.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/OneOffJobBootstrap.java
similarity index 56%
copy from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJob.java
copy to elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/OneOffJobBootstrap.java
index 03fab7c..08ce449 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJob.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/OneOffJobBootstrap.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,40 +15,32 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.internal.schedule;
+package org.apache.shardingsphere.elasticjob.lite.api.bootstrap;
-import lombok.Setter;
import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
import org.apache.shardingsphere.elasticjob.lite.api.listener.ElasticJobListener;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
import org.apache.shardingsphere.elasticjob.lite.tracing.api.TracingConfiguration;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-
-import java.util.List;
/**
- * Lite job class.
+ * One off job bootstrap.
*/
-@Setter
-public final class LiteJob implements Job {
-
- private CoordinatorRegistryCenter regCenter;
-
- private ElasticJob elasticJob;
+public final class OneOffJobBootstrap extends JobBootstrap {
- private JobConfiguration jobConfig;
-
- private List<ElasticJobListener> elasticJobListeners;
+ public OneOffJobBootstrap(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final JobConfiguration jobConfig, final ElasticJobListener... elasticJobListeners) {
+ super(regCenter, elasticJob, jobConfig, elasticJobListeners);
+ }
- private TracingConfiguration tracingConfig;
+ public OneOffJobBootstrap(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final JobConfiguration jobConfig, final TracingConfiguration tracingConfig,
+ final ElasticJobListener... elasticJobListeners) {
+ super(regCenter, elasticJob, jobConfig, tracingConfig, elasticJobListeners);
+ }
- @Override
- public void execute(final JobExecutionContext context) {
- ElasticJobExecutor executor = null == tracingConfig
- ? new ElasticJobExecutor(regCenter, elasticJob, jobConfig, elasticJobListeners) : new ElasticJobExecutor(regCenter, elasticJob, jobConfig, elasticJobListeners, tracingConfig);
- executor.execute();
+ /**
+ * Execute job.
+ */
+ public void execute() {
+ createJobScheduleController().executeJob();
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJob.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/ScheduleJobBootstrap.java
similarity index 52%
copy from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJob.java
copy to elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/ScheduleJobBootstrap.java
index 03fab7c..d903daa 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJob.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/ScheduleJobBootstrap.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,40 +15,35 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.internal.schedule;
+package org.apache.shardingsphere.elasticjob.lite.api.bootstrap;
-import lombok.Setter;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
import org.apache.shardingsphere.elasticjob.lite.api.listener.ElasticJobListener;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
import org.apache.shardingsphere.elasticjob.lite.tracing.api.TracingConfiguration;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-
-import java.util.List;
/**
- * Lite job class.
+ * Schedule job bootstrap.
*/
-@Setter
-public final class LiteJob implements Job {
-
- private CoordinatorRegistryCenter regCenter;
-
- private ElasticJob elasticJob;
+public final class ScheduleJobBootstrap extends JobBootstrap {
- private JobConfiguration jobConfig;
-
- private List<ElasticJobListener> elasticJobListeners;
+ public ScheduleJobBootstrap(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final JobConfiguration jobConfig, final ElasticJobListener... elasticJobListeners) {
+ super(regCenter, elasticJob, jobConfig, elasticJobListeners);
+ }
- private TracingConfiguration tracingConfig;
+ public ScheduleJobBootstrap(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final JobConfiguration jobConfig, final TracingConfiguration tracingConfig,
+ final ElasticJobListener... elasticJobListeners) {
+ super(regCenter, elasticJob, jobConfig, tracingConfig, elasticJobListeners);
+ }
- @Override
- public void execute(final JobExecutionContext context) {
- ElasticJobExecutor executor = null == tracingConfig
- ? new ElasticJobExecutor(regCenter, elasticJob, jobConfig, elasticJobListeners) : new ElasticJobExecutor(regCenter, elasticJob, jobConfig, elasticJobListeners, tracingConfig);
- executor.execute();
+ /**
+ * Schedule job.
+ */
+ public void schedule() {
+ Preconditions.checkArgument(!Strings.isNullOrEmpty(getJobConfig().getCron()), "Cron can not be empty.");
+ createJobScheduleController().scheduleJob(getJobConfig().getCron());
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/config/JobConfiguration.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/config/JobConfiguration.java
index d709ae7..13e8e28 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/config/JobConfiguration.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/config/JobConfiguration.java
@@ -347,7 +347,6 @@ public final class JobConfiguration {
public final JobConfiguration build() {
Preconditions.checkArgument(!Strings.isNullOrEmpty(jobName), "jobName can not be empty.");
Preconditions.checkNotNull(jobType, "jobType can not be null.");
- Preconditions.checkArgument(!Strings.isNullOrEmpty(cron), "cron can not be empty.");
Preconditions.checkArgument(shardingTotalCount > 0, "shardingTotalCount should larger than zero.");
return new JobConfiguration(jobName, jobType, cron, shardingTotalCount, shardingItemParameters, jobParameter,
monitorExecution, failover, misfire, maxTimeDiffSeconds, reconcileIntervalMinutes,
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutor.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutor.java
index 41ec11e..5cbfe3c 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutor.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutor.java
@@ -69,19 +69,11 @@ public final class ElasticJobExecutor {
private final Map<Integer, String> itemErrorMessages;
- public ElasticJobExecutor(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final JobConfiguration jobConfig, final List<ElasticJobListener> elasticJobListeners) {
- this(elasticJob, jobConfig, new LiteJobFacade(regCenter, jobConfig.getJobName(), elasticJobListeners));
- }
-
- public ElasticJobExecutor(final CoordinatorRegistryCenter regCenter,
+ public ElasticJobExecutor(final CoordinatorRegistryCenter regCenter,
final ElasticJob elasticJob, final JobConfiguration jobConfig, final List<ElasticJobListener> elasticJobListeners, final TracingConfiguration tracingConfig) {
- this(elasticJob, jobConfig, new LiteJobFacade(regCenter, jobConfig.getJobName(), elasticJobListeners, tracingConfig));
- }
-
- private ElasticJobExecutor(final ElasticJob elasticJob, final JobConfiguration jobConfig, final JobFacade jobFacade) {
this.elasticJob = elasticJob;
this.jobConfig = jobConfig;
- this.jobFacade = jobFacade;
+ this.jobFacade = new LiteJobFacade(regCenter, jobConfig.getJobName(), elasticJobListeners, tracingConfig);
jobItemExecutor = getJobItemExecutor(elasticJob);
executorService = JobExecutorServiceHandlerFactory.getHandler(jobConfig.getJobExecutorServiceHandlerType()).createExecutorService(jobConfig.getJobName());
jobErrorHandler = JobErrorHandlerFactory.getHandler(jobConfig.getJobErrorHandlerType());
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduleController.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduleController.java
index 2471507..48c7470 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduleController.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduleController.java
@@ -24,6 +24,7 @@ import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
+import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.TriggerKey;
@@ -41,6 +42,26 @@ public final class JobScheduleController {
private final String triggerIdentity;
/**
+ * Execute job.
+ */
+ public void executeJob() {
+ try {
+ if (!scheduler.checkExists(jobDetail.getKey())) {
+ scheduler.scheduleJob(jobDetail, createOneOffTrigger());
+ scheduler.start();
+ } else {
+ scheduler.triggerJob(jobDetail.getKey());
+ }
+ } catch (final SchedulerException ex) {
+ throw new JobSystemException(ex);
+ }
+ }
+
+ private Trigger createOneOffTrigger() {
+ return TriggerBuilder.newTrigger().withIdentity(triggerIdentity).withSchedule(SimpleScheduleBuilder.simpleSchedule()).build();
+ }
+
+ /**
* Schedule job.
*
* @param cron CRON expression
@@ -48,7 +69,7 @@ public final class JobScheduleController {
public void scheduleJob(final String cron) {
try {
if (!scheduler.checkExists(jobDetail.getKey())) {
- scheduler.scheduleJob(jobDetail, createTrigger(cron));
+ scheduler.scheduleJob(jobDetail, createCronTrigger(cron));
}
scheduler.start();
} catch (final SchedulerException ex) {
@@ -65,14 +86,14 @@ public final class JobScheduleController {
try {
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(TriggerKey.triggerKey(triggerIdentity));
if (!scheduler.isShutdown() && null != trigger && !cron.equals(trigger.getCronExpression())) {
- scheduler.rescheduleJob(TriggerKey.triggerKey(triggerIdentity), createTrigger(cron));
+ scheduler.rescheduleJob(TriggerKey.triggerKey(triggerIdentity), createCronTrigger(cron));
}
} catch (final SchedulerException ex) {
throw new JobSystemException(ex);
}
}
- private CronTrigger createTrigger(final String cron) {
+ private Trigger createCronTrigger(final String cron) {
return TriggerBuilder.newTrigger().withIdentity(triggerIdentity).withSchedule(CronScheduleBuilder.cronSchedule(cron).withMisfireHandlingInstructionDoNothing()).build();
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJob.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJob.java
index 03fab7c..dbfd7ca 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJob.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJob.java
@@ -47,8 +47,6 @@ public final class LiteJob implements Job {
@Override
public void execute(final JobExecutionContext context) {
- ElasticJobExecutor executor = null == tracingConfig
- ? new ElasticJobExecutor(regCenter, elasticJob, jobConfig, elasticJobListeners) : new ElasticJobExecutor(regCenter, elasticJob, jobConfig, elasticJobListeners, tracingConfig);
- executor.execute();
+ new ElasticJobExecutor(regCenter, elasticJob, jobConfig, elasticJobListeners, tracingConfig).execute();
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacade.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacade.java
index 4fe4d23..d3cd78c 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacade.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacade.java
@@ -63,22 +63,14 @@ public final class LiteJobFacade implements JobFacade {
private final JobEventBus jobEventBus;
- public LiteJobFacade(final CoordinatorRegistryCenter regCenter, final String jobName, final List<ElasticJobListener> elasticJobListeners) {
- this(regCenter, jobName, elasticJobListeners, new JobEventBus());
- }
-
public LiteJobFacade(final CoordinatorRegistryCenter regCenter, final String jobName, final List<ElasticJobListener> elasticJobListeners, final TracingConfiguration tracingConfig) {
- this(regCenter, jobName, elasticJobListeners, new JobEventBus(tracingConfig));
- }
-
- private LiteJobFacade(final CoordinatorRegistryCenter regCenter, final String jobName, final List<ElasticJobListener> elasticJobListeners, final JobEventBus jobEventBus) {
configService = new ConfigurationService(regCenter, jobName);
shardingService = new ShardingService(regCenter, jobName);
executionContextService = new ExecutionContextService(regCenter, jobName);
executionService = new ExecutionService(regCenter, jobName);
failoverService = new FailoverService(regCenter, jobName);
this.elasticJobListeners = elasticJobListeners;
- this.jobEventBus = jobEventBus;
+ this.jobEventBus = null == tracingConfig ? new JobEventBus() : new JobEventBus(tracingConfig);
}
@Override
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/config/JobConfigurationTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/config/JobConfigurationTest.java
index 7a1f016..f126fe6 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/config/JobConfigurationTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/config/JobConfigurationTest.java
@@ -91,11 +91,6 @@ public final class JobConfigurationTest {
}
@Test(expected = IllegalArgumentException.class)
- public void assertBuildWithEmptyCron() {
- JobConfiguration.newBuilder("test_job", JobType.SIMPLE, "", 3).build();
- }
-
- @Test(expected = IllegalArgumentException.class)
public void assertBuildWithInvalidShardingTotalCount() {
JobConfiguration.newBuilder("test_job", JobType.SIMPLE, "0/1 * * * * ?", -1).build();
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java
index e3aa7b6..67c5dc1 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java
@@ -177,7 +177,7 @@ public final class DataflowJobExecutorTest {
JobConfiguration jobConfig = JobConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, JobType.DATAFLOW, "0/1 * * * * ?", 3)
.jobErrorHandlerType("IGNORE").setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.toString(isStreamingProcess)).build();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
- elasticJobExecutor = new ElasticJobExecutor(regCenter, new TestDataflowJob(jobCaller), jobConfig, Collections.emptyList());
+ elasticJobExecutor = new ElasticJobExecutor(regCenter, new TestDataflowJob(jobCaller), jobConfig, Collections.emptyList(), null);
ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java
index ec561e2..3d80ef2 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java
@@ -47,7 +47,7 @@ public final class ScriptJobExecutorTest {
@Test
public void assertExecuteWhenCommandLineIsEmpty() {
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, ShardingContextsBuilder.getMultipleShardingContexts());
- elasticJobExecutor = new ElasticJobExecutor(regCenter, null, createJobConfiguration("", "IGNORE"), Collections.emptyList());
+ elasticJobExecutor = new ElasticJobExecutor(regCenter, null, createJobConfiguration("", "IGNORE"), Collections.emptyList(), null);
ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
elasticJobExecutor.execute();
}
@@ -64,7 +64,7 @@ public final class ScriptJobExecutorTest {
private void assertExecuteWhenExecuteFailure(final ShardingContexts shardingContexts) {
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
- elasticJobExecutor = new ElasticJobExecutor(regCenter, null, createJobConfiguration("not_exists_file", "THROW"), Collections.emptyList());
+ elasticJobExecutor = new ElasticJobExecutor(regCenter, null, createJobConfiguration("not_exists_file", "THROW"), Collections.emptyList(), null);
ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
elasticJobExecutor.execute();
}
@@ -81,7 +81,7 @@ public final class ScriptJobExecutorTest {
private void assertExecuteSuccess(final ShardingContexts shardingContexts) {
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
- elasticJobExecutor = new ElasticJobExecutor(regCenter, null, createJobConfiguration("exists_file param0 param1", "IGNORE"), Collections.emptyList());
+ elasticJobExecutor = new ElasticJobExecutor(regCenter, null, createJobConfiguration("exists_file param0 param1", "IGNORE"), Collections.emptyList(), null);
ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
elasticJobExecutor.execute();
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
index 38d0d42..19d0e39 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
@@ -63,7 +63,7 @@ public final class SimpleJobExecutorTest {
@Before
public void setUp() {
- elasticJobExecutor = new ElasticJobExecutor(regCenter, new TestSimpleJob(jobCaller), createJobConfiguration(null, "THROW"), Collections.emptyList());
+ elasticJobExecutor = new ElasticJobExecutor(regCenter, new TestSimpleJob(jobCaller), createJobConfiguration(null, "THROW"), Collections.emptyList(), null);
ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
}
@@ -75,7 +75,7 @@ public final class SimpleJobExecutorTest {
@Test
public void assertNewExecutorWithDefaultHandlers() {
- elasticJobExecutor = new ElasticJobExecutor(regCenter, new TestSimpleJob(jobCaller), createJobConfiguration(null, null), Collections.emptyList());
+ elasticJobExecutor = new ElasticJobExecutor(regCenter, new TestSimpleJob(jobCaller), createJobConfiguration(null, null), Collections.emptyList(), null);
assertThat(ReflectionUtils.getFieldValue(elasticJobExecutor, "executorService"), instanceOf(new CPUUsageJobExecutorServiceHandler().createExecutorService("test_job").getClass()));
assertThat(ReflectionUtils.getFieldValue(elasticJobExecutor, "jobErrorHandler"), instanceOf(LogJobErrorHandler.class));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
index 270de14..3332e99 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
@@ -53,7 +53,7 @@ public final class WrongJobExecutorTest {
@Before
public void setUp() {
- wrongJobExecutor = new ElasticJobExecutor(regCenter, new TestWrongJob(), createJobConfiguration(), Collections.emptyList());
+ wrongJobExecutor = new ElasticJobExecutor(regCenter, new TestWrongJob(), createJobConfiguration(), Collections.emptyList(), null);
ReflectionUtils.setFieldValue(wrongJobExecutor, "jobFacade", jobFacade);
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobAutoInitTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobAutoInitTest.java
index 4f373b4..e58aa5e 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobAutoInitTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobAutoInitTest.java
@@ -33,7 +33,7 @@ public abstract class AbstractBaseStdJobAutoInitTest extends AbstractBaseStdJobT
@Before
public void autoJobInit() {
setJobConfiguration(getJobConfiguration());
- initJob();
+ scheduleJob();
assertRegCenterCommonInfoWithEnabled();
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java
index 8a61f74..0179534 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java
@@ -21,8 +21,8 @@ import lombok.AccessLevel;
import lombok.Getter;
import lombok.SneakyThrows;
import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.api.JobScheduler;
import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.ScheduleJobBootstrap;
import org.apache.shardingsphere.elasticjob.lite.api.dataflow.DataflowJob;
import org.apache.shardingsphere.elasticjob.lite.api.listener.AbstractDistributeOnceElasticJobListener;
import org.apache.shardingsphere.elasticjob.lite.api.listener.ElasticJobListener;
@@ -37,7 +37,6 @@ import org.apache.shardingsphere.elasticjob.lite.internal.config.yaml.YamlJobCon
import org.apache.shardingsphere.elasticjob.lite.internal.election.LeaderService;
import org.apache.shardingsphere.elasticjob.lite.internal.monitor.MonitorService;
import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
-import org.apache.shardingsphere.elasticjob.lite.internal.schedule.SchedulerFacade;
import org.apache.shardingsphere.elasticjob.lite.internal.server.ServerStatus;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
import org.apache.shardingsphere.elasticjob.lite.reg.zookeeper.ZookeeperConfiguration;
@@ -69,7 +68,7 @@ public abstract class AbstractBaseStdJobTest {
@Getter(AccessLevel.PROTECTED)
private final JobConfiguration jobConfiguration;
- private final JobScheduler jobScheduler;
+ private final ScheduleJobBootstrap scheduleJobBootstrap;
private final boolean disabled;
@@ -82,7 +81,7 @@ public abstract class AbstractBaseStdJobTest {
protected AbstractBaseStdJobTest(final Class<? extends ElasticJob> elasticJobClass, final boolean disabled) {
this.disabled = disabled;
jobConfiguration = initJobConfig(elasticJobClass);
- jobScheduler = new JobScheduler(regCenter, ScriptJob.class == elasticJobClass ? null : elasticJobClass.newInstance(), jobConfiguration, new ElasticJobListener() {
+ scheduleJobBootstrap = new ScheduleJobBootstrap(regCenter, ScriptJob.class == elasticJobClass ? null : elasticJobClass.newInstance(), jobConfiguration, new ElasticJobListener() {
@Override
public void beforeJobExecuted(final ShardingContexts shardingContexts) {
@@ -109,7 +108,7 @@ public abstract class AbstractBaseStdJobTest {
@SneakyThrows
protected AbstractBaseStdJobTest(final Class<? extends ElasticJob> elasticJobClass) {
jobConfiguration = initJobConfig(elasticJobClass);
- jobScheduler = new JobScheduler(regCenter, elasticJobClass.newInstance(), jobConfiguration);
+ scheduleJobBootstrap = new ScheduleJobBootstrap(regCenter, elasticJobClass.newInstance(), jobConfiguration);
disabled = false;
leaderService = new LeaderService(regCenter, jobName);
}
@@ -152,12 +151,12 @@ public abstract class AbstractBaseStdJobTest {
@After
public void tearDown() {
- ((SchedulerFacade) ReflectionUtils.getFieldValue(jobScheduler, "schedulerFacade")).shutdownInstance();
+ scheduleJobBootstrap.shutdown();
ReflectionUtils.setFieldValue(JobRegistry.getInstance(), "instance", null);
}
- protected final void initJob() {
- jobScheduler.init();
+ protected final void scheduleJob() {
+ scheduleJobBootstrap.schedule();
}
final void assertRegCenterCommonInfoWithEnabled() {
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/DisabledJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/DisabledJobTest.java
index f0f7809..a8208c8 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/DisabledJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/DisabledJobTest.java
@@ -37,7 +37,7 @@ public final class DisabledJobTest extends AbstractBaseStdJobTest {
@Test
public void assertJobInit() {
- initJob();
+ scheduleJob();
assertRegCenterCommonInfoWithDisabled();
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java
index f4f0b45..b0f0267 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java
@@ -75,7 +75,7 @@ public final class LiteJobFacadeTest {
@Before
public void setUp() {
- liteJobFacade = new LiteJobFacade(null, "test_job", Collections.singletonList(new TestElasticJobListener(caller)));
+ liteJobFacade = new LiteJobFacade(null, "test_job", Collections.singletonList(new TestElasticJobListener(caller)), null);
ReflectionUtils.setFieldValue(liteJobFacade, "configService", configService);
ReflectionUtils.setFieldValue(liteJobFacade, "shardingService", shardingService);
ReflectionUtils.setFieldValue(liteJobFacade, "executionContextService", executionContextService);
diff --git a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java
index 0f29d17..9d363ce 100644
--- a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java
+++ b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.elasticjob.lite.spring.job.parser.common;
import com.google.common.base.Strings;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.elasticjob.lite.api.JobScheduler;
import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.ScheduleJobBootstrap;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.tracing.api.TracingConfiguration;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -43,8 +43,8 @@ public abstract class AbstractJobBeanDefinitionParser extends AbstractBeanDefini
@SneakyThrows
@Override
protected final AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
- BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(JobScheduler.class);
- factory.setInitMethodName("init");
+ BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(ScheduleJobBootstrap.class);
+ factory.setInitMethodName("schedule");
factory.addConstructorArgReference(element.getAttribute(BaseJobBeanDefinitionParserTag.REGISTRY_CENTER_REF_ATTRIBUTE));
factory.addConstructorArgReference(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE));
factory.addConstructorArgValue(createJobConfiguration(element));
diff --git a/examples/elastic-job-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java b/examples/elastic-job-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java
index 66ad6e7..225996d 100644
--- a/examples/elastic-job-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java
+++ b/examples/elastic-job-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.elasticjob.lite.example;
import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.shardingsphere.elasticjob.lite.api.JobScheduler;
import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.ScheduleJobBootstrap;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.example.job.dataflow.JavaDataflowJob;
import org.apache.shardingsphere.elasticjob.lite.example.job.simple.JavaSimpleJob;
@@ -85,18 +85,18 @@ public final class JavaMain {
}
private static void setUpSimpleJob(final CoordinatorRegistryCenter regCenter, final TracingConfiguration tracingConfig) {
- new JobScheduler(regCenter, new JavaSimpleJob(), JobConfiguration.newBuilder("javaSimpleJob", JobType.SIMPLE, "0/5 * * * * ?", 3)
- .shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou").build(), tracingConfig).init();
+ new ScheduleJobBootstrap(regCenter, new JavaSimpleJob(), JobConfiguration.newBuilder("javaSimpleJob", JobType.SIMPLE, "0/5 * * * * ?", 3)
+ .shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou").build(), tracingConfig).schedule();
}
private static void setUpDataflowJob(final CoordinatorRegistryCenter regCenter, final TracingConfiguration tracingConfig) {
- new JobScheduler(regCenter, new JavaDataflowJob(), JobConfiguration.newBuilder("javaDataflowElasticJob", JobType.DATAFLOW, "0/5 * * * * ?", 3)
- .shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou").setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build(), tracingConfig).init();
+ new ScheduleJobBootstrap(regCenter, new JavaDataflowJob(), JobConfiguration.newBuilder("javaDataflowElasticJob", JobType.DATAFLOW, "0/5 * * * * ?", 3)
+ .shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou").setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build(), tracingConfig).schedule();
}
private static void setUpScriptJob(final CoordinatorRegistryCenter regCenter, final TracingConfiguration tracingConfig) throws IOException {
- new JobScheduler(regCenter, null, JobConfiguration.newBuilder("scriptElasticJob", JobType.SCRIPT, "0/5 * * * * ?", 3)
- .setProperty(ScriptJobExecutor.SCRIPT_KEY, buildScriptCommandLine()).build(), tracingConfig).init();
+ new ScheduleJobBootstrap(regCenter, null, JobConfiguration.newBuilder("scriptElasticJob", JobType.SCRIPT, "0/5 * * * * ?", 3)
+ .setProperty(ScriptJobExecutor.SCRIPT_KEY, buildScriptCommandLine()).build(), tracingConfig).schedule();
}
private static String buildScriptCommandLine() throws IOException {
diff --git a/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/DataflowJobConfig.java b/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/DataflowJobConfig.java
index 6520cfd..abeaa8a 100644
--- a/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/DataflowJobConfig.java
+++ b/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/DataflowJobConfig.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.elasticjob.lite.example.config;
-import org.apache.shardingsphere.elasticjob.lite.api.JobScheduler;
import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.ScheduleJobBootstrap;
import org.apache.shardingsphere.elasticjob.lite.api.dataflow.DataflowJob;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.example.job.dataflow.SpringDataflowJob;
@@ -45,10 +45,11 @@ public class DataflowJobConfig {
return new SpringDataflowJob();
}
- @Bean(initMethod = "init")
- public JobScheduler dataflowJobScheduler(final DataflowJob dataflowJob, @Value("${dataflowJob.cron}") final String cron, @Value("${dataflowJob.shardingTotalCount}") final int shardingTotalCount,
- @Value("${dataflowJob.shardingItemParameters}") final String shardingItemParameters) {
- return new JobScheduler(regCenter, dataflowJob, getJobConfiguration(dataflowJob.getClass(), cron, shardingTotalCount, shardingItemParameters), tracingConfig);
+ @Bean(initMethod = "schedule")
+ public ScheduleJobBootstrap dataflowJobScheduler(final DataflowJob dataflowJob, @Value("${dataflowJob.cron}") final String cron,
+ @Value("${dataflowJob.shardingTotalCount}") final int shardingTotalCount,
+ @Value("${dataflowJob.shardingItemParameters}") final String shardingItemParameters) {
+ return new ScheduleJobBootstrap(regCenter, dataflowJob, getJobConfiguration(dataflowJob.getClass(), cron, shardingTotalCount, shardingItemParameters), tracingConfig);
}
private JobConfiguration getJobConfiguration(final Class<? extends DataflowJob> jobClass, final String cron, final int shardingTotalCount, final String shardingItemParameters) {
diff --git a/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/SimpleJobConfig.java b/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/SimpleJobConfig.java
index 49c5f29..89c0aeb 100644
--- a/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/SimpleJobConfig.java
+++ b/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/SimpleJobConfig.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.elasticjob.lite.example.config;
-import org.apache.shardingsphere.elasticjob.lite.api.JobScheduler;
import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.ScheduleJobBootstrap;
import org.apache.shardingsphere.elasticjob.lite.api.simple.SimpleJob;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.example.job.simple.SpringSimpleJob;
@@ -44,10 +44,10 @@ public class SimpleJobConfig {
return new SpringSimpleJob();
}
- @Bean(initMethod = "init")
- public JobScheduler simpleJobScheduler(final SimpleJob simpleJob, @Value("${simpleJob.cron}") final String cron, @Value("${simpleJob.shardingTotalCount}") final int shardingTotalCount,
- @Value("${simpleJob.shardingItemParameters}") final String shardingItemParameters) {
- return new JobScheduler(regCenter, simpleJob, getJobConfiguration(simpleJob.getClass(), cron, shardingTotalCount, shardingItemParameters), tracingConfig);
+ @Bean(initMethod = "schedule")
+ public ScheduleJobBootstrap simpleJobScheduler(final SimpleJob simpleJob, @Value("${simpleJob.cron}") final String cron, @Value("${simpleJob.shardingTotalCount}") final int shardingTotalCount,
+ @Value("${simpleJob.shardingItemParameters}") final String shardingItemParameters) {
+ return new ScheduleJobBootstrap(regCenter, simpleJob, getJobConfiguration(simpleJob.getClass(), cron, shardingTotalCount, shardingItemParameters), tracingConfig);
}
private JobConfiguration getJobConfiguration(final Class<? extends SimpleJob> jobClass, final String cron, final int shardingTotalCount, final String shardingItemParameters) {