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/06/19 16:27:41 UTC
[shardingsphere-elasticjob-lite] branch master updated: Refactor
miscellaneous (#793)
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 ed0d714 Refactor miscellaneous (#793)
ed0d714 is described below
commit ed0d7141706eca014c0ce827663fdcc9d826c014
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat Jun 20 00:27:29 2020 +0800
Refactor miscellaneous (#793)
* refactor JobScheduler
* remove useless codes
* rename AbstractElasticJobExecutor to ElasticJobExecutor
* refactor ElasticJobExecutor
* refactor LiteJob
* rename ElasticJobExecutorService
* checkstyle for xml
---
.../elasticjob/lite/api/JobScheduler.java | 55 +++++++++++-----------
.../elasticjob/lite/api/strategy/JobInstance.java | 3 --
.../elasticjob/lite/event/JobEventBus.java | 12 ++---
...ticJobExecutor.java => ElasticJobExecutor.java} | 25 +++++-----
.../lite/executor/JobExecutorFactory.java | 2 +-
.../impl/DefaultExecutorServiceHandler.java | 4 +-
.../lite/executor/type/DataflowJobExecutor.java | 4 +-
.../lite/executor/type/ScriptJobExecutor.java | 4 +-
.../lite/executor/type/SimpleJobExecutor.java | 4 +-
.../elasticjob/lite/internal/schedule/LiteJob.java | 3 +-
...eObject.java => ElasticJobExecutorService.java} | 6 +--
.../elasticjob/lite/util/digest/Encryption.java | 51 --------------------
.../lite/executor/JobExecutorFactoryTest.java | 4 +-
.../lite/executor/type/SimpleJobExecutorTest.java | 6 +--
...est.java => ElasticJobExecutorServiceTest.java} | 4 +-
.../lite/util/digest/EncryptionTest.java | 31 ------------
.../src/test/resources/META-INF/job/base.xml | 8 ++--
.../src/test/resources/META-INF/job/withJobRef.xml | 4 +-
18 files changed, 73 insertions(+), 157 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/JobScheduler.java
index b2ea86d..577cb13 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/JobScheduler.java
@@ -41,6 +41,7 @@ import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
+import org.quartz.simpl.SimpleThreadPool;
import java.util.Arrays;
import java.util.List;
@@ -107,11 +108,28 @@ public class JobScheduler {
jobScheduleController.scheduleJob(liteJobConfigFromRegCenter.getTypeConfig().getCoreConfig().getCron());
}
- /**
- * Shutdown job.
- */
- public void shutdown() {
- schedulerFacade.shutdownInstance();
+ private Scheduler createScheduler() {
+ Scheduler result;
+ try {
+ StdSchedulerFactory factory = new StdSchedulerFactory();
+ factory.initialize(getQuartzProps());
+ result = factory.getScheduler();
+ result.getListenerManager().addTriggerListener(schedulerFacade.newJobTriggerListener());
+ } catch (final SchedulerException ex) {
+ throw new JobSystemException(ex);
+ }
+ return result;
+ }
+
+ private Properties getQuartzProps() {
+ 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", liteJobConfig.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());
+ return result;
}
private JobDetail createJobDetail(final String jobClass) {
@@ -134,27 +152,10 @@ public class JobScheduler {
return Optional.empty();
}
- private Scheduler createScheduler() {
- Scheduler result;
- try {
- StdSchedulerFactory factory = new StdSchedulerFactory();
- factory.initialize(getBaseQuartzProperties());
- result = factory.getScheduler();
- result.getListenerManager().addTriggerListener(schedulerFacade.newJobTriggerListener());
- } catch (final SchedulerException ex) {
- throw new JobSystemException(ex);
- }
- return result;
- }
-
- private Properties getBaseQuartzProperties() {
- Properties result = new Properties();
- result.put("org.quartz.threadPool.class", org.quartz.simpl.SimpleThreadPool.class.getName());
- result.put("org.quartz.threadPool.threadCount", "1");
- result.put("org.quartz.scheduler.instanceName", liteJobConfig.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());
- return result;
+ /**
+ * Shutdown job.
+ */
+ public void shutdown() {
+ schedulerFacade.shutdownInstance();
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/strategy/JobInstance.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/strategy/JobInstance.java
index 53a9efb..5dbee4f 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/strategy/JobInstance.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/strategy/JobInstance.java
@@ -34,9 +34,6 @@ public final class JobInstance {
private static final String DELIMITER = "@-@";
- /**
- * Job instance ID.
- */
private final String jobInstanceId;
public JobInstance() {
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventBus.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventBus.java
index 2ada23c..2bc0c60 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventBus.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventBus.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.elasticjob.lite.event;
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.elasticjob.lite.util.concurrent.ExecutorServiceObject;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.ElasticJobExecutorService;
/**
* Job event bus.
@@ -30,7 +30,7 @@ public final class JobEventBus {
private final JobEventConfiguration jobEventConfig;
- private final ExecutorServiceObject executorServiceObject;
+ private final ElasticJobExecutorService elasticJobExecutorService;
private final EventBus eventBus;
@@ -38,14 +38,14 @@ public final class JobEventBus {
public JobEventBus() {
jobEventConfig = null;
- executorServiceObject = null;
+ elasticJobExecutorService = null;
eventBus = null;
}
public JobEventBus(final JobEventConfiguration jobEventConfig) {
this.jobEventConfig = jobEventConfig;
- executorServiceObject = new ExecutorServiceObject("job-event", Runtime.getRuntime().availableProcessors() * 2);
- eventBus = new AsyncEventBus(executorServiceObject.createExecutorService());
+ elasticJobExecutorService = new ElasticJobExecutorService("job-event", Runtime.getRuntime().availableProcessors() * 2);
+ eventBus = new AsyncEventBus(elasticJobExecutorService.createExecutorService());
register();
}
@@ -64,7 +64,7 @@ public final class JobEventBus {
* @param event job event
*/
public void post(final JobEvent event) {
- if (isRegistered && !executorServiceObject.isShutdown()) {
+ if (isRegistered && !elasticJobExecutorService.isShutdown()) {
eventBus.post(event);
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/AbstractElasticJobExecutor.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutor.java
similarity index 91%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/AbstractElasticJobExecutor.java
rename to elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutor.java
index 18ac648..a2f23b5 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/AbstractElasticJobExecutor.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutor.java
@@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.elasticjob.lite.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.lite.config.JobRootConfiguration;
import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent.ExecutionSource;
import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
import org.apache.shardingsphere.elasticjob.lite.exception.ExceptionUtil;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
@@ -30,7 +31,7 @@ import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
import org.apache.shardingsphere.elasticjob.lite.executor.handler.ExecutorServiceHandler;
import org.apache.shardingsphere.elasticjob.lite.executor.handler.ExecutorServiceHandlerRegistry;
import org.apache.shardingsphere.elasticjob.lite.executor.handler.JobExceptionHandler;
-import org.apache.shardingsphere.elasticjob.lite.executor.handler.JobProperties;
+import org.apache.shardingsphere.elasticjob.lite.executor.handler.JobProperties.JobPropertiesEnum;
import java.util.Collection;
import java.util.Map;
@@ -42,7 +43,7 @@ import java.util.concurrent.ExecutorService;
* ElasticJob executor.
*/
@Slf4j
-public abstract class AbstractElasticJobExecutor {
+public abstract class ElasticJobExecutor {
@Getter(AccessLevel.PROTECTED)
private final JobFacade jobFacade;
@@ -58,16 +59,16 @@ public abstract class AbstractElasticJobExecutor {
private final Map<Integer, String> itemErrorMessages;
- protected AbstractElasticJobExecutor(final JobFacade jobFacade) {
+ protected ElasticJobExecutor(final JobFacade jobFacade) {
this.jobFacade = jobFacade;
jobRootConfig = jobFacade.loadJobRootConfiguration(true);
jobName = jobRootConfig.getTypeConfig().getCoreConfig().getJobName();
- executorService = ExecutorServiceHandlerRegistry.getExecutorServiceHandler(jobName, (ExecutorServiceHandler) getHandler(JobProperties.JobPropertiesEnum.EXECUTOR_SERVICE_HANDLER));
- jobExceptionHandler = (JobExceptionHandler) getHandler(JobProperties.JobPropertiesEnum.JOB_EXCEPTION_HANDLER);
+ executorService = ExecutorServiceHandlerRegistry.getExecutorServiceHandler(jobName, (ExecutorServiceHandler) getHandler(JobPropertiesEnum.EXECUTOR_SERVICE_HANDLER));
+ jobExceptionHandler = (JobExceptionHandler) getHandler(JobPropertiesEnum.JOB_EXCEPTION_HANDLER);
itemErrorMessages = new ConcurrentHashMap<>(jobRootConfig.getTypeConfig().getCoreConfig().getShardingTotalCount(), 1);
}
- private Object getHandler(final JobProperties.JobPropertiesEnum jobPropertiesEnum) {
+ private Object getHandler(final JobPropertiesEnum jobPropertiesEnum) {
String handlerClassName = jobRootConfig.getTypeConfig().getCoreConfig().getJobProperties().get(jobPropertiesEnum);
try {
Class<?> handlerClass = Class.forName(handlerClassName);
@@ -80,7 +81,7 @@ public abstract class AbstractElasticJobExecutor {
}
}
- private Object getDefaultHandler(final JobProperties.JobPropertiesEnum jobPropertiesEnum, final String handlerClassName) {
+ private Object getDefaultHandler(final JobPropertiesEnum jobPropertiesEnum, final String handlerClassName) {
log.warn("Cannot instantiation class '{}', use default '{}' class.", handlerClassName, jobPropertiesEnum.getKey());
try {
return Class.forName(jobPropertiesEnum.getDefaultValue()).newInstance();
@@ -117,10 +118,10 @@ public abstract class AbstractElasticJobExecutor {
//CHECKSTYLE:ON
jobExceptionHandler.handleException(jobName, cause);
}
- execute(shardingContexts, JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER);
+ execute(shardingContexts, ExecutionSource.NORMAL_TRIGGER);
while (jobFacade.isExecuteMisfired(shardingContexts.getShardingItemParameters().keySet())) {
jobFacade.clearMisfire(shardingContexts.getShardingItemParameters().keySet());
- execute(shardingContexts, JobExecutionEvent.ExecutionSource.MISFIRE);
+ execute(shardingContexts, ExecutionSource.MISFIRE);
}
jobFacade.failoverIfNecessary();
try {
@@ -132,7 +133,7 @@ public abstract class AbstractElasticJobExecutor {
}
}
- private void execute(final ShardingContexts shardingContexts, final JobExecutionEvent.ExecutionSource executionSource) {
+ private void execute(final ShardingContexts shardingContexts, final ExecutionSource executionSource) {
if (shardingContexts.getShardingItemParameters().isEmpty()) {
if (shardingContexts.isAllowSendJobEvent()) {
jobFacade.postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_FINISHED, String.format("Sharding item for job '%s' is empty.", jobName));
@@ -161,7 +162,7 @@ public abstract class AbstractElasticJobExecutor {
}
}
- private void process(final ShardingContexts shardingContexts, final JobExecutionEvent.ExecutionSource executionSource) {
+ private void process(final ShardingContexts shardingContexts, final ExecutionSource executionSource) {
Collection<Integer> items = shardingContexts.getShardingItemParameters().keySet();
if (1 == items.size()) {
int item = shardingContexts.getShardingItemParameters().keySet().iterator().next();
@@ -171,7 +172,7 @@ public abstract class AbstractElasticJobExecutor {
}
final CountDownLatch latch = new CountDownLatch(items.size());
for (final int each : items) {
- final JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(shardingContexts.getTaskId(), jobName, executionSource, each);
+ JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(shardingContexts.getTaskId(), jobName, executionSource, each);
if (executorService.isShutdown()) {
return;
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/JobExecutorFactory.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/JobExecutorFactory.java
index e454ded..9f9a16e 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/JobExecutorFactory.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/JobExecutorFactory.java
@@ -41,7 +41,7 @@ public final class JobExecutorFactory {
* @return job executor
*/
@SuppressWarnings("unchecked")
- public static AbstractElasticJobExecutor getJobExecutor(final ElasticJob elasticJob, final JobFacade jobFacade) {
+ public static ElasticJobExecutor getJobExecutor(final ElasticJob elasticJob, final JobFacade jobFacade) {
if (null == elasticJob) {
return new ScriptJobExecutor(jobFacade);
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/handler/impl/DefaultExecutorServiceHandler.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/handler/impl/DefaultExecutorServiceHandler.java
index 56ab265..4bd8eb7 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/handler/impl/DefaultExecutorServiceHandler.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/handler/impl/DefaultExecutorServiceHandler.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.elasticjob.lite.executor.handler.impl;
import org.apache.shardingsphere.elasticjob.lite.executor.handler.ExecutorServiceHandler;
-import org.apache.shardingsphere.elasticjob.lite.util.concurrent.ExecutorServiceObject;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.ElasticJobExecutorService;
import java.util.concurrent.ExecutorService;
@@ -29,6 +29,6 @@ public final class DefaultExecutorServiceHandler implements ExecutorServiceHandl
@Override
public ExecutorService createExecutorService(final String jobName) {
- return new ExecutorServiceObject("inner-job-" + jobName, Runtime.getRuntime().availableProcessors() * 2).createExecutorService();
+ return new ElasticJobExecutorService("inner-job-" + jobName, Runtime.getRuntime().availableProcessors() * 2).createExecutorService();
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/DataflowJobExecutor.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/DataflowJobExecutor.java
index 1126b34..7fa27d1 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/DataflowJobExecutor.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/DataflowJobExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.elasticjob.lite.executor.type;
import org.apache.shardingsphere.elasticjob.lite.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.lite.api.dataflow.DataflowJob;
import org.apache.shardingsphere.elasticjob.lite.config.dataflow.DataflowJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.executor.AbstractElasticJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import java.util.List;
@@ -28,7 +28,7 @@ import java.util.List;
/**
* Dataflow job executor.
*/
-public final class DataflowJobExecutor extends AbstractElasticJobExecutor {
+public final class DataflowJobExecutor extends ElasticJobExecutor {
private final DataflowJob<Object> dataflowJob;
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/ScriptJobExecutor.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/ScriptJobExecutor.java
index 76644ea..0cb5f01 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/ScriptJobExecutor.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/ScriptJobExecutor.java
@@ -23,7 +23,7 @@ import org.apache.commons.exec.DefaultExecutor;
import org.apache.shardingsphere.elasticjob.lite.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.lite.config.script.ScriptJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
-import org.apache.shardingsphere.elasticjob.lite.executor.AbstractElasticJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import org.apache.shardingsphere.elasticjob.lite.util.json.GsonFactory;
@@ -32,7 +32,7 @@ import java.io.IOException;
/**
* Script job executor.
*/
-public final class ScriptJobExecutor extends AbstractElasticJobExecutor {
+public final class ScriptJobExecutor extends ElasticJobExecutor {
public ScriptJobExecutor(final JobFacade jobFacade) {
super(jobFacade);
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/SimpleJobExecutor.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/SimpleJobExecutor.java
index b7ca6c6..dc4f815 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/SimpleJobExecutor.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/type/SimpleJobExecutor.java
@@ -19,13 +19,13 @@ package org.apache.shardingsphere.elasticjob.lite.executor.type;
import org.apache.shardingsphere.elasticjob.lite.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.lite.api.simple.SimpleJob;
-import org.apache.shardingsphere.elasticjob.lite.executor.AbstractElasticJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
/**
* Simple job executor.
*/
-public final class SimpleJobExecutor extends AbstractElasticJobExecutor {
+public final class SimpleJobExecutor extends ElasticJobExecutor {
private final SimpleJob simpleJob;
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 08eb6d0..63c2277 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
@@ -27,12 +27,11 @@ import org.quartz.JobExecutionContext;
/**
* Lite job class.
*/
+@Setter
public final class LiteJob implements Job {
- @Setter
private ElasticJob elasticJob;
- @Setter
private JobFacade jobFacade;
@Override
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ExecutorServiceObject.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ElasticJobExecutorService.java
similarity index 93%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ExecutorServiceObject.java
rename to elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ElasticJobExecutorService.java
index d5bf3d5..228aeea 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ExecutorServiceObject.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ElasticJobExecutorService.java
@@ -28,15 +28,15 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
- * Executor service object.
+ * ElasticJob executor service.
*/
-public final class ExecutorServiceObject {
+public final class ElasticJobExecutorService {
private final ThreadPoolExecutor threadPoolExecutor;
private final BlockingQueue<Runnable> workQueue;
- public ExecutorServiceObject(final String namingPattern, final int threadSize) {
+ public ElasticJobExecutorService(final String namingPattern, final int threadSize) {
workQueue = new LinkedBlockingQueue<>();
threadPoolExecutor = new ThreadPoolExecutor(threadSize, threadSize, 5L, TimeUnit.MINUTES, workQueue,
new BasicThreadFactory.Builder().namingPattern(Joiner.on("-").join(namingPattern, "%s")).build());
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/digest/Encryption.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/digest/Encryption.java
deleted file mode 100644
index 0558a87..0000000
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/digest/Encryption.java
+++ /dev/null
@@ -1,51 +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.util.digest;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
-
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-/**
- * Encryption.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class Encryption {
-
- private static final String MD5 = "MD5";
-
- /**
- * Use md5 to encrypt string.
- *
- * @param str string to be encrypted
- * @return encrypted string
- */
- public static String md5(final String str) {
- try {
- MessageDigest messageDigest = MessageDigest.getInstance(MD5);
- messageDigest.update(str.getBytes());
- return new BigInteger(1, messageDigest.digest()).toString(16);
- } catch (final NoSuchAlgorithmException ex) {
- throw new JobSystemException(ex);
- }
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/JobExecutorFactoryTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/JobExecutorFactoryTest.java
index c4409d5..ca4c311 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/JobExecutorFactoryTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/JobExecutorFactoryTest.java
@@ -70,8 +70,8 @@ public final class JobExecutorFactoryTest {
@Test
public void assertGetJobExecutorTwice() {
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestDataflowJobConfiguration(false));
- AbstractElasticJobExecutor executor = JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade);
- AbstractElasticJobExecutor anotherExecutor = JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade);
+ ElasticJobExecutor executor = JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade);
+ ElasticJobExecutor anotherExecutor = JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade);
assertTrue(executor.hashCode() != anotherExecutor.hashCode());
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/SimpleJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/SimpleJobExecutorTest.java
index 3589971..be0816a 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/SimpleJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/SimpleJobExecutorTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.elasticjob.lite.executor.type;
import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
-import org.apache.shardingsphere.elasticjob.lite.executor.AbstractElasticJobExecutor;
+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.executor.handler.impl.DefaultExecutorServiceHandler;
@@ -66,9 +66,9 @@ public final class SimpleJobExecutorTest {
public void assertNewExecutorWithDefaultHandlers() throws NoSuchFieldException {
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration("ErrorHandler", Object.class.getName()));
SimpleJobExecutor simpleJobExecutor = new SimpleJobExecutor(new TestSimpleJob(jobCaller), jobFacade);
- assertThat(ReflectionUtils.getFieldValue(simpleJobExecutor, AbstractElasticJobExecutor.class.getDeclaredField("executorService")),
+ assertThat(ReflectionUtils.getFieldValue(simpleJobExecutor, ElasticJobExecutor.class.getDeclaredField("executorService")),
instanceOf(new DefaultExecutorServiceHandler().createExecutorService("test_job").getClass()));
- assertThat(ReflectionUtils.getFieldValue(simpleJobExecutor, AbstractElasticJobExecutor.class.getDeclaredField("jobExceptionHandler")),
+ assertThat(ReflectionUtils.getFieldValue(simpleJobExecutor, ElasticJobExecutor.class.getDeclaredField("jobExceptionHandler")),
instanceOf(DefaultJobExceptionHandler.class));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ExecutorServiceObjectTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ElasticJobExecutorServiceTest.java
similarity index 93%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ExecutorServiceObjectTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ElasticJobExecutorServiceTest.java
index 4981425..31073eb 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ExecutorServiceObjectTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ElasticJobExecutorServiceTest.java
@@ -26,11 +26,11 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-public final class ExecutorServiceObjectTest {
+public final class ElasticJobExecutorServiceTest {
@Test
public void assertCreateExecutorService() {
- ExecutorServiceObject executorServiceObject = new ExecutorServiceObject("executor-service-test", 1);
+ ElasticJobExecutorService executorServiceObject = new ElasticJobExecutorService("executor-service-test", 1);
assertThat(executorServiceObject.getActiveThreadCount(), is(0));
assertThat(executorServiceObject.getWorkQueueSize(), is(0));
assertFalse(executorServiceObject.isShutdown());
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/digest/EncryptionTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/digest/EncryptionTest.java
deleted file mode 100644
index 21cd771..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/digest/EncryptionTest.java
+++ /dev/null
@@ -1,31 +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.util.digest;
-
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class EncryptionTest {
-
- @Test
- public void assertMd5() {
- assertThat(Encryption.md5("test"), is("98f6bcd4621d373cade4e832627b4f6"));
- }
-}
diff --git a/elastic-job-lite-spring/src/test/resources/META-INF/job/base.xml b/elastic-job-lite-spring/src/test/resources/META-INF/job/base.xml
index f5377ac..bb3e4c2 100644
--- a/elastic-job-lite-spring/src/test/resources/META-INF/job/base.xml
+++ b/elastic-job-lite-spring/src/test/resources/META-INF/job/base.xml
@@ -32,9 +32,9 @@
max-sleep-time-milliseconds="${regCenter.maxSleepTimeMilliseconds}" max-retries="${regCenter.maxRetries}" />
<bean id="foo" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.service.FooServiceImpl" />
<bean id="elasticJobLog" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="org.h2.Driver"/>
- <property name="url" value="jdbc:h2:mem:job_event_storage"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <property name="driverClassName" value="org.h2.Driver" />
+ <property name="url" value="jdbc:h2:mem:job_event_storage" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
</bean>
</beans>
diff --git a/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobRef.xml b/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobRef.xml
index fe051a3..1fa556d 100644
--- a/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobRef.xml
+++ b/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobRef.xml
@@ -26,10 +26,10 @@
">
<import resource="base.xml"/>
<bean id="refSimpleJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.ref.RefFooSimpleElasticJob">
- <property name="fooService" ref="foo"/>
+ <property name="fooService" ref="foo" />
</bean>
<bean id="refDataflowJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.ref.RefFooDataflowElasticJob">
- <property name="fooService" ref="foo"/>
+ <property name="fooService" ref="foo" />
</bean>
<job:simple id="simpleElasticJob_job_ref" job-ref="refSimpleJob" registry-center-ref="regCenter" cron="${simpleJob.cron}" sharding-total-count="${simpleJob.shardingTotalCount}"
sharding-item-parameters="${simpleJob.shardingItemParameters}" disabled="${simpleJob.disabled}" overwrite="${simpleJob.overwrite}"