You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/10/10 08:35:22 UTC

[shardingsphere] branch master updated: Remove setter of DataConsistencyCheckAlgorithmInfo (#21448)

This is an automated email from the ASF dual-hosted git repository.

sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 5793ac7a636 Remove setter of DataConsistencyCheckAlgorithmInfo (#21448)
5793ac7a636 is described below

commit 5793ac7a636824fefb9d03661cf4594ac1c49264
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Oct 10 16:35:13 2022 +0800

    Remove setter of DataConsistencyCheckAlgorithmInfo (#21448)
    
    * Revise javadoc
    
    * Remove setter of DataConsistencyCheckAlgorithmInfo
    
    * Remove useless @ToString
    
    * Replace sequence
---
 .../data/pipeline/api/PipelineJobPublicAPI.java      |  2 +-
 .../api/pojo/CreateConsistencyCheckJobParameter.java |  2 +-
 .../api/pojo/CreateMigrationJobParameter.java        |  2 +-
 .../api/pojo/DataConsistencyCheckAlgorithmInfo.java  | 12 +++++-------
 .../impl/AbstractInventoryIncrementalJobAPIImpl.java | 20 +++++++-------------
 5 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/PipelineJobPublicAPI.java b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/PipelineJobPublicAPI.java
index 1b635825c7e..c4e76b72991 100644
--- a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/PipelineJobPublicAPI.java
+++ b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/PipelineJobPublicAPI.java
@@ -51,7 +51,7 @@ public interface PipelineJobPublicAPI {
     /**
      * Get pipeline job info.
      *
-     * @return jobInfos
+     * @return job info list
      */
     List<? extends PipelineJobInfo> list();
 }
diff --git a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/CreateConsistencyCheckJobParameter.java b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/CreateConsistencyCheckJobParameter.java
index deaf027368a..ab9d1923e5d 100644
--- a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/CreateConsistencyCheckJobParameter.java
+++ b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/CreateConsistencyCheckJobParameter.java
@@ -25,8 +25,8 @@ import java.util.Properties;
 /**
  * Create consistency check job parameter.
  */
-@Data
 @RequiredArgsConstructor
+@Data
 public final class CreateConsistencyCheckJobParameter {
     
     private final String jobId;
diff --git a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/CreateMigrationJobParameter.java b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/CreateMigrationJobParameter.java
index f4a55d5811e..20967194e0e 100644
--- a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/CreateMigrationJobParameter.java
+++ b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/CreateMigrationJobParameter.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.data.pipeline.api.pojo;
 import lombok.Data;
 import lombok.RequiredArgsConstructor;
 
-@Data
 @RequiredArgsConstructor
+@Data
 public final class CreateMigrationJobParameter {
     
     private final String sourceResourceName;
diff --git a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/DataConsistencyCheckAlgorithmInfo.java b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/DataConsistencyCheckAlgorithmInfo.java
index aaea9a4739f..c1d62b143cd 100644
--- a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/DataConsistencyCheckAlgorithmInfo.java
+++ b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/DataConsistencyCheckAlgorithmInfo.java
@@ -18,22 +18,20 @@
 package org.apache.shardingsphere.data.pipeline.api.pojo;
 
 import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
+import lombok.RequiredArgsConstructor;
 
 import java.util.Collection;
 
 /**
  * Data consistency check algorithm info.
  */
+@RequiredArgsConstructor
 @Getter
-@Setter
-@ToString
 public final class DataConsistencyCheckAlgorithmInfo {
     
-    private String type;
+    private final String type;
     
-    private String description;
+    private final Collection<String> supportedDatabaseTypes;
     
-    private Collection<String> supportedDatabaseTypes;
+    private final String description;
 }
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractInventoryIncrementalJobAPIImpl.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractInventoryIncrementalJobAPIImpl.java
index b98eb85cf8f..2881877cbe6 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractInventoryIncrementalJobAPIImpl.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractInventoryIncrementalJobAPIImpl.java
@@ -141,23 +141,17 @@ public abstract class AbstractInventoryIncrementalJobAPIImpl extends AbstractPip
     @Override
     public Collection<DataConsistencyCheckAlgorithmInfo> listDataConsistencyCheckAlgorithms() {
         checkModeConfig();
-        return DataConsistencyCalculateAlgorithmFactory.getAllInstances().stream().map(each -> {
-            DataConsistencyCheckAlgorithmInfo result = new DataConsistencyCheckAlgorithmInfo();
-            result.setType(each.getType());
-            result.setDescription(each.getDescription());
-            result.setSupportedDatabaseTypes(each.getSupportedDatabaseTypes());
-            return result;
-        }).collect(Collectors.toList());
+        return DataConsistencyCalculateAlgorithmFactory.getAllInstances().stream()
+                .map(each -> new DataConsistencyCheckAlgorithmInfo(each.getType(), each.getSupportedDatabaseTypes(), each.getDescription())).collect(Collectors.toList());
     }
     
     @Override
     public DataConsistencyCalculateAlgorithm buildDataConsistencyCalculateAlgorithm(final PipelineJobConfiguration jobConfig, final String algorithmType, final Properties algorithmProps) {
-        ShardingSpherePreconditions.checkState(null != algorithmType || null != jobConfig, () -> new IllegalArgumentException("algorithmType and jobConfig are null"));
-        if (null != algorithmType) {
-            return DataConsistencyCalculateAlgorithmFactory.newInstance(algorithmType, algorithmProps);
-        }
-        return DataConsistencyCalculateAlgorithmChooser.choose(
-                DatabaseTypeFactory.getInstance(jobConfig.getSourceDatabaseType()), DatabaseTypeFactory.getInstance(getTargetDatabaseType(jobConfig)));
+        ShardingSpherePreconditions.checkState(null != algorithmType || null != jobConfig, () -> new IllegalArgumentException("Algorithm type and job configuration are null."));
+        return null == algorithmType
+                ? DataConsistencyCalculateAlgorithmChooser.choose(
+                        DatabaseTypeFactory.getInstance(jobConfig.getSourceDatabaseType()), DatabaseTypeFactory.getInstance(getTargetDatabaseType(jobConfig)))
+                : DataConsistencyCalculateAlgorithmFactory.newInstance(algorithmType, algorithmProps);
     }
     
     @Override