Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CDCJobAPI #29239

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,26 @@
@Slf4j
public final class CDCJobAPI implements TransmissionJobAPI {

private final YamlDataSourceConfigurationSwapper dataSourceConfigSwapper = new YamlDataSourceConfigurationSwapper();
private final CDCJobOption jobOption;

private final YamlRuleConfigurationSwapperEngine ruleConfigSwapperEngine = new YamlRuleConfigurationSwapperEngine();
private final PipelineJobManager jobManager;

private final YamlPipelineDataSourceConfigurationSwapper pipelineDataSourceConfigSwapper = new YamlPipelineDataSourceConfigurationSwapper();
private final PipelineJobConfigurationManager jobConfigManager;

private final CDCJobOption jobOption = new CDCJobOption();
private final YamlDataSourceConfigurationSwapper dataSourceConfigSwapper;

private final YamlRuleConfigurationSwapperEngine ruleConfigSwapperEngine;

private final YamlPipelineDataSourceConfigurationSwapper pipelineDataSourceConfigSwapper;

public CDCJobAPI() {
jobOption = new CDCJobOption();
jobManager = new PipelineJobManager(jobOption);
jobConfigManager = new PipelineJobConfigurationManager(jobOption);
dataSourceConfigSwapper = new YamlDataSourceConfigurationSwapper();
ruleConfigSwapperEngine = new YamlRuleConfigurationSwapperEngine();
pipelineDataSourceConfigSwapper = new YamlPipelineDataSourceConfigurationSwapper();
}

/**
* Create CDC job.
Expand All @@ -108,7 +121,7 @@ public String create(final StreamDataParameter param, final CDCSinkType sinkType
log.warn("CDC job already exists in registry center, ignore, job id is `{}`", jobConfig.getJobId());
} else {
governanceFacade.getJobFacade().getJob().create(jobConfig.getJobId(), jobOption.getJobClass());
JobConfigurationPOJO jobConfigPOJO = new PipelineJobConfigurationManager(jobOption).convertToJobConfigurationPOJO(jobConfig);
JobConfigurationPOJO jobConfigPOJO = jobConfigManager.convertToJobConfigurationPOJO(jobConfig);
jobConfigPOJO.setDisabled(true);
governanceFacade.getJobFacade().getConfiguration().persist(jobConfig.getJobId(), jobConfigPOJO);
if (!param.isFull()) {
Expand Down Expand Up @@ -231,9 +244,9 @@ public void disable(final String jobId) {
* @param jobId job id
*/
public void drop(final String jobId) {
CDCJobConfiguration jobConfig = new PipelineJobConfigurationManager(jobOption).getJobConfiguration(jobId);
CDCJobConfiguration jobConfig = jobConfigManager.getJobConfiguration(jobId);
ShardingSpherePreconditions.checkState(PipelineJobIdUtils.getElasticJobConfigurationPOJO(jobId).isDisabled(), () -> new PipelineInternalException("Can't drop streaming job which is active"));
new PipelineJobManager(jobOption).drop(jobId);
jobManager.drop(jobId);
cleanup(jobConfig);
}

Expand Down