Skip to content

Commit

Permalink
Remove AbstractJobType
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Nov 9, 2023
1 parent 3987143 commit 8a196e0
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 56 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
/**
* 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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

0 comments on commit 8a196e0

Please sign in to comment.