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/04 09:09:23 UTC
[shardingsphere-elasticjob-lite] branch master updated: Use SPI to
introduce job type (#934)
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 f64cc3b Use SPI to introduce job type (#934)
f64cc3b is described below
commit f64cc3b1fc5dc6db38e25b93b400299ce7873f4b
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat Jul 4 17:09:12 2020 +0800
Use SPI to introduce job type (#934)
* Add JobItemExecutor.getElasticJobClass
* Make ElasticJobExecutor to SPI provided
* Add JobItemExecutorFactoryTest
* Refactor JobItemExecutorFactoryTest fixture
* Add ClassedJobItemExecutor and TypedJobItemExecutor
* Add back ScriptJobExecutor
* Remove ScriptJob usage
* Remove ScriptJob
* Remove useless typed job
---
.../lite/executor/ElasticJobExecutor.java | 32 ++++----
.../type/ClassedJobItemExecutor.java} | 17 ++--
.../lite/executor/type/JobItemExecutorFactory.java | 83 +++++++++++++++++++
.../type/TypedJobItemExecutor.java} | 15 +---
.../executor/type/impl/DataflowJobExecutor.java | 11 ++-
.../type/impl/ScriptJobExecutor.java} | 37 ++++-----
.../lite/executor/type/impl/SimpleJobExecutor.java | 11 ++-
.../elasticjob/lite/internal/schedule/LiteJob.java | 10 ++-
.../elasticjob/lite/job/TypedJobFactory.java | 60 --------------
.../elasticjob/lite/scheduler/JobScheduler.java | 22 +++++-
....elasticjob.lite.executor.type.JobItemExecutor} | 4 +-
.../executor/type/JobItemExecutorFactoryTest.java | 57 ++++++++++++++
.../fixture/executor/ClassedFooJobExecutor.java} | 21 ++---
.../fixture/executor/TypedFooJobExecutor.java} | 23 ++----
.../executor/type/fixture/job/DetailedFooJob.java} | 19 +----
.../lite/executor/type/fixture/job/FailedJob.java} | 17 +---
.../lite/executor/type/fixture/job/FooJob.java} | 17 +---
.../executor/type/impl/ScriptJobExecutorTest.java | 92 ++++++++++++++++++++++
.../lite/integrate/BaseIntegrateTest.java | 17 ++++
.../lite/integrate/EnabledJobIntegrateTest.java | 4 +
.../enable/oneoff/script/ScriptElasticJobTest.java | 10 +--
.../schedule/script/ScriptElasticJobTest.java | 10 +--
.../elasticjob/lite/job/TypedJobFactoryTest.java | 43 ----------
.../elasticjob/lite/job/impl/ScriptJobTest.java | 55 -------------
....elasticjob.lite.executor.type.JobItemExecutor} | 3 +-
.../lite/lifecycle/domain/JobSettings.java | 4 +-
.../internal/settings/JobSettingsAPIImpl.java | 6 +-
.../script/ScriptJobBeanDefinitionParser.java | 4 +-
.../elasticjob/lite/example/JavaMain.java | 4 +-
29 files changed, 385 insertions(+), 323 deletions(-)
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 5a37f14..aa99d2f 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
@@ -20,16 +20,12 @@ package org.apache.shardingsphere.elasticjob.lite.executor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.listener.ElasticJobListener;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.DataflowJob;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.SimpleJob;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.api.listener.ElasticJobListener;
import org.apache.shardingsphere.elasticjob.lite.exception.ExceptionUtils;
-import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
import org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.SimpleJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutorFactory;
import org.apache.shardingsphere.elasticjob.lite.handler.error.JobErrorHandler;
import org.apache.shardingsphere.elasticjob.lite.handler.error.JobErrorHandlerFactory;
import org.apache.shardingsphere.elasticjob.lite.handler.threadpool.JobExecutorServiceHandlerFactory;
@@ -70,25 +66,25 @@ public final class ElasticJobExecutor {
public ElasticJobExecutor(final CoordinatorRegistryCenter regCenter,
final ElasticJob elasticJob, final JobConfiguration jobConfig, final List<ElasticJobListener> elasticJobListeners, final TracingConfiguration tracingConfig) {
+ this(regCenter, elasticJob, jobConfig, elasticJobListeners, tracingConfig, JobItemExecutorFactory.getExecutor(elasticJob.getClass()));
+ }
+
+ public ElasticJobExecutor(final CoordinatorRegistryCenter regCenter,
+ final String type, final JobConfiguration jobConfig, final List<ElasticJobListener> elasticJobListeners, final TracingConfiguration tracingConfig) {
+ this(regCenter, null, jobConfig, elasticJobListeners, tracingConfig, JobItemExecutorFactory.getExecutor(type));
+ }
+
+ private ElasticJobExecutor(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final JobConfiguration jobConfig,
+ final List<ElasticJobListener> elasticJobListeners, final TracingConfiguration tracingConfig, final JobItemExecutor jobItemExecutor) {
this.elasticJob = elasticJob;
this.jobConfig = jobConfig;
- this.jobFacade = new LiteJobFacade(regCenter, jobConfig.getJobName(), elasticJobListeners, tracingConfig);
- jobItemExecutor = getJobItemExecutor(elasticJob);
+ this.jobItemExecutor = jobItemExecutor;
+ jobFacade = new LiteJobFacade(regCenter, jobConfig.getJobName(), elasticJobListeners, tracingConfig);
executorService = JobExecutorServiceHandlerFactory.getHandler(jobConfig.getJobExecutorServiceHandlerType()).createExecutorService(jobConfig.getJobName());
jobErrorHandler = JobErrorHandlerFactory.getHandler(jobConfig.getJobErrorHandlerType());
itemErrorMessages = new ConcurrentHashMap<>(jobConfig.getShardingTotalCount(), 1);
}
- private static JobItemExecutor getJobItemExecutor(final ElasticJob elasticJob) {
- if (elasticJob instanceof SimpleJob) {
- return new SimpleJobExecutor();
- }
- if (elasticJob instanceof DataflowJob) {
- return new DataflowJobExecutor();
- }
- throw new JobConfigurationException("Cannot support job type '%s'", elasticJob.getClass().getCanonicalName());
- }
-
/**
* Execute job.
*/
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/ClassedJobItemExecutor.java
similarity index 74%
copy from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java
copy to elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/ClassedJobItemExecutor.java
index a4076b4..7533710 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/ClassedJobItemExecutor.java
@@ -15,22 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.job;
+package org.apache.shardingsphere.elasticjob.lite.executor.type;
import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.spi.TypedSPI;
-
-import java.util.Properties;
/**
- * Typed job.
+ * Classed job item executor.
+ *
+ * @param <T> type of ElasticJob
*/
-public interface TypedJob extends ElasticJob, TypedSPI {
+public interface ClassedJobItemExecutor<T extends ElasticJob> extends JobItemExecutor<T> {
/**
- * Initialize job.
+ * Get elastic job class.
*
- * @param props job properties
+ * @return elastic job class
*/
- void init(Properties props);
+ Class<T> getElasticJobClass();
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/JobItemExecutorFactory.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/JobItemExecutorFactory.java
new file mode 100644
index 0000000..7e4161f
--- /dev/null
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/JobItemExecutorFactory.java
@@ -0,0 +1,83 @@
+/*
+ * 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.lite.executor.type;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.ServiceLoader;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Job item executor factory.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class JobItemExecutorFactory {
+
+ private static final Map<Class, ClassedJobItemExecutor> CLASSED_EXECUTORS = new ConcurrentHashMap<>();
+
+ private static final Map<String, TypedJobItemExecutor> TYPED_EXECUTORS = new ConcurrentHashMap<>();
+
+ static {
+ for (JobItemExecutor each : ServiceLoader.load(JobItemExecutor.class)) {
+ if (each instanceof ClassedJobItemExecutor) {
+ ClassedJobItemExecutor typedJobItemExecutor = (ClassedJobItemExecutor) each;
+ CLASSED_EXECUTORS.put(typedJobItemExecutor.getElasticJobClass(), typedJobItemExecutor);
+ }
+ if (each instanceof TypedJobItemExecutor) {
+ TypedJobItemExecutor typedJobItemExecutor = (TypedJobItemExecutor) each;
+ TYPED_EXECUTORS.put(typedJobItemExecutor.getType(), typedJobItemExecutor);
+ }
+ }
+ }
+
+ /**
+ * Get executor.
+ *
+ * @param elasticJobClass elastic job class
+ * @return job item executor
+ */
+ @SuppressWarnings("unchecked")
+ public static JobItemExecutor getExecutor(final Class<? extends ElasticJob> elasticJobClass) {
+ for (Entry<Class, ClassedJobItemExecutor> entry : CLASSED_EXECUTORS.entrySet()) {
+ if (entry.getKey().isAssignableFrom(elasticJobClass)) {
+ return entry.getValue();
+ }
+ }
+ throw new JobConfigurationException("Can not find executor for elastic job class `%s`", elasticJobClass.getName());
+ }
+
+ /**
+ * Get executor.
+ *
+ * @param elasticJobType elastic job type
+ * @return job item executor
+ */
+ public static JobItemExecutor getExecutor(final String elasticJobType) {
+ for (Entry<String, TypedJobItemExecutor> entry : TYPED_EXECUTORS.entrySet()) {
+ if (entry.getKey().equals(elasticJobType)) {
+ return entry.getValue();
+ }
+ }
+ throw new JobConfigurationException("Can not find executor for elastic job type `%s`", elasticJobType);
+ }
+}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/TypedJobItemExecutor.java
similarity index 77%
copy from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java
copy to elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/TypedJobItemExecutor.java
index a4076b4..202cbef 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/TypedJobItemExecutor.java
@@ -15,22 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.job;
+package org.apache.shardingsphere.elasticjob.lite.executor.type;
import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
import org.apache.shardingsphere.elasticjob.lite.spi.TypedSPI;
-import java.util.Properties;
-
/**
- * Typed job.
+ * Typed job item executor.
*/
-public interface TypedJob extends ElasticJob, TypedSPI {
-
- /**
- * Initialize job.
- *
- * @param props job properties
- */
- void init(Properties props);
+public interface TypedJobItemExecutor extends JobItemExecutor<ElasticJob>, TypedSPI {
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutor.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutor.java
index 4050d31..d936e08 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutor.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutor.java
@@ -18,17 +18,17 @@
package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.DataflowJob;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.api.job.type.DataflowJob;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.ClassedJobItemExecutor;
import java.util.List;
/**
* Dataflow job executor.
*/
-public final class DataflowJobExecutor implements JobItemExecutor<DataflowJob> {
+public final class DataflowJobExecutor implements ClassedJobItemExecutor<DataflowJob> {
public static final String STREAM_PROCESS_KEY = "streaming.process";
@@ -72,4 +72,9 @@ public final class DataflowJobExecutor implements JobItemExecutor<DataflowJob> {
private void processData(final DataflowJob elasticJob, final ShardingContext shardingContext, final List<Object> data) {
elasticJob.processData(shardingContext, data);
}
+
+ @Override
+ public Class<DataflowJob> getElasticJobClass() {
+ return DataflowJob.class;
+ }
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/impl/ScriptJob.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutor.java
similarity index 74%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/impl/ScriptJob.java
rename to elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutor.java
index daa8d7e..49a6eae 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/impl/ScriptJob.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutor.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,33 +15,39 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.job.impl;
+package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
import com.google.common.base.Strings;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
+import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.SimpleJob;
+import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
-import org.apache.shardingsphere.elasticjob.lite.job.TypedJob;
+import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.TypedJobItemExecutor;
import org.apache.shardingsphere.elasticjob.lite.util.json.GsonFactory;
import java.io.IOException;
import java.util.Properties;
/**
- * Script job.
+ * Script job executor.
*/
-public final class ScriptJob implements SimpleJob, TypedJob {
+public final class ScriptJobExecutor implements TypedJobItemExecutor {
public static final String SCRIPT_KEY = "script.command.line";
- private volatile String scriptCommandLine;
-
@Override
- public void init(final Properties props) {
- scriptCommandLine = getScriptCommandLine(props);
+ public void process(final ElasticJob elasticJob, final JobConfiguration jobConfig, final JobFacade jobFacade, final ShardingContext shardingContext) {
+ CommandLine commandLine = CommandLine.parse(getScriptCommandLine(jobConfig.getProps()));
+ commandLine.addArgument(GsonFactory.getGson().toJson(shardingContext), false);
+ try {
+ new DefaultExecutor().execute(commandLine);
+ } catch (final IOException ex) {
+ throw new JobSystemException("Execute script failure.", ex);
+ }
}
private String getScriptCommandLine(final Properties props) {
@@ -53,17 +59,6 @@ public final class ScriptJob implements SimpleJob, TypedJob {
}
@Override
- public void execute(final ShardingContext shardingContext) {
- CommandLine commandLine = CommandLine.parse(scriptCommandLine);
- commandLine.addArgument(GsonFactory.getGson().toJson(shardingContext), false);
- try {
- new DefaultExecutor().execute(commandLine);
- } catch (final IOException ex) {
- throw new JobSystemException("Execute script failure.", ex);
- }
- }
-
- @Override
public String getType() {
return "SCRIPT";
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutor.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutor.java
index ce69275..3fbe2e0 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutor.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutor.java
@@ -18,18 +18,23 @@
package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.SimpleJob;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.api.job.type.SimpleJob;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.ClassedJobItemExecutor;
/**
* Simple job executor.
*/
-public final class SimpleJobExecutor implements JobItemExecutor<SimpleJob> {
+public final class SimpleJobExecutor implements ClassedJobItemExecutor<SimpleJob> {
@Override
public void process(final SimpleJob elasticJob, final JobConfiguration jobConfig, final JobFacade jobFacade, final ShardingContext shardingContext) {
elasticJob.execute(shardingContext);
}
+
+ @Override
+ public Class<SimpleJob> getElasticJobClass() {
+ return SimpleJob.class;
+ }
}
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 4ee6a82..4e11249 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
@@ -39,6 +39,8 @@ public final class LiteJob implements Job {
private ElasticJob elasticJob;
+ private String elasticJobType;
+
private JobConfiguration jobConfig;
private List<ElasticJobListener> elasticJobListeners;
@@ -47,6 +49,12 @@ public final class LiteJob implements Job {
@Override
public void execute(final JobExecutionContext context) {
- new ElasticJobExecutor(regCenter, elasticJob, jobConfig, elasticJobListeners, tracingConfig).execute();
+ createExecutor().execute();
+ }
+
+ private ElasticJobExecutor createExecutor() {
+ return null == elasticJob
+ ? new ElasticJobExecutor(regCenter, elasticJobType, jobConfig, elasticJobListeners, tracingConfig)
+ : new ElasticJobExecutor(regCenter, elasticJob, jobConfig, elasticJobListeners, tracingConfig);
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJobFactory.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJobFactory.java
deleted file mode 100644
index 3f57e42..0000000
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJobFactory.java
+++ /dev/null
@@ -1,60 +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.lite.job;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.ServiceLoader;
-
-/**
- * Typed job factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class TypedJobFactory {
-
- private static final Map<String, TypedJob> JOBS = new HashMap<>();
-
- static {
- for (TypedJob each : ServiceLoader.load(TypedJob.class)) {
- JOBS.put(each.getType(), each);
- }
- }
-
- /**
- * Create new job instance.
- *
- * @param type job type
- * @param props job properties
- * @return new job instance
- */
- @SneakyThrows
- public static TypedJob createJobInstance(final String type, final Properties props) {
- if (!JOBS.containsKey(type)) {
- throw new JobConfigurationException("Can not find job type `%s`.", type);
- }
- TypedJob result = JOBS.get(type).getClass().newInstance();
- result.init(props);
- return result;
- }
-}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/scheduler/JobScheduler.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/scheduler/JobScheduler.java
index 7b0af33..be2e1b9 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/scheduler/JobScheduler.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/scheduler/JobScheduler.java
@@ -19,9 +19,9 @@ package org.apache.shardingsphere.elasticjob.lite.scheduler;
import lombok.Getter;
import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
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.job.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
import org.apache.shardingsphere.elasticjob.lite.handler.sharding.JobInstance;
import org.apache.shardingsphere.elasticjob.lite.internal.guarantee.GuaranteeService;
@@ -31,7 +31,6 @@ import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobShutdownHo
import org.apache.shardingsphere.elasticjob.lite.internal.schedule.LiteJob;
import org.apache.shardingsphere.elasticjob.lite.internal.schedule.SchedulerFacade;
import org.apache.shardingsphere.elasticjob.lite.internal.setup.SetUpFacade;
-import org.apache.shardingsphere.elasticjob.lite.job.TypedJobFactory;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
import org.apache.shardingsphere.elasticjob.lite.tracing.api.TracingConfiguration;
import org.quartz.JobBuilder;
@@ -54,6 +53,8 @@ public final class JobScheduler {
private static final String ELASTIC_JOB_DATA_MAP_KEY = "elasticJob";
+ private static final String ELASTIC_JOB_TYPE_DATA_MAP_KEY = "elasticJobType";
+
private static final String JOB_CONFIG_DATA_MAP_KEY = "jobConfig";
private static final String JOB_LISTENERS_DATA_MAP_KEY = "elasticJobListeners";
@@ -64,6 +65,8 @@ public final class JobScheduler {
private final ElasticJob elasticJob;
+ private final String elasticJobType;
+
@Getter
private final JobConfiguration jobConfig;
@@ -86,6 +89,7 @@ public final class JobScheduler {
final ElasticJobListener... elasticJobListeners) {
this.regCenter = regCenter;
this.elasticJob = elasticJob;
+ elasticJobType = null;
this.elasticJobListeners = Arrays.asList(elasticJobListeners);
this.tracingConfig = tracingConfig;
setUpFacade = new SetUpFacade(regCenter, jobConfig.getJobName(), this.elasticJobListeners);
@@ -101,7 +105,16 @@ public final class JobScheduler {
public JobScheduler(final CoordinatorRegistryCenter regCenter, final String elasticJobType, final JobConfiguration jobConfig, final TracingConfiguration tracingConfig,
final ElasticJobListener... elasticJobListeners) {
- this(regCenter, TypedJobFactory.createJobInstance(elasticJobType, jobConfig.getProps()), jobConfig, tracingConfig, elasticJobListeners);
+ this.regCenter = regCenter;
+ elasticJob = null;
+ this.elasticJobType = elasticJobType;
+ this.elasticJobListeners = Arrays.asList(elasticJobListeners);
+ this.tracingConfig = tracingConfig;
+ setUpFacade = new SetUpFacade(regCenter, jobConfig.getJobName(), this.elasticJobListeners);
+ schedulerFacade = new SchedulerFacade(regCenter, jobConfig.getJobName());
+ this.jobConfig = setUpFacade.setUpJobConfiguration(elasticJobType, jobConfig);
+ setGuaranteeServiceForElasticJobListeners(regCenter, this.elasticJobListeners);
+ jobScheduleController = createJobScheduleController();
}
private void setGuaranteeServiceForElasticJobListeners(final CoordinatorRegistryCenter regCenter, final List<ElasticJobListener> elasticJobListeners) {
@@ -147,10 +160,11 @@ public final class JobScheduler {
private JobDetail createJobDetail() {
JobDetail result = JobBuilder.newJob(LiteJob.class).withIdentity(getJobConfig().getJobName()).build();
result.getJobDataMap().put(REG_CENTER_DATA_MAP_KEY, regCenter);
+ result.getJobDataMap().put(ELASTIC_JOB_DATA_MAP_KEY, elasticJob);
+ result.getJobDataMap().put(ELASTIC_JOB_TYPE_DATA_MAP_KEY, elasticJobType);
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);
- result.getJobDataMap().put(ELASTIC_JOB_DATA_MAP_KEY, elasticJob);
return result;
}
diff --git a/elastic-job-lite-core/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.job.TypedJob b/elastic-job-lite-core/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor
similarity index 76%
rename from elastic-job-lite-core/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.job.TypedJob
rename to elastic-job-lite-core/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor
index a23ab14..c1b6ca1 100644
--- a/elastic-job-lite-core/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.job.TypedJob
+++ b/elastic-job-lite-core/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor
@@ -15,4 +15,6 @@
# limitations under the License.
#
-org.apache.shardingsphere.elasticjob.lite.job.fixture.FooTypedJob
+org.apache.shardingsphere.elasticjob.lite.executor.type.impl.SimpleJobExecutor
+org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor
+org.apache.shardingsphere.elasticjob.lite.executor.type.impl.ScriptJobExecutor
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/JobItemExecutorFactoryTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/JobItemExecutorFactoryTest.java
new file mode 100644
index 0000000..c99029e
--- /dev/null
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/JobItemExecutorFactoryTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.lite.executor.type;
+
+import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor.ClassedFooJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor.TypedFooJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job.DetailedFooJob;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job.FailedJob;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job.FooJob;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+public final class JobItemExecutorFactoryTest {
+
+ @Test(expected = JobConfigurationException.class)
+ public void assertGetExecutorByClassFailureWithInvalidType() {
+ JobItemExecutorFactory.getExecutor(FailedJob.class);
+ }
+
+ @Test
+ public void assertGetExecutorByClassSuccessWithCurrentClass() {
+ assertThat(JobItemExecutorFactory.getExecutor(FooJob.class), instanceOf(ClassedFooJobExecutor.class));
+ }
+
+ @Test
+ public void assertGetExecutorByClassSuccessWithSubClass() {
+ assertThat(JobItemExecutorFactory.getExecutor(DetailedFooJob.class), instanceOf(ClassedFooJobExecutor.class));
+ }
+
+ @Test(expected = JobConfigurationException.class)
+ public void assertGetExecutorByTypeFailureWithInvalidType() {
+ JobItemExecutorFactory.getExecutor("FAIL");
+ }
+
+ @Test
+ public void assertGetExecutorByTypeSuccess() {
+ assertThat(JobItemExecutorFactory.getExecutor("FOO"), instanceOf(TypedFooJobExecutor.class));
+ }
+}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutor.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/ClassedFooJobExecutor.java
similarity index 67%
copy from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutor.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/ClassedFooJobExecutor.java
index ce69275..71d5111 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutor.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/ClassedFooJobExecutor.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,21 +15,22 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
+package org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor;
import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.SimpleJob;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.ClassedJobItemExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job.FooJob;
-/**
- * Simple job executor.
- */
-public final class SimpleJobExecutor implements JobItemExecutor<SimpleJob> {
+public final class ClassedFooJobExecutor implements ClassedJobItemExecutor<FooJob> {
+
+ @Override
+ public void process(final FooJob elasticJob, final JobConfiguration jobConfig, final JobFacade jobFacade, final ShardingContext shardingContext) {
+ }
@Override
- public void process(final SimpleJob elasticJob, final JobConfiguration jobConfig, final JobFacade jobFacade, final ShardingContext shardingContext) {
- elasticJob.execute(shardingContext);
+ public Class<FooJob> getElasticJobClass() {
+ return FooJob.class;
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/job/fixture/FooTypedJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/TypedFooJobExecutor.java
similarity index 61%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/job/fixture/FooTypedJob.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/TypedFooJobExecutor.java
index cd2f26d..9f32b1f 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/job/fixture/FooTypedJob.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/TypedFooJobExecutor.java
@@ -15,27 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.job.fixture;
+package org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor;
-import lombok.Getter;
+import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.SimpleJob;
-import org.apache.shardingsphere.elasticjob.lite.job.TypedJob;
+import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.TypedJobItemExecutor;
-import java.util.Properties;
-
-@Getter
-public final class FooTypedJob implements SimpleJob, TypedJob {
-
- private volatile String foo;
-
- @Override
- public void init(final Properties props) {
- foo = props.getProperty("foo");
- }
+public final class TypedFooJobExecutor implements TypedJobItemExecutor {
@Override
- public void execute(final ShardingContext shardingContext) {
+ public void process(final ElasticJob elasticJob, final JobConfiguration jobConfig, final JobFacade jobFacade, final ShardingContext shardingContext) {
}
@Override
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/DetailedFooJob.java
similarity index 65%
copy from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/DetailedFooJob.java
index a4076b4..fb7a7fd 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/DetailedFooJob.java
@@ -15,22 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.job;
+package org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job;
-import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.spi.TypedSPI;
-
-import java.util.Properties;
-
-/**
- * Typed job.
- */
-public interface TypedJob extends ElasticJob, TypedSPI {
-
- /**
- * Initialize job.
- *
- * @param props job properties
- */
- void init(Properties props);
+public final class DetailedFooJob implements FooJob {
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FailedJob.java
similarity index 71%
copy from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FailedJob.java
index a4076b4..84c3026 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FailedJob.java
@@ -15,22 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.job;
+package org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job;
import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.spi.TypedSPI;
-import java.util.Properties;
-
-/**
- * Typed job.
- */
-public interface TypedJob extends ElasticJob, TypedSPI {
-
- /**
- * Initialize job.
- *
- * @param props job properties
- */
- void init(Properties props);
+public final class FailedJob implements ElasticJob {
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FooJob.java
similarity index 71%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FooJob.java
index a4076b4..cb00238 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJob.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FooJob.java
@@ -15,22 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.job;
+package org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job;
import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.spi.TypedSPI;
-import java.util.Properties;
-
-/**
- * Typed job.
- */
-public interface TypedJob extends ElasticJob, TypedSPI {
-
- /**
- * Initialize job.
- *
- * @param props job properties
- */
- void init(Properties props);
+public interface FooJob extends ElasticJob {
}
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
new file mode 100644
index 0000000..e954819
--- /dev/null
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.lite.executor.type.impl;
+
+import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
+import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
+import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
+import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
+import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
+import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.util.Collections;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class ScriptJobExecutorTest {
+
+ @Mock
+ private CoordinatorRegistryCenter regCenter;
+
+ @Mock
+ private JobFacade jobFacade;
+
+ private ElasticJobExecutor elasticJobExecutor;
+
+ @Test
+ public void assertExecuteWhenCommandLineIsEmpty() {
+ ElasticJobVerify.prepareForIsNotMisfire(jobFacade, ShardingContextsBuilder.getMultipleShardingContexts());
+ elasticJobExecutor = new ElasticJobExecutor(regCenter, "SCRIPT", createJobConfiguration("", "IGNORE"), Collections.emptyList(), null);
+ ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
+ elasticJobExecutor.execute();
+ }
+
+ @Test(expected = JobSystemException.class)
+ public void assertExecuteWhenExecuteFailureForSingleShardingItems() {
+ assertExecuteWhenExecuteFailure(ShardingContextsBuilder.getSingleShardingContexts());
+ }
+
+ @Test
+ public void assertExecuteWhenExecuteFailureForMultipleShardingItems() {
+ assertExecuteWhenExecuteFailure(ShardingContextsBuilder.getMultipleShardingContexts());
+ }
+
+ private void assertExecuteWhenExecuteFailure(final ShardingContexts shardingContexts) {
+ ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
+ elasticJobExecutor = new ElasticJobExecutor(regCenter, "SCRIPT", createJobConfiguration("not_exists_file", "THROW"), Collections.emptyList(), null);
+ ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
+ elasticJobExecutor.execute();
+ }
+
+ @Test
+ public void assertExecuteSuccessForMultipleShardingItems() {
+ assertExecuteSuccess(ShardingContextsBuilder.getMultipleShardingContexts());
+ }
+
+ @Test
+ public void assertExecuteSuccessForSingleShardingItems() {
+ assertExecuteSuccess(ShardingContextsBuilder.getSingleShardingContexts());
+ }
+
+ private void assertExecuteSuccess(final ShardingContexts shardingContexts) {
+ ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
+ elasticJobExecutor = new ElasticJobExecutor(regCenter, "SCRIPT", createJobConfiguration("exists_file param0 param1", "IGNORE"), Collections.emptyList(), null);
+ ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
+ elasticJobExecutor.execute();
+ }
+
+ private JobConfiguration createJobConfiguration(final String scriptCommandLine, final String jobErrorHandlerType) {
+ return JobConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, 3)
+ .cron("0/1 * * * * ?").jobErrorHandlerType(jobErrorHandlerType).setProperty(ScriptJobExecutor.SCRIPT_KEY, scriptCommandLine).build();
+ }
+}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java
index 52fe1ab..8b71673 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java
@@ -71,6 +71,12 @@ public abstract class BaseIntegrateTest {
leaderService = new LeaderService(regCenter, jobName);
}
+ protected BaseIntegrateTest(final TestType type, final String elasticJobType) {
+ jobConfiguration = getJobConfiguration(jobName);
+ jobBootstrap = createJobBootstrap(type, elasticJobType);
+ leaderService = new LeaderService(regCenter, jobName);
+ }
+
protected abstract JobConfiguration getJobConfiguration(String jobName);
private JobBootstrap createJobBootstrap(final TestType type, final ElasticJob elasticJob) {
@@ -84,6 +90,17 @@ public abstract class BaseIntegrateTest {
}
}
+ private JobBootstrap createJobBootstrap(final TestType type, final String elasticJobType) {
+ switch (type) {
+ case SCHEDULE:
+ return new ScheduleJobBootstrap(regCenter, elasticJobType, jobConfiguration, new TestElasticJobListener(), new TestDistributeOnceElasticJobListener());
+ case ONE_OFF:
+ return new OneOffJobBootstrap(regCenter, elasticJobType, jobConfiguration, new TestElasticJobListener(), new TestDistributeOnceElasticJobListener());
+ default:
+ throw new RuntimeException(String.format("Cannot support `%s`", type));
+ }
+ }
+
@BeforeClass
public static void init() {
EmbedTestingServer.start();
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/EnabledJobIntegrateTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/EnabledJobIntegrateTest.java
index cab0ce0..28e99c6 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/EnabledJobIntegrateTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/EnabledJobIntegrateTest.java
@@ -26,6 +26,10 @@ public abstract class EnabledJobIntegrateTest extends BaseIntegrateTest {
super(type, elasticJob);
}
+ protected EnabledJobIntegrateTest(final TestType type, final String elasticJobType) {
+ super(type, elasticJobType);
+ }
+
@Before
public final void autoSchedule() {
assertRegCenterCommonInfoWithEnabled();
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/script/ScriptElasticJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/script/ScriptElasticJobTest.java
index 8830373..3e910f3 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/script/ScriptElasticJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/script/ScriptElasticJobTest.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.oneoff.script;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.ScriptJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.internal.config.yaml.YamlJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.job.impl.ScriptJob;
import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.apache.shardingsphere.elasticjob.lite.util.yaml.YamlEngine;
import org.junit.Test;
@@ -31,19 +31,19 @@ import static org.junit.Assert.assertThat;
public final class ScriptElasticJobTest extends EnabledJobIntegrateTest {
public ScriptElasticJobTest() {
- super(TestType.ONE_OFF, new ScriptJob());
+ super(TestType.ONE_OFF, "SCRIPT");
}
@Override
protected JobConfiguration getJobConfiguration(final String jobName) {
- return JobConfiguration.newBuilder(jobName, 3).shardingItemParameters("0=A,1=B,2=C").overwrite(true).setProperty(ScriptJob.SCRIPT_KEY, "echo").build();
+ return JobConfiguration.newBuilder(jobName, 3).shardingItemParameters("0=A,1=B,2=C").overwrite(true).setProperty(ScriptJobExecutor.SCRIPT_KEY, "echo").build();
}
@Test
public void assertJobInit() {
BlockUtils.waitingShortTime();
- String scriptCommandLine = getJobConfiguration().getProps().getProperty(ScriptJob.SCRIPT_KEY);
+ String scriptCommandLine = getJobConfiguration().getProps().getProperty(ScriptJobExecutor.SCRIPT_KEY);
JobConfiguration jobConfig = YamlEngine.unmarshal(getRegCenter().get("/" + getJobName() + "/config"), YamlJobConfiguration.class).toJobConfiguration();
- assertThat(jobConfig.getProps().getProperty(ScriptJob.SCRIPT_KEY), is(scriptCommandLine));
+ assertThat(jobConfig.getProps().getProperty(ScriptJobExecutor.SCRIPT_KEY), is(scriptCommandLine));
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/script/ScriptElasticJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/script/ScriptElasticJobTest.java
index 300798d..f5d8084 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/script/ScriptElasticJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/script/ScriptElasticJobTest.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.schedule.script;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.ScriptJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.internal.config.yaml.YamlJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.job.impl.ScriptJob;
import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.apache.shardingsphere.elasticjob.lite.util.yaml.YamlEngine;
import org.junit.Test;
@@ -31,19 +31,19 @@ import static org.junit.Assert.assertThat;
public final class ScriptElasticJobTest extends EnabledJobIntegrateTest {
public ScriptElasticJobTest() {
- super(TestType.SCHEDULE, new ScriptJob());
+ super(TestType.SCHEDULE, "SCRIPT");
}
@Override
protected JobConfiguration getJobConfiguration(final String jobName) {
- return JobConfiguration.newBuilder(jobName, 3).cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").overwrite(true).setProperty(ScriptJob.SCRIPT_KEY, "echo").build();
+ return JobConfiguration.newBuilder(jobName, 3).cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").overwrite(true).setProperty(ScriptJobExecutor.SCRIPT_KEY, "echo").build();
}
@Test
public void assertJobInit() {
BlockUtils.waitingShortTime();
- String scriptCommandLine = getJobConfiguration().getProps().getProperty(ScriptJob.SCRIPT_KEY);
+ String scriptCommandLine = getJobConfiguration().getProps().getProperty(ScriptJobExecutor.SCRIPT_KEY);
JobConfiguration jobConfig = YamlEngine.unmarshal(getRegCenter().get("/" + getJobName() + "/config"), YamlJobConfiguration.class).toJobConfiguration();
- assertThat(jobConfig.getProps().getProperty(ScriptJob.SCRIPT_KEY), is(scriptCommandLine));
+ assertThat(jobConfig.getProps().getProperty(ScriptJobExecutor.SCRIPT_KEY), is(scriptCommandLine));
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJobFactoryTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJobFactoryTest.java
deleted file mode 100644
index 55442b6..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/job/TypedJobFactoryTest.java
+++ /dev/null
@@ -1,43 +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.lite.job;
-
-import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
-import org.apache.shardingsphere.elasticjob.lite.job.fixture.FooTypedJob;
-import org.junit.Test;
-
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class TypedJobFactoryTest {
-
- @Test(expected = JobConfigurationException.class)
- public void assertCreateJobInstanceFailureWhenJobTypeNotExisted() {
- TypedJobFactory.createJobInstance("INVALID", new Properties());
- }
-
- @Test
- public void assertCreateJobInstanceSuccess() {
- Properties props = new Properties();
- props.setProperty("foo", "foo");
- FooTypedJob actual = (FooTypedJob) TypedJobFactory.createJobInstance("FOO", props);
- assertThat(actual.getFoo(), is("foo"));
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/job/impl/ScriptJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/job/impl/ScriptJobTest.java
deleted file mode 100644
index e4c9126..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/job/impl/ScriptJobTest.java
+++ /dev/null
@@ -1,55 +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.lite.job.impl;
-
-import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
-import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
-import org.junit.Test;
-
-import java.util.Properties;
-
-import static org.mockito.Mockito.mock;
-
-public final class ScriptJobTest {
-
- @Test(expected = JobConfigurationException.class)
- public void assertExecuteWhenCommandLineIsEmpty() {
- ScriptJob scriptJob = new ScriptJob();
- scriptJob.init(new Properties());
- scriptJob.execute(mock(ShardingContext.class));
- }
-
- @Test(expected = JobSystemException.class)
- public void assertExecuteWhenExecuteFailure() {
- ScriptJob scriptJob = new ScriptJob();
- Properties props = new Properties();
- props.setProperty(ScriptJob.SCRIPT_KEY, "not_exists_file");
- scriptJob.init(props);
- scriptJob.execute(mock(ShardingContext.class));
- }
-
- @Test
- public void assertExecuteWhenExecuteSuccess() {
- ScriptJob scriptJob = new ScriptJob();
- Properties props = new Properties();
- props.setProperty(ScriptJob.SCRIPT_KEY, "echo");
- scriptJob.init(props);
- scriptJob.execute(mock(ShardingContext.class));
- }
-}
diff --git a/elastic-job-lite-core/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.job.TypedJob b/elastic-job-lite-core/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor
similarity index 80%
rename from elastic-job-lite-core/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.job.TypedJob
rename to elastic-job-lite-core/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor
index b53cf36..611350f 100644
--- a/elastic-job-lite-core/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.job.TypedJob
+++ b/elastic-job-lite-core/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor
@@ -15,4 +15,5 @@
# limitations under the License.
#
-org.apache.shardingsphere.elasticjob.lite.job.impl.ScriptJob
+org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor.ClassedFooJobExecutor
+org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor.TypedFooJobExecutor
diff --git a/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/domain/JobSettings.java b/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/domain/JobSettings.java
index 352435a..93813d0 100644
--- a/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/domain/JobSettings.java
+++ b/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/domain/JobSettings.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.elasticjob.lite.lifecycle.domain;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.ScriptJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.internal.config.yaml.YamlJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.job.impl.ScriptJob;
import java.io.Serializable;
@@ -89,7 +89,7 @@ public final class JobSettings implements Serializable {
result.setDescription(description);
result.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.valueOf(streamingProcess).toString());
if (null != scriptCommandLine) {
- result.getProps().setProperty(ScriptJob.SCRIPT_KEY, scriptCommandLine);
+ result.getProps().setProperty(ScriptJobExecutor.SCRIPT_KEY, scriptCommandLine);
}
return result;
}
diff --git a/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobSettingsAPIImpl.java b/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobSettingsAPIImpl.java
index db928cf..c277979 100644
--- a/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobSettingsAPIImpl.java
+++ b/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobSettingsAPIImpl.java
@@ -22,9 +22,9 @@ import com.google.common.base.Strings;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.ScriptJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.internal.config.yaml.YamlJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodePath;
-import org.apache.shardingsphere.elasticjob.lite.job.impl.ScriptJob;
import org.apache.shardingsphere.elasticjob.lite.lifecycle.api.JobSettingsAPI;
import org.apache.shardingsphere.elasticjob.lite.lifecycle.domain.JobSettings;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
@@ -47,8 +47,8 @@ public final class JobSettingsAPIImpl implements JobSettingsAPI {
if (jobConfig.getProps().containsKey(DataflowJobExecutor.STREAM_PROCESS_KEY)) {
result.setStreamingProcess(Boolean.parseBoolean(jobConfig.getProps().get(DataflowJobExecutor.STREAM_PROCESS_KEY).toString()));
}
- if (jobConfig.getProps().containsKey(ScriptJob.SCRIPT_KEY)) {
- result.setScriptCommandLine(jobConfig.getProps().getProperty(ScriptJob.SCRIPT_KEY));
+ if (jobConfig.getProps().containsKey(ScriptJobExecutor.SCRIPT_KEY)) {
+ result.setScriptCommandLine(jobConfig.getProps().getProperty(ScriptJobExecutor.SCRIPT_KEY));
}
return result;
}
diff --git a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/script/ScriptJobBeanDefinitionParser.java b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/script/ScriptJobBeanDefinitionParser.java
index 74b88cc..19b1b2c 100644
--- a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/script/ScriptJobBeanDefinitionParser.java
+++ b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/script/ScriptJobBeanDefinitionParser.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.elasticjob.lite.spring.job.parser.script;
-import org.apache.shardingsphere.elasticjob.lite.job.impl.ScriptJob;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.ScriptJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.spring.job.parser.common.AbstractJobBeanDefinitionParser;
import org.w3c.dom.Element;
@@ -31,7 +31,7 @@ public final class ScriptJobBeanDefinitionParser extends AbstractJobBeanDefiniti
@Override
protected Properties getProps(final Element element) {
Properties result = new Properties();
- result.setProperty(ScriptJob.SCRIPT_KEY, element.getAttribute(ScriptJobBeanDefinitionParserTag.SCRIPT_COMMAND_LINE_ATTRIBUTE));
+ result.setProperty(ScriptJobExecutor.SCRIPT_KEY, element.getAttribute(ScriptJobBeanDefinitionParserTag.SCRIPT_COMMAND_LINE_ATTRIBUTE));
return result;
}
}
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 a8a97a7..c89dad3 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
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration
import org.apache.shardingsphere.elasticjob.lite.example.job.dataflow.JavaDataflowJob;
import org.apache.shardingsphere.elasticjob.lite.example.job.simple.JavaSimpleJob;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.job.impl.ScriptJob;
+import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.ScriptJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
import org.apache.shardingsphere.elasticjob.lite.reg.zookeeper.ZookeeperConfiguration;
import org.apache.shardingsphere.elasticjob.lite.reg.zookeeper.ZookeeperRegistryCenter;
@@ -96,7 +96,7 @@ public final class JavaMain {
private static void setUpScriptJob(final CoordinatorRegistryCenter regCenter, final TracingConfiguration tracingConfig) throws IOException {
new ScheduleJobBootstrap(regCenter, "SCRIPT", JobConfiguration.newBuilder("scriptElasticJob", 3)
- .cron("0/5 * * * * ?").setProperty(ScriptJob.SCRIPT_KEY, buildScriptCommandLine()).build(), tracingConfig).schedule();
+ .cron("0/5 * * * * ?").setProperty(ScriptJobExecutor.SCRIPT_KEY, buildScriptCommandLine()).build(), tracingConfig).schedule();
}
private static String buildScriptCommandLine() throws IOException {