View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shardingsphere.data.pipeline.core.job.type;
19  
20  import com.fasterxml.jackson.annotation.JsonIgnoreType;
21  import org.apache.shardingsphere.data.pipeline.core.consistencycheck.ConsistencyCheckJobItemProgressContext;
22  import org.apache.shardingsphere.data.pipeline.core.consistencycheck.PipelineDataConsistencyChecker;
23  import org.apache.shardingsphere.data.pipeline.core.context.TransmissionProcessContext;
24  import org.apache.shardingsphere.data.pipeline.core.job.PipelineJob;
25  import org.apache.shardingsphere.data.pipeline.core.job.config.PipelineJobConfiguration;
26  import org.apache.shardingsphere.data.pipeline.core.job.config.yaml.swapper.YamlPipelineJobConfigurationSwapper;
27  import org.apache.shardingsphere.data.pipeline.core.job.progress.PipelineJobItemProgress;
28  import org.apache.shardingsphere.data.pipeline.core.job.progress.yaml.config.YamlPipelineJobItemProgressConfiguration;
29  import org.apache.shardingsphere.data.pipeline.core.job.progress.yaml.swapper.YamlPipelineJobItemProgressSwapper;
30  import org.apache.shardingsphere.data.pipeline.core.pojo.PipelineJobInfo;
31  import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
32  import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
33  import org.apache.shardingsphere.infra.util.yaml.YamlConfiguration;
34  
35  import java.util.Optional;
36  
37  /**
38   * Pipeline job type.
39   */
40  @SingletonSPI
41  @JsonIgnoreType
42  public interface PipelineJobType extends TypedSPI {
43      
44      /**
45       * Get job type code.
46       *
47       * @return job type code
48       */
49      String getCode();
50      
51      /**
52       * Get YAML pipeline job configuration swapper.
53       *
54       * @param <T> type of YAML configuration
55       * @param <Y> type of pipeline job configuration
56       * @return YAML pipeline job configuration swapper
57       */
58      <Y extends YamlConfiguration, T extends PipelineJobConfiguration> YamlPipelineJobConfigurationSwapper<Y, T> getYamlJobConfigurationSwapper();
59      
60      /**
61       * Get YAML pipeline job item progress swapper.
62       *
63       * @param <T> type of pipeline job item progress
64       * @return YAML pipeline job item progress swapper
65       */
66      <T extends PipelineJobItemProgress> YamlPipelineJobItemProgressSwapper<YamlPipelineJobItemProgressConfiguration, T> getYamlJobItemProgressSwapper();
67      
68      /**
69       * Get pipeline job class.
70       *
71       * @return pipeline job class
72       */
73      Class<? extends PipelineJob> getJobClass();
74      
75      /**
76       * Whether to ignore to start disabled job when job item progress is finished.
77       *
78       * @return ignore to start disabled job when job item progress is finished or not
79       */
80      default boolean isIgnoreToStartDisabledJobWhenJobItemProgressIsFinished() {
81          return false;
82      }
83      
84      /**
85       * Get to be start disabled next job type.
86       *
87       * @return to be start disabled next job type
88       */
89      default Optional<String> getToBeStartDisabledNextJobType() {
90          return Optional.empty();
91      }
92      
93      /**
94       * Get to be stopped previous job type.
95       *
96       * @return to be stopped previous job type
97       */
98      default Optional<String> getToBeStoppedPreviousJobType() {
99          return Optional.empty();
100     }
101     
102     /**
103      * Whether to force no sharding when convert to job configuration POJO.
104      *
105      * @return without sharding or not
106      */
107     default boolean isForceNoShardingWhenConvertToJobConfigurationPOJO() {
108         return false;
109     }
110     
111     /**
112      * Get pipeline job info.
113      *
114      * @param jobId job ID
115      * @return pipeline job info
116      */
117     PipelineJobInfo getJobInfo(String jobId);
118     
119     /**
120      * Build pipeline data consistency checker.
121      *
122      * @param jobConfig job configuration
123      * @param processContext process context
124      * @param progressContext consistency check job item progress context
125      * @return all logic tables check result
126      */
127     PipelineDataConsistencyChecker buildDataConsistencyChecker(PipelineJobConfiguration jobConfig, TransmissionProcessContext processContext, ConsistencyCheckJobItemProgressContext progressContext);
128     
129     @Override
130     String getType();
131 }