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/23 11:09:32 UTC
[shardingsphere-elasticjob-lite] branch master updated: Split core
module and tracing module (#825)
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 019daf9 Split core module and tracing module (#825)
019daf9 is described below
commit 019daf9163eff0f0eca42d2f6017ecb2d801075a
Author: Liang Zhang <te...@163.com>
AuthorDate: Tue Jun 23 19:09:23 2020 +0800
Split core module and tracing module (#825)
* Add elastic-job-lite-tracing module
* Add dependency
* refactor JobEventRdbSearch
* rename ExceptionUtils
* decouple ExecutionType and JobStatusTraceEvent
* decouple ElasticJobExecutorService and JobEventBus
* decouple IpUtils and JobExecutionEvent
* decouple ExceptionUtils and JobExecutionEvent
* remove useless JobExecutionEventThrowable
* Move suitable codes to elastic-job-lite-tracing-api
* finish LogJobErrorHandlerTest
* Add rdb tracing dependency
* Move suitable code to elastic-job-lite-tracing-rdb
* Add log config
---
.../restful/EventTraceHistoryRESTfulAPI.java | 6 +--
elastic-job-lite-core/pom.xml | 10 +++-
.../elasticjob/lite/api/JobScheduler.java | 4 +-
.../event/type/JobExecutionEventThrowable.java | 37 -------------
.../{ExceptionUtil.java => ExceptionUtils.java} | 4 +-
.../lite/executor/ElasticJobExecutor.java | 17 +++---
.../elasticjob/lite/executor/JobFacade.java | 4 +-
.../lite/internal/schedule/LiteJobFacade.java | 12 ++---
.../util/concurrent/ElasticJobExecutorService.java | 4 +-
...eptionUtilTest.java => ExceptionUtilsTest.java} | 8 +--
.../lite/executor/type/impl/ElasticJobVerify.java | 2 +-
.../executor/type/impl/SimpleJobExecutorTest.java | 2 +-
.../executor/type/impl/WrongJobExecutorTest.java | 2 +-
.../handler/error/impl/LogJobErrorHandlerTest.java | 13 +++--
.../lite/internal/schedule/LiteJobFacadeTest.java | 2 +-
.../elasticjob/lite/util/ReflectionUtils.java | 18 +++++++
.../src/test/resources/logback-test.xml | 4 +-
.../restful/RESTfulAPIExceptionMapper.java | 4 +-
.../common/AbstractJobBeanDefinitionParser.java | 2 +-
.../elastic-job-lite-tracing-api}/pom.xml | 59 ++++++--------------
.../elasticjob/lite/tracing}/JobEvent.java | 4 +-
.../elasticjob/lite/tracing}/JobEventBus.java | 30 ++++++++---
.../lite/tracing}/JobEventConfiguration.java | 4 +-
.../elasticjob/lite/tracing}/JobEventIdentity.java | 4 +-
.../elasticjob/lite/tracing}/JobEventListener.java | 8 +--
.../JobEventListenerConfigurationException.java | 4 +-
.../lite/tracing}/type/JobExecutionEvent.java | 26 +++------
.../lite/tracing}/type/JobStatusTraceEvent.java | 7 ++-
.../elasticjob/lite/tracing}/JobEventBusTest.java | 39 ++++++++------
.../lite/tracing}/JobExecutionEventTest.java | 27 +++++-----
.../lite/tracing}/fixture/JobEventCaller.java | 2 +-
.../fixture/TestJobEventConfiguration.java | 6 +--
.../fixture/TestJobEventFailureConfiguration.java | 8 +--
.../tracing}/fixture/TestJobEventIdentity.java | 4 +-
.../tracing}/fixture/TestJobEventListener.java | 8 +--
.../src/test/resources/logback-test.xml | 11 ++--
.../elastic-job-lite-tracing-rdb}/pom.xml | 62 +++++++---------------
.../elasticjob/lite/tracing}/rdb/DatabaseType.java | 4 +-
.../tracing}/rdb/JobEventRdbConfiguration.java | 10 ++--
.../lite/tracing}/rdb/JobEventRdbIdentity.java | 6 +--
.../lite/tracing}/rdb/JobEventRdbListener.java | 10 ++--
.../lite/tracing}/rdb/JobEventRdbSearch.java | 22 ++++----
.../lite/tracing}/rdb/JobEventRdbStorage.java | 17 +++---
.../tracing}/rdb/JobEventRdbConfigurationTest.java | 10 ++--
.../lite/tracing}/rdb/JobEventRdbIdentityTest.java | 4 +-
.../lite/tracing}/rdb/JobEventRdbListenerTest.java | 34 +++++++-----
.../lite/tracing}/rdb/JobEventRdbSearchTest.java | 22 ++++----
.../lite/tracing}/rdb/JobEventRdbStorageTest.java | 55 ++++++++++---------
.../src/test/resources/logback-test.xml | 8 +--
elastic-job-lite-tracing/pom.xml | 36 +++++++++++++
.../elasticjob/lite/example/JavaMain.java | 4 +-
.../lite/example/config/DataflowJobConfig.java | 2 +-
.../lite/example/config/JobEventConfig.java | 4 +-
.../lite/example/config/SimpleJobConfig.java | 2 +-
pom.xml | 16 +++---
55 files changed, 354 insertions(+), 380 deletions(-)
diff --git a/elastic-job-lite-console/src/main/java/org/apache/shardingsphere/elasticjob/lite/console/restful/EventTraceHistoryRESTfulAPI.java b/elastic-job-lite-console/src/main/java/org/apache/shardingsphere/elasticjob/lite/console/restful/EventTraceHistoryRESTfulAPI.java
index 5fd3449..f1cb8f7 100644
--- a/elastic-job-lite-console/src/main/java/org/apache/shardingsphere/elasticjob/lite/console/restful/EventTraceHistoryRESTfulAPI.java
+++ b/elastic-job-lite-console/src/main/java/org/apache/shardingsphere/elasticjob/lite/console/restful/EventTraceHistoryRESTfulAPI.java
@@ -22,9 +22,9 @@ import org.apache.shardingsphere.elasticjob.lite.console.domain.EventTraceDataSo
import org.apache.shardingsphere.elasticjob.lite.console.service.EventTraceDataSourceConfigurationService;
import org.apache.shardingsphere.elasticjob.lite.console.service.impl.EventTraceDataSourceConfigurationServiceImpl;
import org.apache.shardingsphere.elasticjob.lite.console.util.SessionEventTraceDataSourceConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.rdb.JobEventRdbSearch;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.rdb.JobEventRdbSearch;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent;
import org.apache.commons.dbcp.BasicDataSource;
import javax.sql.DataSource;
diff --git a/elastic-job-lite-core/pom.xml b/elastic-job-lite-core/pom.xml
index 87cff50..6a33c18 100644
--- a/elastic-job-lite-core/pom.xml
+++ b/elastic-job-lite-core/pom.xml
@@ -27,9 +27,11 @@
<dependencies>
<dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
+ <groupId>org.apache.shardingsphere.elasticjob</groupId>
+ <artifactId>elastic-job-lite-tracing-rdb</artifactId>
+ <version>${project.parent.version}</version>
</dependency>
+
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
@@ -61,6 +63,10 @@
<artifactId>curator-recipes</artifactId>
</dependency>
<dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
</dependency>
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 b3df527..b9367cf 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
@@ -21,8 +21,8 @@ import org.apache.shardingsphere.elasticjob.lite.api.listener.AbstractDistribute
import org.apache.shardingsphere.elasticjob.lite.api.listener.ElasticJobListener;
import org.apache.shardingsphere.elasticjob.lite.api.script.ScriptJob;
import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventBus;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventBus;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventConfiguration;
import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import org.apache.shardingsphere.elasticjob.lite.handler.sharding.JobInstance;
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/type/JobExecutionEventThrowable.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/type/JobExecutionEventThrowable.java
deleted file mode 100644
index 39169f9..0000000
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/type/JobExecutionEventThrowable.java
+++ /dev/null
@@ -1,37 +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.event.type;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import lombok.ToString;
-
-/**
- * Job execution event throwable.
- */
-@RequiredArgsConstructor
-@AllArgsConstructor
-@Getter
-@ToString(of = "plainText")
-public final class JobExecutionEventThrowable {
-
- private final Throwable throwable;
-
- private String plainText;
-}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtil.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtils.java
similarity index 96%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtil.java
rename to elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtils.java
index 00df08a..ceaf895 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtil.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtils.java
@@ -24,10 +24,10 @@ import java.io.PrintWriter;
import java.io.StringWriter;
/**
- * Exception utility.
+ * Exception utilities.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ExceptionUtil {
+public final class ExceptionUtils {
/**
* Transform throwable to string.
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 6271dd8..0ba75cb 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
@@ -21,15 +21,16 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
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.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent.ExecutionSource;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.exception.ExceptionUtils;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
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;
import org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor;
+import org.apache.shardingsphere.elasticjob.lite.util.env.IpUtils;
import java.util.Collection;
import java.util.Map;
@@ -134,13 +135,13 @@ public final class ElasticJobExecutor {
Collection<Integer> items = shardingContexts.getShardingItemParameters().keySet();
if (1 == items.size()) {
int item = shardingContexts.getShardingItemParameters().keySet().iterator().next();
- JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(shardingContexts.getTaskId(), jobName, executionSource, item);
+ JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(IpUtils.getHostName(), IpUtils.getIp(), shardingContexts.getTaskId(), jobName, executionSource, item);
process(shardingContexts, item, jobExecutionEvent);
return;
}
final CountDownLatch latch = new CountDownLatch(items.size());
for (final int each : items) {
- JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(shardingContexts.getTaskId(), jobName, executionSource, each);
+ JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(IpUtils.getHostName(), IpUtils.getIp(), shardingContexts.getTaskId(), jobName, executionSource, each);
if (executorService.isShutdown()) {
return;
}
@@ -172,9 +173,9 @@ public final class ElasticJobExecutor {
// CHECKSTYLE:OFF
} catch (final Throwable cause) {
// CHECKSTYLE:ON
- completeEvent = startEvent.executionFailure(cause);
+ completeEvent = startEvent.executionFailure(ExceptionUtils.transform(cause));
jobFacade.postJobExecutionEvent(completeEvent);
- itemErrorMessages.put(item, ExceptionUtil.transform(cause));
+ itemErrorMessages.put(item, ExceptionUtils.transform(cause));
jobErrorHandler.handleException(jobName, cause);
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/JobFacade.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/JobFacade.java
index 02ea1cf..c76138e 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/JobFacade.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/executor/JobFacade.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.elasticjob.lite.executor;
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.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.State;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
import java.util.Collection;
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacade.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacade.java
index 93f9780..b8c9b50 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacade.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacade.java
@@ -23,11 +23,11 @@ import org.apache.shardingsphere.elasticjob.lite.api.listener.ElasticJobListener
import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.dataflow.DataflowJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.context.TaskContext;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventBus;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.Source;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventBus;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.Source;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.State;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
@@ -171,7 +171,7 @@ public final class LiteJobFacade implements JobFacade {
public void postJobStatusTraceEvent(final String taskId, final State state, final String message) {
TaskContext taskContext = TaskContext.from(taskId);
jobEventBus.post(new JobStatusTraceEvent(taskContext.getMetaInfo().getJobName(), taskContext.getId(),
- taskContext.getSlaveId(), Source.LITE_EXECUTOR, taskContext.getType(), taskContext.getMetaInfo().getShardingItems().toString(), state, message));
+ taskContext.getSlaveId(), Source.LITE_EXECUTOR, taskContext.getType().name(), taskContext.getMetaInfo().getShardingItems().toString(), state, message));
if (!Strings.isNullOrEmpty(message)) {
log.trace(message);
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ElasticJobExecutorService.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ElasticJobExecutorService.java
index 228aeea..29f6b84 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ElasticJobExecutorService.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/concurrent/ElasticJobExecutorService.java
@@ -38,8 +38,8 @@ public final class ElasticJobExecutorService {
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());
+ threadPoolExecutor = new ThreadPoolExecutor(
+ threadSize, threadSize, 5L, TimeUnit.MINUTES, workQueue, new BasicThreadFactory.Builder().namingPattern(Joiner.on("-").join(namingPattern, "%s")).build());
threadPoolExecutor.allowCoreThreadTimeOut(true);
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtilTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtilsTest.java
similarity index 80%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtilTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtilsTest.java
index b7ce89a..dd95696 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtilTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/exception/ExceptionUtilsTest.java
@@ -23,20 +23,20 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-public final class ExceptionUtilTest {
+public final class ExceptionUtilsTest {
@Test
public void assertTransformWithError() {
- assertTrue(ExceptionUtil.transform(new Error("Error")).startsWith("java.lang.Error"));
+ assertTrue(ExceptionUtils.transform(new Error("Error")).startsWith("java.lang.Error"));
}
@Test
public void assertTransformWithException() {
- assertTrue(ExceptionUtil.transform(new Exception("Exception")).startsWith("java.lang.Exception"));
+ assertTrue(ExceptionUtils.transform(new Exception("Exception")).startsWith("java.lang.Exception"));
}
@Test
public void assertTransformWithNull() {
- assertThat(ExceptionUtil.transform(null), is(""));
+ assertThat(ExceptionUtils.transform(null), is(""));
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ElasticJobVerify.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ElasticJobVerify.java
index d9a3f71..f9f573e 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ElasticJobVerify.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ElasticJobVerify.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.State;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
index 7390f73..d0b0ddb 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.tracing.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.ElasticJobExecutor;
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
index d997e94..8b846dd 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.State;
import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/handler/error/impl/LogJobErrorHandlerTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/handler/error/impl/LogJobErrorHandlerTest.java
index 56890d2..6c93071 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/handler/error/impl/LogJobErrorHandlerTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/handler/error/impl/LogJobErrorHandlerTest.java
@@ -17,24 +17,27 @@
package org.apache.shardingsphere.elasticjob.lite.handler.error.impl;
-import org.apache.shardingsphere.elasticjob.lite.event.fixture.JobEventCaller;
+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 org.slf4j.Logger;
-import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
public final class LogJobErrorHandlerTest {
@Mock
- private JobEventCaller caller;
+ private Logger log;
@Test
public void assertHandleException() {
- new LogJobErrorHandler().handleException("test_job", new RuntimeException("test"));
- verify(caller, atMost(1)).call();
+ LogJobErrorHandler actual = new LogJobErrorHandler();
+ ReflectionUtils.setStaticFieldValue(actual, "log", log);
+ Throwable cause = new RuntimeException("test");
+ actual.handleException("test_job", cause);
+ verify(log).error("Job 'test_job' exception occur in job processing", cause);
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java
index f7a06e6..c0676aa 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.dataflow.DataflowJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.simple.SimpleJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventBus;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventBus;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationService;
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/ReflectionUtils.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/ReflectionUtils.java
index 1d39846..213973a 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/ReflectionUtils.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/ReflectionUtils.java
@@ -22,6 +22,7 @@ import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
/**
* Reflection utilities.
@@ -58,6 +59,23 @@ public final class ReflectionUtils {
}
/**
+ * Set static field value.
+ *
+ * @param target target object
+ * @param fieldName field name
+ * @param fieldValue field value
+ */
+ @SneakyThrows
+ public static void setStaticFieldValue(final Object target, final String fieldName, final Object fieldValue) {
+ Field field = target.getClass().getDeclaredField(fieldName);
+ field.setAccessible(true);
+ Field modifiers = field.getClass().getDeclaredField("modifiers");
+ modifiers.setAccessible(true);
+ modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
+ field.set(target, fieldValue);
+ }
+
+ /**
* Set superclass field value.
*
* @param target target object
diff --git a/elastic-job-lite-core/src/test/resources/logback-test.xml b/elastic-job-lite-core/src/test/resources/logback-test.xml
index f1ef5d1..90cd2f2 100644
--- a/elastic-job-lite-core/src/test/resources/logback-test.xml
+++ b/elastic-job-lite-core/src/test/resources/logback-test.xml
@@ -35,10 +35,8 @@
<root>
<appender-ref ref="STDOUT" />
</root>
-
+
<logger name="org.apache.curator.framework.recipes.leader.LeaderSelector" level="OFF" />
- <logger name="org.apache.shardingsphere.elasticjob.lite.event.rdb.JobEventRdbConfiguration" level="OFF" />
- <logger name="org.apache.shardingsphere.elasticjob.lite.event.JobEventBus" level="OFF" />
<logger name="org.apache.shardingsphere.elasticjob.lite.handler.error.impl.LogJobErrorHandler" level="OFF" />
<logger name="org.apache.shardingsphere.elasticjob.lite.internal.monitor.MonitorService" level="OFF" />
</configuration>
diff --git a/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/restful/RESTfulAPIExceptionMapper.java b/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/restful/RESTfulAPIExceptionMapper.java
index aecccfb..5c96478 100644
--- a/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/restful/RESTfulAPIExceptionMapper.java
+++ b/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/restful/RESTfulAPIExceptionMapper.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.elasticjob.lite.lifecycle.restful;
-import org.apache.shardingsphere.elasticjob.lite.exception.ExceptionUtil;
+import org.apache.shardingsphere.elasticjob.lite.exception.ExceptionUtils;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -32,6 +32,6 @@ public final class RESTfulAPIExceptionMapper implements ExceptionMapper<Throwabl
@Override
public Response toResponse(final Throwable cause) {
- return Response.ok(ExceptionUtil.transform(cause), MediaType.TEXT_PLAIN).status(Response.Status.INTERNAL_SERVER_ERROR).build();
+ return Response.ok(ExceptionUtils.transform(cause), MediaType.TEXT_PLAIN).status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
diff --git a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java
index 14fca0c..17ad417 100644
--- a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java
+++ b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java
@@ -22,7 +22,7 @@ import lombok.SneakyThrows;
import org.apache.shardingsphere.elasticjob.lite.api.JobScheduler;
import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.rdb.JobEventRdbConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.rdb.JobEventRdbConfiguration;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
diff --git a/elastic-job-lite-core/pom.xml b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/pom.xml
similarity index 57%
copy from elastic-job-lite-core/pom.xml
copy to elastic-job-lite-tracing/elastic-job-lite-tracing-api/pom.xml
index 87cff50..ee4160b 100644
--- a/elastic-job-lite-core/pom.xml
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/pom.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
@@ -7,7 +8,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,64 +16,38 @@
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere.elasticjob</groupId>
- <artifactId>elastic-job-lite</artifactId>
+ <artifactId>elastic-job-lite-tracing</artifactId>
<version>3.0.0.M1-SNAPSHOT</version>
</parent>
- <artifactId>elastic-job-lite-core</artifactId>
+ <artifactId>elastic-job-lite-tracing-api</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <dependency>
- <groupId>org.quartz-scheduler</groupId>
- <artifactId>quartz</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-exec</artifactId>
- <version>${commons-exec.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator.version}</version>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-recipes</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-test</artifactId>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
</dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -86,10 +61,6 @@
<artifactId>mockito-inline</artifactId>
</dependency>
<dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEvent.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEvent.java
similarity index 93%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEvent.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEvent.java
index fc4bcdd..957fc87 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEvent.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEvent.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,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event;
+package org.apache.shardingsphere.elasticjob.lite.tracing;
/**
* Job event.
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventBus.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventBus.java
similarity index 60%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventBus.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventBus.java
index 0deddba..34ee08c 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventBus.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventBus.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,12 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event;
+package org.apache.shardingsphere.elasticjob.lite.tracing;
+import com.google.common.base.Joiner;
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
+import com.google.common.util.concurrent.MoreExecutors;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.elasticjob.lite.util.concurrent.ElasticJobExecutorService;
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
/**
* Job event bus.
@@ -30,7 +37,7 @@ public final class JobEventBus {
private final JobEventConfiguration jobEventConfig;
- private final ElasticJobExecutorService elasticJobExecutorService;
+ private final ExecutorService executorService;
private final EventBus eventBus;
@@ -38,17 +45,24 @@ public final class JobEventBus {
public JobEventBus() {
jobEventConfig = null;
- elasticJobExecutorService = null;
+ executorService = null;
eventBus = null;
}
public JobEventBus(final JobEventConfiguration jobEventConfig) {
this.jobEventConfig = jobEventConfig;
- elasticJobExecutorService = new ElasticJobExecutorService("job-event", Runtime.getRuntime().availableProcessors() * 2);
- eventBus = new AsyncEventBus(elasticJobExecutorService.createExecutorService());
+ executorService = createExecutorService(Runtime.getRuntime().availableProcessors() * 2);
+ eventBus = new AsyncEventBus(executorService);
register();
}
+ private ExecutorService createExecutorService(final int threadSize) {
+ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
+ threadSize, threadSize, 5L, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new BasicThreadFactory.Builder().namingPattern(Joiner.on("-").join("job-event", "%s")).build());
+ threadPoolExecutor.allowCoreThreadTimeOut(true);
+ return MoreExecutors.listeningDecorator(MoreExecutors.getExitingExecutorService(threadPoolExecutor));
+ }
+
private void register() {
try {
eventBus.register(jobEventConfig.createJobEventListener());
@@ -64,7 +78,7 @@ public final class JobEventBus {
* @param event job event
*/
public void post(final JobEvent event) {
- if (isRegistered && !elasticJobExecutorService.isShutdown()) {
+ if (isRegistered && !executorService.isShutdown()) {
eventBus.post(event);
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventConfiguration.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventConfiguration.java
similarity index 94%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventConfiguration.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventConfiguration.java
index 1b8f7fb..3b5d43c 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventConfiguration.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventConfiguration.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,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event;
+package org.apache.shardingsphere.elasticjob.lite.tracing;
/**
* Job event configuration.
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventIdentity.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventIdentity.java
similarity index 93%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventIdentity.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventIdentity.java
index a62bf05..edf1ffc 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventIdentity.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventIdentity.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,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event;
+package org.apache.shardingsphere.elasticjob.lite.tracing;
/**
* Job event identity.
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventListener.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventListener.java
similarity index 86%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventListener.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventListener.java
index f37407f..46f8684 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventListener.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventListener.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,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event;
+package org.apache.shardingsphere.elasticjob.lite.tracing;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent;
/**
* Job event listener.
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventListenerConfigurationException.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventListenerConfigurationException.java
similarity index 94%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventListenerConfigurationException.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventListenerConfigurationException.java
index b1d93cf..6a81bbe 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventListenerConfigurationException.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventListenerConfigurationException.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,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event;
+package org.apache.shardingsphere.elasticjob.lite.tracing;
/**
* Job event listener configuration exception.
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/type/JobExecutionEvent.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/type/JobExecutionEvent.java
similarity index 75%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/type/JobExecutionEvent.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/type/JobExecutionEvent.java
index 20eed35..2d4b783 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/type/JobExecutionEvent.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/type/JobExecutionEvent.java
@@ -15,15 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.type;
+package org.apache.shardingsphere.elasticjob.lite.tracing.type;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEvent;
-import org.apache.shardingsphere.elasticjob.lite.exception.ExceptionUtil;
-import org.apache.shardingsphere.elasticjob.lite.util.env.IpUtils;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEvent;
import java.util.Date;
import java.util.UUID;
@@ -38,9 +36,9 @@ public final class JobExecutionEvent implements JobEvent {
private String id = UUID.randomUUID().toString();
- private String hostname = IpUtils.getHostName();
+ private final String hostname;
- private String ip = IpUtils.getIp();
+ private final String ip;
private final String taskId;
@@ -59,7 +57,7 @@ public final class JobExecutionEvent implements JobEvent {
private boolean success;
@Setter
- private JobExecutionEventThrowable failureCause;
+ private String failureCause;
/**
* Execution success.
@@ -79,23 +77,15 @@ public final class JobExecutionEvent implements JobEvent {
* @param failureCause failure cause
* @return job execution event
*/
- public JobExecutionEvent executionFailure(final Throwable failureCause) {
- JobExecutionEvent result = new JobExecutionEvent(id, hostname, ip, taskId, jobName, source, shardingItem, startTime, completeTime, success, new JobExecutionEventThrowable(failureCause));
+ public JobExecutionEvent executionFailure(final String failureCause) {
+ JobExecutionEvent result = new JobExecutionEvent(id, hostname, ip, taskId, jobName, source, shardingItem, startTime, completeTime, success, failureCause);
result.setCompleteTime(new Date());
result.setSuccess(false);
+ result.setFailureCause(failureCause);
return result;
}
/**
- * Get failure cause.
- *
- * @return failure cause
- */
- public String getFailureCause() {
- return ExceptionUtil.transform(failureCause == null ? null : failureCause.getThrowable());
- }
-
- /**
* Execution source.
*/
public enum ExecutionSource {
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/type/JobStatusTraceEvent.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/type/JobStatusTraceEvent.java
similarity index 88%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/type/JobStatusTraceEvent.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/type/JobStatusTraceEvent.java
index b92b421..fa1455d 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/type/JobStatusTraceEvent.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/type/JobStatusTraceEvent.java
@@ -15,14 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.type;
+package org.apache.shardingsphere.elasticjob.lite.tracing.type;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
-import org.apache.shardingsphere.elasticjob.lite.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEvent;
import java.util.Date;
import java.util.UUID;
@@ -48,7 +47,7 @@ public final class JobStatusTraceEvent implements JobEvent {
private final Source source;
- private final ExecutionType executionType;
+ private final String executionType;
private final String shardingItems;
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventBusTest.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventBusTest.java
similarity index 57%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventBusTest.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventBusTest.java
index acdf962..b44ecce 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/JobEventBusTest.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobEventBusTest.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,24 +15,26 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event;
+package org.apache.shardingsphere.elasticjob.lite.tracing;
import com.google.common.eventbus.EventBus;
-import org.apache.shardingsphere.elasticjob.lite.event.fixture.JobEventCaller;
-import org.apache.shardingsphere.elasticjob.lite.event.fixture.TestJobEventConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.fixture.TestJobEventFailureConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.fixture.TestJobEventListener;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import lombok.SneakyThrows;
+import org.apache.shardingsphere.elasticjob.lite.tracing.fixture.JobEventCaller;
+import org.apache.shardingsphere.elasticjob.lite.tracing.fixture.TestJobEventConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.fixture.TestJobEventFailureConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.fixture.TestJobEventListener;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
-import static org.hamcrest.CoreMatchers.is;
+import java.lang.reflect.Field;
+
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
@@ -56,7 +58,7 @@ public final class JobEventBusTest {
public void assertPost() throws InterruptedException {
jobEventBus = new JobEventBus(new TestJobEventConfiguration(jobEventCaller));
assertIsRegistered(true);
- jobEventBus.post(new JobExecutionEvent("fake_task_id", "test_event_bus_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0));
+ jobEventBus.post(new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_event_bus_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0));
while (!TestJobEventListener.isExecutionEventCalled()) {
Thread.sleep(100L);
}
@@ -64,15 +66,20 @@ public final class JobEventBusTest {
}
@Test
- public void assertPostWithoutListener() {
+ public void assertPostWithoutListener() throws ReflectiveOperationException {
jobEventBus = new JobEventBus();
assertIsRegistered(false);
- ReflectionUtils.setFieldValue(jobEventBus, "eventBus", eventBus);
- jobEventBus.post(new JobExecutionEvent("fake_task_id", "test_event_bus_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0));
- verify(eventBus, times(0)).post(ArgumentMatchers.<JobEvent>any());
+ Field field = JobEventBus.class.getDeclaredField("eventBus");
+ field.setAccessible(true);
+ field.set(jobEventBus, eventBus);
+ jobEventBus.post(new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_event_bus_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0));
+ verify(eventBus, Mockito.times(0)).post(ArgumentMatchers.<JobEvent>any());
}
+ @SneakyThrows
private void assertIsRegistered(final boolean actual) {
- assertThat(ReflectionUtils.getFieldValue(jobEventBus, "isRegistered"), is(actual));
+ Field field = JobEventBus.class.getDeclaredField("isRegistered");
+ field.setAccessible(true);
+ assertThat(field.get(jobEventBus), CoreMatchers.is(actual));
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/JobExecutionEventTest.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobExecutionEventTest.java
similarity index 61%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/JobExecutionEventTest.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobExecutionEventTest.java
index d0c68c3..0d830c5 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/JobExecutionEventTest.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/JobExecutionEventTest.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,13 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event;
+package org.apache.shardingsphere.elasticjob.lite.tracing;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.hamcrest.CoreMatchers;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.startsWith;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -32,20 +31,20 @@ public final class JobExecutionEventTest {
@Test
public void assertNewJobExecutionEvent() {
- JobExecutionEvent actual = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
- assertThat(actual.getJobName(), is("test_job"));
- assertThat(actual.getSource(), is(JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER));
- assertThat(actual.getShardingItem(), is(0));
+ JobExecutionEvent actual = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
+ assertThat(actual.getJobName(), CoreMatchers.is("test_job"));
+ assertThat(actual.getSource(), CoreMatchers.is(JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER));
+ assertThat(actual.getShardingItem(), CoreMatchers.is(0));
assertNotNull(actual.getHostname());
assertNotNull(actual.getStartTime());
assertNull(actual.getCompleteTime());
assertFalse(actual.isSuccess());
- assertThat(actual.getFailureCause(), is(""));
+ assertNull(actual.getFailureCause());
}
@Test
public void assertExecutionSuccess() {
- JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
+ JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
JobExecutionEvent successEvent = startEvent.executionSuccess();
assertNotNull(successEvent.getCompleteTime());
assertTrue(successEvent.isSuccess());
@@ -53,10 +52,10 @@ public final class JobExecutionEventTest {
@Test
public void assertExecutionFailure() {
- JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
- JobExecutionEvent failureEvent = startEvent.executionFailure(new RuntimeException("failure"));
+ JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
+ JobExecutionEvent failureEvent = startEvent.executionFailure("java.lang.RuntimeException: failure");
assertNotNull(failureEvent.getCompleteTime());
assertFalse(failureEvent.isSuccess());
- assertThat(failureEvent.getFailureCause(), startsWith("java.lang.RuntimeException: failure"));
+ assertThat(failureEvent.getFailureCause(), CoreMatchers.is("java.lang.RuntimeException: failure"));
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/JobEventCaller.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/JobEventCaller.java
similarity index 93%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/JobEventCaller.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/JobEventCaller.java
index 6a1f293..35993bf 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/JobEventCaller.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/JobEventCaller.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.fixture;
+package org.apache.shardingsphere.elasticjob.lite.tracing.fixture;
public interface JobEventCaller {
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventConfiguration.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventConfiguration.java
similarity index 84%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventConfiguration.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventConfiguration.java
index e6e03ff..0e4f520 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventConfiguration.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventConfiguration.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.fixture;
+package org.apache.shardingsphere.elasticjob.lite.tracing.fixture;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventListener;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventListener;
@RequiredArgsConstructor
public final class TestJobEventConfiguration extends TestJobEventIdentity implements JobEventConfiguration {
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventFailureConfiguration.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventFailureConfiguration.java
similarity index 78%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventFailureConfiguration.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventFailureConfiguration.java
index 3231edd..26f6855 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventFailureConfiguration.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventFailureConfiguration.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.fixture;
+package org.apache.shardingsphere.elasticjob.lite.tracing.fixture;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventListener;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventListenerConfigurationException;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventListener;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventListenerConfigurationException;
public final class TestJobEventFailureConfiguration extends TestJobEventIdentity implements JobEventConfiguration {
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventIdentity.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventIdentity.java
similarity index 87%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventIdentity.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventIdentity.java
index e6da52d..31042f7 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventIdentity.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventIdentity.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.fixture;
+package org.apache.shardingsphere.elasticjob.lite.tracing.fixture;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventIdentity;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventIdentity;
public class TestJobEventIdentity implements JobEventIdentity {
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventListener.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventListener.java
similarity index 83%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventListener.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventListener.java
index 6c97451..d970fad 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/fixture/TestJobEventListener.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/fixture/TestJobEventListener.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.fixture;
+package org.apache.shardingsphere.elasticjob.lite.tracing.fixture;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventListener;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventListener;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent;
@RequiredArgsConstructor
public final class TestJobEventListener extends TestJobEventIdentity implements JobEventListener {
diff --git a/elastic-job-lite-core/src/test/resources/logback-test.xml b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/resources/logback-test.xml
similarity index 74%
copy from elastic-job-lite-core/src/test/resources/logback-test.xml
copy to elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/resources/logback-test.xml
index f1ef5d1..639f0ac 100644
--- a/elastic-job-lite-core/src/test/resources/logback-test.xml
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-api/src/test/resources/logback-test.xml
@@ -8,7 +8,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.
@@ -35,10 +35,7 @@
<root>
<appender-ref ref="STDOUT" />
</root>
-
- <logger name="org.apache.curator.framework.recipes.leader.LeaderSelector" level="OFF" />
- <logger name="org.apache.shardingsphere.elasticjob.lite.event.rdb.JobEventRdbConfiguration" level="OFF" />
- <logger name="org.apache.shardingsphere.elasticjob.lite.event.JobEventBus" level="OFF" />
- <logger name="org.apache.shardingsphere.elasticjob.lite.handler.error.impl.LogJobErrorHandler" level="OFF" />
- <logger name="org.apache.shardingsphere.elasticjob.lite.internal.monitor.MonitorService" level="OFF" />
+
+ <logger name="org.apache.shardingsphere.elasticjob.lite.tracing.rdb.JobEventRdbConfiguration" level="OFF" />
+ <logger name="org.apache.shardingsphere.elasticjob.lite.tracing.JobEventBus" level="OFF" />
</configuration>
diff --git a/elastic-job-lite-core/pom.xml b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/pom.xml
similarity index 63%
copy from elastic-job-lite-core/pom.xml
copy to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/pom.xml
index 87cff50..421d582 100644
--- a/elastic-job-lite-core/pom.xml
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/pom.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
@@ -7,7 +8,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,64 +16,43 @@
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere.elasticjob</groupId>
- <artifactId>elastic-job-lite</artifactId>
+ <artifactId>elastic-job-lite-tracing</artifactId>
<version>3.0.0.M1-SNAPSHOT</version>
</parent>
- <artifactId>elastic-job-lite-core</artifactId>
+ <artifactId>elastic-job-lite-tracing-rdb</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <dependency>
- <groupId>org.quartz-scheduler</groupId>
- <artifactId>quartz</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-exec</artifactId>
- <version>${commons-exec.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-recipes</artifactId>
+ <groupId>org.apache.shardingsphere.elasticjob</groupId>
+ <artifactId>elastic-job-lite-tracing-api</artifactId>
+ <version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
+ <version>${commons-dbcp.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
-
<dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-test</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
</dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -86,10 +66,6 @@
<artifactId>mockito-inline</artifactId>
</dependency>
<dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/DatabaseType.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/DatabaseType.java
similarity index 96%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/DatabaseType.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/DatabaseType.java
index 3054ac5..a3f20a7 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/DatabaseType.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/DatabaseType.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,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
import java.util.Arrays;
import java.util.Optional;
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbConfiguration.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbConfiguration.java
similarity index 83%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbConfiguration.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbConfiguration.java
index 211a574..98f0f62 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbConfiguration.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbConfiguration.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,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventListener;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventListenerConfigurationException;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventListener;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventListenerConfigurationException;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbIdentity.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbIdentity.java
similarity index 87%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbIdentity.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbIdentity.java
index a57c112..c375b45 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbIdentity.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbIdentity.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,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventIdentity;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventIdentity;
/**
* Job event RDB identity.
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbListener.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbListener.java
similarity index 83%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbListener.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbListener.java
index 8fc087c..1acd138 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbListener.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbListener.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,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventListener;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventListener;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent;
import javax.sql.DataSource;
import java.sql.SQLException;
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbSearch.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbSearch.java
similarity index 93%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbSearch.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbSearch.java
index c4c0606..8017003 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbSearch.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbSearch.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,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
import com.google.common.base.CaseFormat;
import com.google.common.base.Strings;
@@ -23,12 +23,11 @@ import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.elasticjob.lite.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEventThrowable;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.Source;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent.ExecutionSource;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.Source;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.State;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -90,10 +89,9 @@ public final class JobEventRdbSearch {
) {
while (resultSet.next()) {
JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(resultSet.getString(1), resultSet.getString(2), resultSet.getString(3), resultSet.getString(4),
- resultSet.getString(5), JobExecutionEvent.ExecutionSource.valueOf(resultSet.getString(6)), Integer.valueOf(resultSet.getString(7)),
+ resultSet.getString(5), ExecutionSource.valueOf(resultSet.getString(6)), Integer.valueOf(resultSet.getString(7)),
new Date(resultSet.getTimestamp(8).getTime()), resultSet.getTimestamp(9) == null ? null : new Date(resultSet.getTimestamp(9).getTime()),
- resultSet.getBoolean(10), new JobExecutionEventThrowable(null, resultSet.getString(11))
- );
+ resultSet.getBoolean(10), resultSet.getString(11));
result.add(jobExecutionEvent);
}
} catch (final SQLException ex) {
@@ -112,7 +110,7 @@ public final class JobEventRdbSearch {
) {
while (resultSet.next()) {
JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent(resultSet.getString(1), resultSet.getString(2), resultSet.getString(3), resultSet.getString(4),
- resultSet.getString(5), Source.valueOf(resultSet.getString(6)), ExecutionType.valueOf(resultSet.getString(7)), resultSet.getString(8),
+ resultSet.getString(5), Source.valueOf(resultSet.getString(6)), resultSet.getString(7), resultSet.getString(8),
State.valueOf(resultSet.getString(9)), resultSet.getString(10), new Date(resultSet.getTimestamp(11).getTime()));
result.add(jobStatusTraceEvent);
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbStorage.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbStorage.java
similarity index 96%
rename from elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbStorage.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbStorage.java
index a194a6f..6bf9589 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbStorage.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbStorage.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,15 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
import com.google.common.base.Strings;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.elasticjob.lite.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.Source;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.Source;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.State;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -313,7 +312,7 @@ final class JobEventRdbStorage {
preparedStatement.setString(4, jobStatusTraceEvent.getTaskId());
preparedStatement.setString(5, jobStatusTraceEvent.getSlaveId());
preparedStatement.setString(6, jobStatusTraceEvent.getSource().toString());
- preparedStatement.setString(7, jobStatusTraceEvent.getExecutionType().name());
+ preparedStatement.setString(7, jobStatusTraceEvent.getExecutionType());
preparedStatement.setString(8, jobStatusTraceEvent.getShardingItems());
preparedStatement.setString(9, jobStatusTraceEvent.getState().toString());
preparedStatement.setString(10, truncateString(jobStatusTraceEvent.getMessage()));
@@ -359,7 +358,7 @@ final class JobEventRdbStorage {
) {
while (resultSet.next()) {
JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent(resultSet.getString(1), resultSet.getString(2), resultSet.getString(3), resultSet.getString(4),
- resultSet.getString(5), Source.valueOf(resultSet.getString(6)), ExecutionType.valueOf(resultSet.getString(7)), resultSet.getString(8),
+ resultSet.getString(5), Source.valueOf(resultSet.getString(6)), resultSet.getString(7), resultSet.getString(8),
State.valueOf(resultSet.getString(9)), resultSet.getString(10), new SimpleDateFormat("yyyy-mm-dd HH:MM:SS").parse(resultSet.getString(11)));
result.add(jobStatusTraceEvent);
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbConfigurationTest.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbConfigurationTest.java
similarity index 90%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbConfigurationTest.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbConfigurationTest.java
index 399c1e9..67feb3b 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbConfigurationTest.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbConfigurationTest.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,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventListenerConfigurationException;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventListenerConfigurationException;
+import org.hamcrest.CoreMatchers;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public final class JobEventRdbConfigurationTest {
@@ -34,7 +34,7 @@ public final class JobEventRdbConfigurationTest {
dataSource.setUrl("jdbc:h2:mem:job_event_storage");
dataSource.setUsername("sa");
dataSource.setPassword("");
- assertThat(new JobEventRdbConfiguration(dataSource).getDataSource(), is(dataSource));
+ assertThat(new JobEventRdbConfiguration(dataSource).getDataSource(), CoreMatchers.is(dataSource));
}
@Test
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbIdentityTest.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbIdentityTest.java
similarity index 94%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbIdentityTest.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbIdentityTest.java
index d89d5c2..bac6b5c 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbIdentityTest.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbIdentityTest.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,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
import org.junit.Test;
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbListenerTest.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbListenerTest.java
similarity index 68%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbListenerTest.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbListenerTest.java
index 19ad13e..31e9c13 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbListenerTest.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbListenerTest.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,23 +15,23 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
+import lombok.SneakyThrows;
import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.shardingsphere.elasticjob.lite.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventBus;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventListenerConfigurationException;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.Source;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
-import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventBus;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventListenerConfigurationException;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.Source;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.State;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.lang.reflect.Field;
import java.sql.SQLException;
import static org.mockito.Mockito.atMost;
@@ -59,22 +59,28 @@ public final class JobEventRdbListenerTest {
dataSource.setUsername("sa");
dataSource.setPassword("");
JobEventRdbListener jobEventRdbListener = new JobEventRdbListener(dataSource);
- ReflectionUtils.setFieldValue(jobEventRdbListener, "repository", repository);
+ setRepository(jobEventRdbListener);
when(jobEventRdbConfiguration.createJobEventListener()).thenReturn(jobEventRdbListener);
jobEventBus = new JobEventBus(jobEventRdbConfiguration);
}
+ @SneakyThrows
+ private void setRepository(final JobEventRdbListener jobEventRdbListener) {
+ Field field = JobEventRdbListener.class.getDeclaredField("repository");
+ field.setAccessible(true);
+ field.set(jobEventRdbListener, repository);
+ }
+
@Test
public void assertPostJobExecutionEvent() {
- JobExecutionEvent jobExecutionEvent = new JobExecutionEvent("fake_task_id", JOB_NAME, JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
+ JobExecutionEvent jobExecutionEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", JOB_NAME, JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
jobEventBus.post(jobExecutionEvent);
verify(repository, atMost(1)).addJobExecutionEvent(jobExecutionEvent);
}
@Test
public void assertPostJobStatusTraceEvent() {
- JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent(
- JOB_NAME, "fake_task_id", "fake_slave_id", Source.LITE_EXECUTOR, ExecutionType.READY, "0", State.TASK_RUNNING, "message is empty.");
+ JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent(JOB_NAME, "fake_task_id", "fake_slave_id", Source.LITE_EXECUTOR, "READY", "0", State.TASK_RUNNING, "message is empty.");
jobEventBus.post(jobStatusTraceEvent);
verify(repository, atMost(1)).addJobStatusTraceEvent(jobStatusTraceEvent);
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbSearchTest.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbSearchTest.java
similarity index 93%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbSearchTest.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbSearchTest.java
index 94ac33f..f93fa04 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbSearchTest.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbSearchTest.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,14 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.shardingsphere.elasticjob.lite.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.Source;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.Source;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.State;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -34,7 +33,7 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public class JobEventRdbSearchTest {
+public final class JobEventRdbSearchTest {
private static JobEventRdbStorage storage;
@@ -54,15 +53,14 @@ public class JobEventRdbSearchTest {
private static void initStorage() {
for (int i = 1; i <= 500; i++) {
- JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job_" + i, JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
+ JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job_" + i, JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
storage.addJobExecutionEvent(startEvent);
if (i % 2 == 0) {
JobExecutionEvent successEvent = startEvent.executionSuccess();
storage.addJobExecutionEvent(successEvent);
}
- storage.addJobStatusTraceEvent(
- new JobStatusTraceEvent("test_job_" + i, "fake_failed_failover_task_id", "fake_slave_id",
- Source.LITE_EXECUTOR, ExecutionType.FAILOVER, "0", State.TASK_FAILED, "message is empty."));
+ storage.addJobStatusTraceEvent(new JobStatusTraceEvent(
+ "test_job_" + i, "fake_failed_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, "FAILOVER", "0", State.TASK_FAILED, "message is empty."));
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbStorageTest.java b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbStorageTest.java
similarity index 65%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbStorageTest.java
rename to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbStorageTest.java
index 35e15e1..7dcb04d 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/event/rdb/JobEventRdbStorageTest.java
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/lite/tracing/rdb/JobEventRdbStorageTest.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,14 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.event.rdb;
+package org.apache.shardingsphere.elasticjob.lite.tracing.rdb;
import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.shardingsphere.elasticjob.lite.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobExecutionEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.Source;
-import org.apache.shardingsphere.elasticjob.lite.event.type.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobExecutionEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.Source;
+import org.apache.shardingsphere.elasticjob.lite.tracing.type.JobStatusTraceEvent.State;
import org.junit.Before;
import org.junit.Test;
@@ -36,7 +35,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-public class JobEventRdbStorageTest {
+public final class JobEventRdbStorageTest {
private JobEventRdbStorage storage;
@@ -52,19 +51,19 @@ public class JobEventRdbStorageTest {
@Test
public void assertAddJobExecutionEvent() {
- assertTrue(storage.addJobExecutionEvent(new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0)));
+ assertTrue(storage.addJobExecutionEvent(new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0)));
}
@Test
public void assertAddJobStatusTraceEvent() {
- assertTrue(storage.addJobStatusTraceEvent(new JobStatusTraceEvent("test_job", "fake_task_id", "fake_slave_id", Source.LITE_EXECUTOR, ExecutionType.READY, "0",
- State.TASK_RUNNING, "message is empty.")));
+ assertTrue(storage.addJobStatusTraceEvent(
+ new JobStatusTraceEvent("test_job", "fake_task_id", "fake_slave_id", Source.LITE_EXECUTOR, "READY", "0", State.TASK_RUNNING, "message is empty.")));
}
@Test
public void assertAddJobStatusTraceEventWhenFailoverWithTaskStagingState() {
- JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent("test_job", "fake_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, ExecutionType.FAILOVER, "0",
- State.TASK_STAGING, "message is empty.");
+ JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent(
+ "test_job", "fake_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, "FAILOVER", "0", State.TASK_STAGING, "message is empty.");
jobStatusTraceEvent.setOriginalTaskId("original_fake_failover_task_id");
assertThat(storage.getJobStatusTraceEvents("fake_failover_task_id").size(), is(0));
storage.addJobStatusTraceEvent(jobStatusTraceEvent);
@@ -73,12 +72,12 @@ public class JobEventRdbStorageTest {
@Test
public void assertAddJobStatusTraceEventWhenFailoverWithTaskFailedState() {
- JobStatusTraceEvent stagingJobStatusTraceEvent = new JobStatusTraceEvent("test_job", "fake_failed_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, ExecutionType.FAILOVER, "0",
- State.TASK_STAGING, "message is empty.");
+ JobStatusTraceEvent stagingJobStatusTraceEvent = new JobStatusTraceEvent(
+ "test_job", "fake_failed_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, "FAILOVER", "0", State.TASK_STAGING, "message is empty.");
stagingJobStatusTraceEvent.setOriginalTaskId("original_fake_failed_failover_task_id");
storage.addJobStatusTraceEvent(stagingJobStatusTraceEvent);
- JobStatusTraceEvent failedJobStatusTraceEvent = new JobStatusTraceEvent("test_job", "fake_failed_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, ExecutionType.FAILOVER, "0",
- State.TASK_FAILED, "message is empty.");
+ JobStatusTraceEvent failedJobStatusTraceEvent = new JobStatusTraceEvent(
+ "test_job", "fake_failed_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, "FAILOVER", "0", State.TASK_FAILED, "message is empty.");
storage.addJobStatusTraceEvent(failedJobStatusTraceEvent);
List<JobStatusTraceEvent> jobStatusTraceEvents = storage.getJobStatusTraceEvents("fake_failed_failover_task_id");
assertThat(jobStatusTraceEvents.size(), is(2));
@@ -89,7 +88,7 @@ public class JobEventRdbStorageTest {
@Test
public void assertUpdateJobExecutionEventWhenSuccess() {
- JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
+ JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
assertTrue(storage.addJobExecutionEvent(startEvent));
JobExecutionEvent successEvent = startEvent.executionSuccess();
assertTrue(storage.addJobExecutionEvent(successEvent));
@@ -97,17 +96,17 @@ public class JobEventRdbStorageTest {
@Test
public void assertUpdateJobExecutionEventWhenFailure() {
- JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
+ JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
assertTrue(storage.addJobExecutionEvent(startEvent));
- JobExecutionEvent failureEvent = startEvent.executionFailure(new RuntimeException("failure"));
+ JobExecutionEvent failureEvent = startEvent.executionFailure("java.lang.RuntimeException: failure");
assertTrue(storage.addJobExecutionEvent(failureEvent));
- assertThat(failureEvent.getFailureCause(), startsWith("java.lang.RuntimeException: failure"));
+ assertThat(failureEvent.getFailureCause(), is("java.lang.RuntimeException: failure"));
assertNotNull(failureEvent.getCompleteTime());
}
@Test
public void assertUpdateJobExecutionEventWhenSuccessAndConflict() {
- JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
+ JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
JobExecutionEvent successEvent = startEvent.executionSuccess();
assertTrue(storage.addJobExecutionEvent(successEvent));
assertFalse(storage.addJobExecutionEvent(startEvent));
@@ -115,28 +114,28 @@ public class JobEventRdbStorageTest {
@Test
public void assertUpdateJobExecutionEventWhenFailureAndConflict() {
- JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
- JobExecutionEvent failureEvent = startEvent.executionFailure(new RuntimeException("failure"));
+ JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
+ JobExecutionEvent failureEvent = startEvent.executionFailure("java.lang.RuntimeException: failure");
assertTrue(storage.addJobExecutionEvent(failureEvent));
- assertThat(failureEvent.getFailureCause(), startsWith("java.lang.RuntimeException: failure"));
+ assertThat(failureEvent.getFailureCause(), is("java.lang.RuntimeException: failure"));
assertFalse(storage.addJobExecutionEvent(startEvent));
}
@Test
public void assertUpdateJobExecutionEventWhenFailureAndMessageExceed() {
- JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
+ JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
assertTrue(storage.addJobExecutionEvent(startEvent));
StringBuilder failureMsg = new StringBuilder();
for (int i = 0; i < 600; i++) {
failureMsg.append(i);
}
- JobExecutionEvent failEvent = startEvent.executionFailure(new RuntimeException("failure" + failureMsg.toString()));
+ JobExecutionEvent failEvent = startEvent.executionFailure("java.lang.RuntimeException: failure" + failureMsg.toString());
assertTrue(storage.addJobExecutionEvent(failEvent));
assertThat(failEvent.getFailureCause(), startsWith("java.lang.RuntimeException: failure"));
}
@Test
public void assertFindJobExecutionEvent() {
- storage.addJobExecutionEvent(new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0));
+ storage.addJobExecutionEvent(new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0));
}
}
diff --git a/elastic-job-lite-core/src/test/resources/logback-test.xml b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/resources/logback-test.xml
similarity index 74%
copy from elastic-job-lite-core/src/test/resources/logback-test.xml
copy to elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/resources/logback-test.xml
index f1ef5d1..6653274 100644
--- a/elastic-job-lite-core/src/test/resources/logback-test.xml
+++ b/elastic-job-lite-tracing/elastic-job-lite-tracing-rdb/src/test/resources/logback-test.xml
@@ -8,7 +8,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.
@@ -35,10 +35,4 @@
<root>
<appender-ref ref="STDOUT" />
</root>
-
- <logger name="org.apache.curator.framework.recipes.leader.LeaderSelector" level="OFF" />
- <logger name="org.apache.shardingsphere.elasticjob.lite.event.rdb.JobEventRdbConfiguration" level="OFF" />
- <logger name="org.apache.shardingsphere.elasticjob.lite.event.JobEventBus" level="OFF" />
- <logger name="org.apache.shardingsphere.elasticjob.lite.handler.error.impl.LogJobErrorHandler" level="OFF" />
- <logger name="org.apache.shardingsphere.elasticjob.lite.internal.monitor.MonitorService" level="OFF" />
</configuration>
diff --git a/elastic-job-lite-tracing/pom.xml b/elastic-job-lite-tracing/pom.xml
new file mode 100644
index 0000000..2e83185
--- /dev/null
+++ b/elastic-job-lite-tracing/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shardingsphere.elasticjob</groupId>
+ <artifactId>elastic-job-lite</artifactId>
+ <version>3.0.0.M1-SNAPSHOT</version>
+ </parent>
+ <artifactId>elastic-job-lite-tracing</artifactId>
+ <packaging>pom</packaging>
+ <name>${project.artifactId}</name>
+
+ <modules>
+ <module>elastic-job-lite-tracing-api</module>
+ <module>elastic-job-lite-tracing-rdb</module>
+ </modules>
+</project>
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 4cadbd5..130dbe5 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
@@ -24,8 +24,8 @@ import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.dataflow.DataflowJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.script.ScriptJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.simple.SimpleJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.rdb.JobEventRdbConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.rdb.JobEventRdbConfiguration;
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.reg.base.CoordinatorRegistryCenter;
diff --git a/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/DataflowJobConfig.java b/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/DataflowJobConfig.java
index 40eeb19..efa8072 100644
--- a/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/DataflowJobConfig.java
+++ b/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/DataflowJobConfig.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.elasticjob.lite.api.dataflow.DataflowJob;
import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.dataflow.DataflowJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventConfiguration;
import org.apache.shardingsphere.elasticjob.lite.example.job.dataflow.SpringDataflowJob;
import org.apache.shardingsphere.elasticjob.lite.reg.zookeeper.ZookeeperRegistryCenter;
import org.springframework.beans.factory.annotation.Value;
diff --git a/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/JobEventConfig.java b/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/JobEventConfig.java
index 8c08de9..44a210d 100644
--- a/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/JobEventConfig.java
+++ b/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/JobEventConfig.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.elasticjob.lite.example.config;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.rdb.JobEventRdbConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.rdb.JobEventRdbConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/SimpleJobConfig.java b/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/SimpleJobConfig.java
index fc03cdc..70b4de2 100644
--- a/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/SimpleJobConfig.java
+++ b/examples/elastic-job-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/config/SimpleJobConfig.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.elasticjob.lite.api.simple.SimpleJob;
import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.config.simple.SimpleJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.event.JobEventConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.tracing.JobEventConfiguration;
import org.apache.shardingsphere.elasticjob.lite.example.job.simple.SpringSimpleJob;
import org.apache.shardingsphere.elasticjob.lite.reg.zookeeper.ZookeeperRegistryCenter;
import org.springframework.beans.factory.annotation.Value;
diff --git a/pom.xml b/pom.xml
index 9dccf72..9d7337c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,6 +32,7 @@
<modules>
<module>elastic-job-lite-core</module>
+ <module>elastic-job-lite-tracing</module>
<module>elastic-job-lite-spring</module>
<module>elastic-job-lite-lifecycle</module>
<module>elastic-job-lite-console</module>
@@ -45,11 +46,11 @@
<springframework.version>[3.1.0.RELEASE,5.0.0.M1)</springframework.version>
- <lombok.version>1.16.4</lombok.version>
<guava.version>18.0</guava.version>
<commons-lang3.version>3.4</commons-lang3.version>
<quartz.version>2.3.0</quartz.version>
<curator.version>2.10.0</curator.version>
+ <lombok.version>1.16.4</lombok.version>
<aspectj.version>1.8.0</aspectj.version>
<slf4j.version>1.7.7</slf4j.version>
<logback.version>1.1.2</logback.version>
@@ -93,12 +94,6 @@
<dependencyManagement>
<dependencies>
<dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- <version>${lombok.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
@@ -140,6 +135,13 @@
<version>${curator.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${lombok.version}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>