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.config.PipelineJobConfiguration;
25  import org.apache.shardingsphere.data.pipeline.core.pojo.PipelineJobTarget;
26  import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
27  import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
28  
29  import java.util.Collection;
30  import java.util.Collections;
31  
32  /**
33   * Pipeline job type.
34   * 
35   * @param <T> type of pipeline job configuration
36   */
37  @SingletonSPI
38  @JsonIgnoreType
39  public interface PipelineJobType<T extends PipelineJobConfiguration> extends TypedSPI {
40      
41      /**
42       * Get pipeline job option.
43       *
44       * @return pipeline job option
45       */
46      PipelineJobOption getOption();
47      
48      /**
49       * Get pipeline job target.
50       *
51       * @param jobConfig pipeline job configuration
52       * @return pipeline job target
53       */
54      PipelineJobTarget getJobTarget(T jobConfig);
55      
56      /**
57       * Build pipeline data consistency checker.
58       *
59       * @param jobConfig pipeline job configuration
60       * @param processContext process context
61       * @param progressContext consistency check job item progress context
62       * @return all logic tables check result
63       * @throws UnsupportedOperationException unsupported operation exception
64       */
65      default PipelineDataConsistencyChecker buildDataConsistencyChecker(final T jobConfig,
66                                                                         final TransmissionProcessContext processContext, final ConsistencyCheckJobItemProgressContext progressContext) {
67          throw new UnsupportedOperationException("Build data consistency checker is not supported.");
68      }
69      
70      @Override
71      String getType();
72      
73      @Override
74      default Collection<Object> getTypeAliases() {
75          return Collections.singleton(getOption().getCode());
76      }
77  }