This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 16a75b80cfa Remove AbstractJobType (#28993)
16a75b80cfa is described below
commit 16a75b80cfa40cb2c3707168a72c185ac89fbe27
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Nov 9 16:31:58 2023 +0800
Remove AbstractJobType (#28993)
---
.../pipeline/common/job/type/AbstractJobType.java | 38 ----------------------
.../pipeline/common/job/type/JobCodeRegistry.java | 5 ++-
.../pipeline/common/job/type/FixtureJobType.java | 12 ++++---
.../data/pipeline/cdc/api/job/type/CDCJobType.java | 14 +++++---
.../consistencycheck/ConsistencyCheckJobType.java | 14 +++++---
.../scenario/migration/MigrationJobType.java | 14 +++++---
6 files changed, 41 insertions(+), 56 deletions(-)
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/type/AbstractJobType.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/type/AbstractJobType.java
deleted file mode 100644
index 8a6610bb34a..00000000000
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/type/AbstractJobType.java
+++ /dev/null
@@ -1,38 +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.data.pipeline.common.job.type;
-
-import com.google.common.base.Preconditions;
-import lombok.Getter;
-
-/**
- * Abstract job type.
- */
-@Getter
-public abstract class AbstractJobType implements JobType {
-
- private final String type;
-
- private final String code;
-
- protected AbstractJobType(final String type, final String code) {
- this.type = type;
- Preconditions.checkArgument(2 == code.length(), "code length is not
2");
- this.code = code;
- }
-}
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/type/JobCodeRegistry.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/type/JobCodeRegistry.java
index 6d198e16144..a9e84907828 100644
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/type/JobCodeRegistry.java
+++
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/type/JobCodeRegistry.java
@@ -36,7 +36,10 @@ public final class JobCodeRegistry {
private static final Map<String, String> JOB_CODE_AND_TYPE_MAP = new
HashMap<>();
static {
-
ShardingSphereServiceLoader.getServiceInstances(JobType.class).forEach(each ->
JOB_CODE_AND_TYPE_MAP.put(each.getCode(), each.getType()));
+ for (JobType each :
ShardingSphereServiceLoader.getServiceInstances(JobType.class)) {
+ Preconditions.checkArgument(2 == each.getCode().length(), "Job
type code length is not 2.");
+ JOB_CODE_AND_TYPE_MAP.put(each.getCode(), each.getType());
+ }
}
/**
diff --git
a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/common/job/type/FixtureJobType.java
b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/common/job/type/FixtureJobType.java
index 1e905f0bfc2..a1976f940ab 100644
---
a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/common/job/type/FixtureJobType.java
+++
b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/common/job/type/FixtureJobType.java
@@ -20,11 +20,15 @@ package
org.apache.shardingsphere.data.pipeline.common.job.type;
/**
* Fixture job type.
*/
-public final class FixtureJobType extends AbstractJobType {
+public final class FixtureJobType implements JobType {
- public static final String TYPE_CODE = "00";
+ @Override
+ public String getCode() {
+ return "00";
+ }
- public FixtureJobType() {
- super("FIXTURE", TYPE_CODE);
+ @Override
+ public String getType() {
+ return "FIXTURE";
}
}
diff --git
a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/job/type/CDCJobType.java
b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/job/type/CDCJobType.java
index b545d63180f..95cfcbdb538 100644
---
a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/job/type/CDCJobType.java
+++
b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/job/type/CDCJobType.java
@@ -17,16 +17,20 @@
package org.apache.shardingsphere.data.pipeline.cdc.api.job.type;
-import org.apache.shardingsphere.data.pipeline.common.job.type.AbstractJobType;
+import org.apache.shardingsphere.data.pipeline.common.job.type.JobType;
/**
* CDC job type.
*/
-public final class CDCJobType extends AbstractJobType {
+public final class CDCJobType implements JobType {
- public static final String TYPE_CODE = "03";
+ @Override
+ public String getCode() {
+ return "03";
+ }
- public CDCJobType() {
- super("STREAMING", TYPE_CODE);
+ @Override
+ public String getType() {
+ return "STREAMING";
}
}
diff --git
a/kernel/data-pipeline/scenario/consistencycheck/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/ConsistencyCheckJobType.java
b/kernel/data-pipeline/scenario/consistencycheck/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/ConsistencyCheckJobType.java
index d42ee9a6ef1..ce87dac4dfa 100644
---
a/kernel/data-pipeline/scenario/consistencycheck/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/ConsistencyCheckJobType.java
+++
b/kernel/data-pipeline/scenario/consistencycheck/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/ConsistencyCheckJobType.java
@@ -17,16 +17,22 @@
package org.apache.shardingsphere.data.pipeline.scenario.consistencycheck;
-import org.apache.shardingsphere.data.pipeline.common.job.type.AbstractJobType;
+import org.apache.shardingsphere.data.pipeline.common.job.type.JobType;
/**
* Consistency check job type.
*/
-public final class ConsistencyCheckJobType extends AbstractJobType {
+public final class ConsistencyCheckJobType implements JobType {
public static final String TYPE_CODE = "02";
- public ConsistencyCheckJobType() {
- super("CONSISTENCY_CHECK", TYPE_CODE);
+ @Override
+ public String getCode() {
+ return TYPE_CODE;
+ }
+
+ @Override
+ public String getType() {
+ return "CONSISTENCY_CHECK";
}
}
diff --git
a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobType.java
b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobType.java
index f0c979e9f51..92d305bca0f 100644
---
a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobType.java
+++
b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobType.java
@@ -17,16 +17,22 @@
package org.apache.shardingsphere.data.pipeline.scenario.migration;
-import org.apache.shardingsphere.data.pipeline.common.job.type.AbstractJobType;
+import org.apache.shardingsphere.data.pipeline.common.job.type.JobType;
/**
* Migration job type.
*/
-public final class MigrationJobType extends AbstractJobType {
+public final class MigrationJobType implements JobType {
public static final String TYPE_CODE = "01";
- public MigrationJobType() {
- super("MIGRATION", TYPE_CODE);
+ @Override
+ public String getCode() {
+ return TYPE_CODE;
+ }
+
+ @Override
+ public String getType() {
+ return "MIGRATION";
}
}