Skip to content

Commit

Permalink
Refactor ConsistencyCheckJobId (#29284)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Dec 4, 2023
1 parent 0b73645 commit c825887
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.apache.shardingsphere.data.pipeline.common.context.PipelineContextKey;
import org.apache.shardingsphere.data.pipeline.common.job.type.PipelineJobType;

import java.util.Optional;

/**
* Pipeline job id.
*/
Expand All @@ -40,4 +42,13 @@ public interface PipelineJobId {
* @return pipeline context key
*/
PipelineContextKey getContextKey();

/**
* Get sequence.
*
* @return sequence
*/
default Optional<Integer> getSequence() {
return Optional.empty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public final class PipelineJobIdUtils {
* @return job id
*/
public static String marshal(final PipelineJobId jobId) {
return marshalPrefix(jobId.getJobType(), jobId.getContextKey()) + marshalSuffix(jobId);
return marshalPrefix(jobId.getJobType(), jobId.getContextKey()) + marshalSuffix(jobId) + jobId.getSequence().map(String::valueOf).orElse("");
}

private static String marshalPrefix(final PipelineJobType jobType, final PipelineContextKey contextKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.apache.shardingsphere.data.pipeline.common.job.type.PipelineJobType;
import org.apache.shardingsphere.data.pipeline.scenario.consistencycheck.util.ConsistencyCheckSequence;

import java.util.Optional;

/**
* Consistency check job id.
*/
Expand Down Expand Up @@ -60,4 +62,9 @@ public ConsistencyCheckJobId(final PipelineContextKey contextKey, final String p
public static int parseSequence(final String checkJobId) {
return Integer.parseInt(checkJobId.substring(checkJobId.length() - 1));
}

@Override
public Optional<Integer> getSequence() {
return Optional.of(sequence);
}
}

0 comments on commit c825887

Please sign in to comment.