From 125f06fdb18faec3bc0d4a30e8221d3f111fe3b6 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Thu, 26 Oct 2023 23:45:24 +0800 Subject: [PATCH] Move TaskContext to kernel module (#2319) * Move TaskContext to kernel module * Move TaskContext to kernel module --- .../elasticjob/tracing/event/JobStatusTraceEvent.java | 2 +- .../kernel/internal}/context/ExecutionType.java | 2 +- .../kernel/internal}/context/TaskContext.java | 2 +- .../elasticjob/kernel/internal/schedule/LiteJob.java | 2 +- .../kernel/internal/schedule/LiteJobFacade.java | 2 +- .../kernel/internal}/context/TaskContextTest.java | 11 ++++++----- .../kernel/internal}/context/fixture/TaskNode.java | 4 ++-- 7 files changed, 13 insertions(+), 12 deletions(-) rename {infra/src/main/java/org/apache/shardingsphere/elasticjob/infra => kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal}/context/ExecutionType.java (93%) rename {infra/src/main/java/org/apache/shardingsphere/elasticjob/infra => kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal}/context/TaskContext.java (98%) rename {infra/src/test/java/org/apache/shardingsphere/elasticjob/infra => kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal}/context/TaskContextTest.java (91%) rename {infra/src/test/java/org/apache/shardingsphere/elasticjob/infra => kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal}/context/fixture/TaskNode.java (90%) diff --git a/ecosystem/tracing/api/src/main/java/org/apache/shardingsphere/elasticjob/tracing/event/JobStatusTraceEvent.java b/ecosystem/tracing/api/src/main/java/org/apache/shardingsphere/elasticjob/tracing/event/JobStatusTraceEvent.java index cef09d3fd9..91b938c8b8 100644 --- a/ecosystem/tracing/api/src/main/java/org/apache/shardingsphere/elasticjob/tracing/event/JobStatusTraceEvent.java +++ b/ecosystem/tracing/api/src/main/java/org/apache/shardingsphere/elasticjob/tracing/event/JobStatusTraceEvent.java @@ -28,8 +28,8 @@ /** * Job status trace event. */ -@RequiredArgsConstructor @AllArgsConstructor +@RequiredArgsConstructor @Getter public final class JobStatusTraceEvent implements JobEvent { diff --git a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/context/ExecutionType.java b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/ExecutionType.java similarity index 93% rename from infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/context/ExecutionType.java rename to kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/ExecutionType.java index fb7cff1b4e..8d771282fa 100755 --- a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/context/ExecutionType.java +++ b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/ExecutionType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.elasticjob.infra.context; +package org.apache.shardingsphere.elasticjob.kernel.internal.context; /** * Execution type. diff --git a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContext.java b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/TaskContext.java similarity index 98% rename from infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContext.java rename to kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/TaskContext.java index e2f32ec664..f416b4d71c 100755 --- a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContext.java +++ b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/TaskContext.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.elasticjob.infra.context; +package org.apache.shardingsphere.elasticjob.kernel.internal.context; import com.google.common.base.Preconditions; import com.google.common.base.Splitter; diff --git a/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/schedule/LiteJob.java b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/schedule/LiteJob.java index 4d828f1d48..8189e05c06 100644 --- a/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/schedule/LiteJob.java +++ b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/schedule/LiteJob.java @@ -23,7 +23,7 @@ import org.quartz.JobExecutionContext; /** - * Lite job class. + * Lite job. */ @Setter public final class LiteJob implements Job { diff --git a/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/schedule/LiteJobFacade.java b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/schedule/LiteJobFacade.java index 479f720da1..593c856a45 100644 --- a/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/schedule/LiteJobFacade.java +++ b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/schedule/LiteJobFacade.java @@ -26,7 +26,7 @@ import org.apache.shardingsphere.elasticjob.kernel.internal.sharding.ExecutionService; import org.apache.shardingsphere.elasticjob.kernel.internal.sharding.ShardingService; import org.apache.shardingsphere.elasticjob.executor.JobFacade; -import org.apache.shardingsphere.elasticjob.infra.context.TaskContext; +import org.apache.shardingsphere.elasticjob.kernel.internal.context.TaskContext; import org.apache.shardingsphere.elasticjob.infra.exception.JobExecutionEnvironmentException; import org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListener; import org.apache.shardingsphere.elasticjob.infra.listener.ShardingContexts; diff --git a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java b/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/TaskContextTest.java similarity index 91% rename from infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java rename to kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/TaskContextTest.java index c5f2f26fd0..9d10370181 100644 --- a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java +++ b/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/TaskContextTest.java @@ -15,10 +15,11 @@ * limitations under the License. */ -package org.apache.shardingsphere.elasticjob.infra.context; +package org.apache.shardingsphere.elasticjob.kernel.internal.context; -import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo; -import org.apache.shardingsphere.elasticjob.infra.context.fixture.TaskNode; +import org.apache.shardingsphere.elasticjob.kernel.internal.context.TaskContext.MetaInfo; +import org.apache.shardingsphere.elasticjob.kernel.internal.context.fixture.TaskNode; +import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -36,7 +37,7 @@ void assertNew() { TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY, "slave-S0"); assertThat(actual.getMetaInfo().getJobName(), is("test_job")); assertThat(actual.getMetaInfo().getShardingItems().get(0), is(0)); - assertThat(actual.getType(), is(ExecutionType.READY)); + assertThat(actual.getType(), CoreMatchers.is(ExecutionType.READY)); assertThat(actual.getSlaveId(), is("slave-S0")); assertThat(actual.getId(), startsWith(TaskNode.builder().build().getTaskNodeValue().substring(0, TaskNode.builder().build().getTaskNodeValue().length() - 1))); } @@ -59,7 +60,7 @@ void assertTaskContextFrom() { assertThat(actual.getId(), is(TaskNode.builder().build().getTaskNodeValue())); assertThat(actual.getMetaInfo().getJobName(), is("test_job")); assertThat(actual.getMetaInfo().getShardingItems().get(0), is(0)); - assertThat(actual.getType(), is(ExecutionType.READY)); + assertThat(actual.getType(), CoreMatchers.is(ExecutionType.READY)); assertThat(actual.getSlaveId(), is("slave-S0")); } diff --git a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/fixture/TaskNode.java b/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/fixture/TaskNode.java similarity index 90% rename from infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/fixture/TaskNode.java rename to kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/fixture/TaskNode.java index 94202fb856..7c8ed00240 100644 --- a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/fixture/TaskNode.java +++ b/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/context/fixture/TaskNode.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.shardingsphere.elasticjob.infra.context.fixture; +package org.apache.shardingsphere.elasticjob.kernel.internal.context.fixture; import lombok.Builder; -import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType; +import org.apache.shardingsphere.elasticjob.kernel.internal.context.ExecutionType; @Builder public final class TaskNode {