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

zhonghongsheng 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 7b322b2  Optimize the return content of the `show scaling list` and 
`show scaling status {JobId}` commands of Scaling DistSQL (#14268)
7b322b2 is described below

commit 7b322b22a68593b054d99e8b393d98159242e871
Author: ReyYang <[email protected]>
AuthorDate: Thu Dec 23 17:25:42 2021 +0800

    Optimize the return content of the `show scaling list` and `show scaling 
status {JobId}` commands of Scaling DistSQL (#14268)
---
 .../data/pipeline/api/job/progress/JobProgress.java            |  2 ++
 .../data/pipeline/core/api/impl/PipelineJobAPIImpl.java        | 10 ++++++++--
 .../distsql/handler/ShowScalingJobStatusQueryResultSet.java    |  3 ++-
 .../scaling/distsql/handler/ShowScalingListQueryResultSet.java |  2 +-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/api/job/progress/JobProgress.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/api/job/progress/JobProgress.java
index 9d31d0e..df70f90 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/api/job/progress/JobProgress.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/api/job/progress/JobProgress.java
@@ -43,6 +43,8 @@ public final class JobProgress {
     
     private String sourceDatabaseType;
     
+    private boolean active;
+    
     private Map<String, InventoryTaskProgress> inventoryTaskProgressMap;
     
     private Map<String, IncrementalTaskProgress> incrementalTaskProgressMap;
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/PipelineJobAPIImpl.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/PipelineJobAPIImpl.java
index 3e942c8..5ce51ef 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/PipelineJobAPIImpl.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/PipelineJobAPIImpl.java
@@ -184,8 +184,14 @@ public final class PipelineJobAPIImpl implements 
PipelineJobAPI {
     
     @Override
     public Map<Integer, JobProgress> getProgress(final long jobId) {
-        return IntStream.range(0, 
getJobConfig(jobId).getHandleConfig().getJobShardingCount()).boxed()
-                .collect(LinkedHashMap::new, (map, each) -> map.put(each, 
PipelineAPIFactory.getGovernanceRepositoryAPI().getJobProgress(jobId, each)), 
LinkedHashMap::putAll);
+        return IntStream.range(0, 
getJobConfig(jobId).getHandleConfig().getJobShardingCount()).boxed().collect(LinkedHashMap::new,
 (map, each) -> {
+            JobProgress jobProgress = 
PipelineAPIFactory.getGovernanceRepositoryAPI().getJobProgress(jobId, each);
+            JobConfigurationPOJO jobConfigPOJO = 
getElasticJobConfigPOJO(jobId);
+            if (jobProgress != null) {
+                jobProgress.setActive(!jobConfigPOJO.isDisabled());
+            }
+            map.put(each, jobProgress);
+        }, LinkedHashMap::putAll);
     }
     
     @Override
diff --git 
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/ShowScalingJobStatusQueryResultSet.java
 
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/ShowScalingJobStatusQueryResultSet.java
index e763dcb..63cd890 100644
--- 
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/ShowScalingJobStatusQueryResultSet.java
+++ 
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/ShowScalingJobStatusQueryResultSet.java
@@ -47,6 +47,7 @@ public final class ShowScalingJobStatusQueryResultSet 
implements DistSQLResultSe
                     if (null != entry.getValue()) {
                         list.add(entry.getValue().getDataSource());
                         list.add(entry.getValue().getStatus());
+                        list.add(entry.getValue().isActive() ? "true" : 
"false");
                         
list.add(entry.getValue().getInventoryFinishedPercentage());
                         long latestActiveTimeMillis = 
entry.getValue().getIncrementalLatestActiveTimeMillis();
                         list.add(latestActiveTimeMillis > 0 ? 
TimeUnit.MILLISECONDS.toMinutes(currentTimeMillis - latestActiveTimeMillis) : 
0);
@@ -62,7 +63,7 @@ public final class ShowScalingJobStatusQueryResultSet 
implements DistSQLResultSe
     
     @Override
     public Collection<String> getColumnNames() {
-        return Arrays.asList("item", "data_source", "status", 
"inventory_finished_percentage", "incremental_idle_minutes");
+        return Arrays.asList("item", "data_source", "status", "active", 
"inventory_finished_percentage", "incremental_idle_minutes");
     }
     
     @Override
diff --git 
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/ShowScalingListQueryResultSet.java
 
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/ShowScalingListQueryResultSet.java
index e4a6c04..4a02b00 100644
--- 
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/ShowScalingListQueryResultSet.java
+++ 
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/ShowScalingListQueryResultSet.java
@@ -44,7 +44,7 @@ public final class ShowScalingListQueryResultSet implements 
DistSQLResultSet {
                     list.add(each.getJobId());
                     list.add(each.getTables());
                     list.add(each.getShardingTotalCount());
-                    list.add(each.isActive() ? 1 : 0);
+                    list.add(each.isActive() ? "true" : "false");
                     list.add(each.getCreateTime());
                     list.add(each.getStopTime());
                     return list;

Reply via email to