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 12:37:36 UTC

[shardingsphere] branch master updated: Refactor TableBasedPipelineJobInfo (#21459)

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 74a1c1a1c46 Refactor TableBasedPipelineJobInfo (#21459)
74a1c1a1c46 is described below

commit 74a1c1a1c461f7ce834ba5cceb2bbd2304fe5604
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Oct 10 20:37:24 2022 +0800

    Refactor TableBasedPipelineJobInfo (#21459)
    
    * Refactor TableBasedPipelineJobInfo
---
 .../handler/query/ShowMigrationListQueryResultSet.java       | 12 +++++++-----
 .../data/pipeline/api/pojo/TableBasedPipelineJobInfo.java    |  7 +++----
 .../pipeline/scenario/migration/MigrationJobAPIImpl.java     |  3 +--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationListQueryResultSet.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationListQueryResultSet.java
index 65125ef9ceb..61552520961 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationListQueryResultSet.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationListQueryResultSet.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.migration.distsql.handler.query;
 
 import org.apache.shardingsphere.data.pipeline.api.MigrationJobPublicAPI;
 import org.apache.shardingsphere.data.pipeline.api.PipelineJobPublicAPIFactory;
+import org.apache.shardingsphere.data.pipeline.api.pojo.PipelineJobMetaData;
 import org.apache.shardingsphere.data.pipeline.api.pojo.TableBasedPipelineJobInfo;
 import org.apache.shardingsphere.infra.distsql.query.DatabaseDistSQLResultSet;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -45,12 +46,13 @@ public final class ShowMigrationListQueryResultSet implements DatabaseDistSQLRes
         data = JOB_API.list().stream()
                 .map(each -> {
                     Collection<Object> result = new LinkedList<>();
-                    result.add(each.getJobId());
+                    PipelineJobMetaData jobMetaData = each.getJobMetaData();
+                    result.add(jobMetaData.getJobId());
                     result.add(((TableBasedPipelineJobInfo) each).getTable());
-                    result.add(each.getShardingTotalCount());
-                    result.add(each.isActive() ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
-                    result.add(each.getCreateTime());
-                    result.add(each.getStopTime());
+                    result.add(jobMetaData.getShardingTotalCount());
+                    result.add(jobMetaData.isActive() ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
+                    result.add(jobMetaData.getCreateTime());
+                    result.add(jobMetaData.getStopTime());
                     return result;
                 }).collect(Collectors.toList()).iterator();
     }
diff --git a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/TableBasedPipelineJobInfo.java b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/TableBasedPipelineJobInfo.java
index 2fc2aaa7104..38e463461ac 100644
--- a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/TableBasedPipelineJobInfo.java
+++ b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/TableBasedPipelineJobInfo.java
@@ -18,22 +18,21 @@
 package org.apache.shardingsphere.data.pipeline.api.pojo;
 
 import lombok.Getter;
-import lombok.Setter;
 import lombok.ToString;
 
 /**
  * Table based pipeline job info.
  */
 @Getter
-@Setter
 @ToString(callSuper = true)
 public final class TableBasedPipelineJobInfo implements PipelineJobInfo {
     
     private final PipelineJobMetaData jobMetaData;
     
-    private String table;
+    private final String table;
     
-    public TableBasedPipelineJobInfo(final String jobId) {
+    public TableBasedPipelineJobInfo(final String jobId, final String table) {
         jobMetaData = new PipelineJobMetaData(jobId);
+        this.table = table;
     }
 }
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
index 63fc1833583..89be8af7148 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
@@ -124,10 +124,9 @@ public final class MigrationJobAPIImpl extends AbstractInventoryIncrementalJobAP
     
     @Override
     protected TableBasedPipelineJobInfo getJobInfo(final String jobId) {
-        TableBasedPipelineJobInfo result = new TableBasedPipelineJobInfo(jobId);
         JobConfigurationPOJO jobConfigPOJO = getElasticJobConfigPOJO(jobId);
+        TableBasedPipelineJobInfo result = new TableBasedPipelineJobInfo(jobId, getJobConfiguration(jobConfigPOJO).getSourceTableName());
         fillJobMetaData(result.getJobMetaData(), jobConfigPOJO);
-        result.setTable(getJobConfiguration(jobConfigPOJO).getSourceTableName());
         return result;
     }