You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/11/14 11:16:25 UTC

[GitHub] [shardingsphere] azexcy opened a new pull request, #22171: Refactor migration inventory finished percentage

azexcy opened a new pull request, #22171:
URL: https://github.com/apache/shardingsphere/pull/22171

   
   
   Changes proposed in this pull request:
     - Refactor migration inventory finished percentage
     - Add unit test
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [ ] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the pull request.
   - [ ] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ] I have added corresponding unit tests for my changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz commented on a diff in pull request #22171: Refactor migration inventory finished percentage

Posted by GitBox <gi...@apache.org>.
sandynz commented on code in PR #22171:
URL: https://github.com/apache/shardingsphere/pull/22171#discussion_r1021396365


##########
kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/pojo/MigrationJobItemInfo.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.data.pipeline.api.pojo;
+
+import lombok.Getter;
+
+/**
+ * Migration job item info.
+ */
+@Getter
+public final class MigrationJobItemInfo extends InventoryIncrementalJobItemInfo {

Review Comment:
   Looks it's not necessary to create `MigrationJobItemInfo`, we could keep them in `InventoryIncrementalJobItemInfo` for common usage



##########
features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationJobStatusQueryResultSet.java:
##########
@@ -45,24 +45,19 @@ public final class ShowMigrationJobStatusQueryResultSet implements DatabaseDistS
     
     @Override
     public void init(final ShardingSphereDatabase database, final SQLStatement sqlStatement) {
-        long currentTimeMillis = System.currentTimeMillis();
         List<InventoryIncrementalJobItemInfo> jobItemInfos = JOB_API.getJobItemInfos(((ShowMigrationStatusStatement) sqlStatement).getJobId());
         data = jobItemInfos.stream().map(each -> {
+            MigrationJobItemInfo jobItemInfo = (MigrationJobItemInfo) each;
             Collection<Object> result = new LinkedList<>();
-            result.add(each.getShardingItem());
-            InventoryIncrementalJobItemProgress jobItemProgress = each.getJobItemProgress();
+            result.add(jobItemInfo.getShardingItem());
+            InventoryIncrementalJobItemProgress jobItemProgress = jobItemInfo.getJobItemProgress();

Review Comment:
   It's better to keep use `each` for common methods, it's enough



##########
features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationJobStatusQueryResultSet.java:
##########
@@ -45,24 +45,19 @@ public final class ShowMigrationJobStatusQueryResultSet implements DatabaseDistS
     
     @Override
     public void init(final ShardingSphereDatabase database, final SQLStatement sqlStatement) {
-        long currentTimeMillis = System.currentTimeMillis();
         List<InventoryIncrementalJobItemInfo> jobItemInfos = JOB_API.getJobItemInfos(((ShowMigrationStatusStatement) sqlStatement).getJobId());
         data = jobItemInfos.stream().map(each -> {
+            MigrationJobItemInfo jobItemInfo = (MigrationJobItemInfo) each;
             Collection<Object> result = new LinkedList<>();
-            result.add(each.getShardingItem());
-            InventoryIncrementalJobItemProgress jobItemProgress = each.getJobItemProgress();
+            result.add(jobItemInfo.getShardingItem());
+            InventoryIncrementalJobItemProgress jobItemProgress = jobItemInfo.getJobItemProgress();
             if (null != jobItemProgress) {
                 result.add(jobItemProgress.getDataSourceName());
                 result.add(jobItemProgress.getStatus());
                 result.add(jobItemProgress.isActive() ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
                 result.add(jobItemProgress.getProcessedRecordsCount());
-                result.add(jobItemProgress.getInventory().getInventoryFinishedPercentage());
-                String incrementalIdleSeconds = "";
-                if (jobItemProgress.getIncremental().getIncrementalLatestActiveTimeMillis() > 0) {
-                    long latestActiveTimeMillis = Math.max(each.getStartTimeMillis(), jobItemProgress.getIncremental().getIncrementalLatestActiveTimeMillis());
-                    incrementalIdleSeconds = String.valueOf(TimeUnit.MILLISECONDS.toSeconds(currentTimeMillis - latestActiveTimeMillis));
-                }
-                result.add(incrementalIdleSeconds);
+                result.add(jobItemInfo.getInventoryFinishedPercentage());
+                result.add(jobItemInfo.getIncrementalIdleSeconds());

Review Comment:
   It's `null != jobItemProgress` in if condition, but it use `jobItemInfo` here, it's not clear enough as before



##########
kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java:
##########
@@ -133,6 +137,32 @@ protected TableBasedPipelineJobInfo getJobInfo(final String jobId) {
         return new TableBasedPipelineJobInfo(jobMetaData, getJobConfiguration(jobConfigPOJO).getSourceTableName());
     }
     
+    @Override
+    public List<InventoryIncrementalJobItemInfo> getJobItemInfos(final String jobId) {

Review Comment:
   Could keep it in `AbstractInventoryIncrementalJobAPIImpl` and extend it for common usage



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz merged pull request #22171: Refactor migration inventory finished percentage

Posted by GitBox <gi...@apache.org>.
sandynz merged PR #22171:
URL: https://github.com/apache/shardingsphere/pull/22171


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] codecov-commenter commented on pull request #22171: Refactor migration inventory finished percentage

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #22171:
URL: https://github.com/apache/shardingsphere/pull/22171#issuecomment-1313589268

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/22171?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#22171](https://codecov.io/gh/apache/shardingsphere/pull/22171?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (fb9083b) into [master](https://codecov.io/gh/apache/shardingsphere/commit/f3cc852dcbba89244ffcaef15a03ebf29693a14d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f3cc852) will **decrease** coverage by `0.04%`.
   > The diff coverage is `32.07%`.
   
   > :exclamation: Current head fb9083b differs from pull request most recent head 91a1a14. Consider uploading reports for the commit 91a1a14 to get more accurate results
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #22171      +/-   ##
   ============================================
   - Coverage     61.01%   60.97%   -0.05%     
     Complexity     2544     2544              
   ============================================
     Files          4122     4123       +1     
     Lines         57393    57450      +57     
     Branches       9726     9737      +11     
   ============================================
   + Hits          35021    35029       +8     
   - Misses        19419    19462      +43     
   - Partials       2953     2959       +6     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/22171?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...er/query/ShowMigrationJobStatusQueryResultSet.java](https://codecov.io/gh/apache/shardingsphere/pull/22171/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvc2hhcmRpbmcvZGlzdHNxbC9oYW5kbGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9taWdyYXRpb24vZGlzdHNxbC9oYW5kbGVyL3F1ZXJ5L1Nob3dNaWdyYXRpb25Kb2JTdGF0dXNRdWVyeVJlc3VsdFNldC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...pi/job/progress/JobItemInventoryTasksProgress.java](https://codecov.io/gh/apache/shardingsphere/pull/22171/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL2FwaS9qb2IvcHJvZ3Jlc3MvSm9iSXRlbUludmVudG9yeVRhc2tzUHJvZ3Jlc3MuamF2YQ==) | `0.00% <ø> (ø)` | |
   | [...e/data/pipeline/api/pojo/MigrationJobItemInfo.java](https://codecov.io/gh/apache/shardingsphere/pull/22171/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL2FwaS9wb2pvL01pZ3JhdGlvbkpvYkl0ZW1JbmZvLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...peline/scenario/migration/MigrationJobAPIImpl.java](https://codecov.io/gh/apache/shardingsphere/pull/22171/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9zY2VuYXJpby9taWdyYXRpb24vTWlncmF0aW9uSm9iQVBJSW1wbC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...rdingsphere/transaction/ConnectionTransaction.java](https://codecov.io/gh/apache/shardingsphere/pull/22171/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL3RyYW5zYWN0aW9uL2NvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3RyYW5zYWN0aW9uL0Nvbm5lY3Rpb25UcmFuc2FjdGlvbi5qYXZh) | `52.00% <ø> (ø)` | |
   | [...ore/statement/ShardingSpherePreparedStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/22171/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-amRiYy9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kcml2ZXIvamRiYy9jb3JlL3N0YXRlbWVudC9TaGFyZGluZ1NwaGVyZVByZXBhcmVkU3RhdGVtZW50LmphdmE=) | `61.56% <39.39%> (-3.76%)` | :arrow_down: |
   | [...r/jdbc/core/statement/ShardingSphereStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/22171/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-amRiYy9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kcml2ZXIvamRiYy9jb3JlL3N0YXRlbWVudC9TaGFyZGluZ1NwaGVyZVN0YXRlbWVudC5qYXZh) | `50.00% <47.72%> (-2.09%)` | :arrow_down: |
   | [...handler/distsql/ral/hint/enums/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/22171/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmFsL2hpbnQvZW51bXMvSGludFNvdXJjZVR5cGUuamF2YQ==) | `42.85% <0.00%> (+42.85%)` | :arrow_up: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] azexcy commented on pull request #22171: Refactor migration inventory finished percentage

Posted by GitBox <gi...@apache.org>.
azexcy commented on PR #22171:
URL: https://github.com/apache/shardingsphere/pull/22171#issuecomment-1313527800

   ```
   mysql> show migration status 'j0101395cd93b2cfc189f29958b8a0342e882';
   +------+-------------+------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   | item | data_source | status                 | active | processed_records_count | inventory_finished_percentage | incremental_idle_seconds | error_message |
   +------+-------------+------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   | 0    | sysbench_ds | EXECUTE_INVENTORY_TASK | true   | 1812000                 | 9                             |                          |               |
   +------+-------------+------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   1 row in set (0.02 sec)
   
   mysql> show migration status 'j0101395cd93b2cfc189f29958b8a0342e882';
   +------+-------------+------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   | item | data_source | status                 | active | processed_records_count | inventory_finished_percentage | incremental_idle_seconds | error_message |
   +------+-------------+------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   | 0    | sysbench_ds | EXECUTE_INVENTORY_TASK | true   | 10864000                | 54                            |                          |               |
   +------+-------------+------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   1 row in set (0.17 sec)
   
   mysql> show migration status 'j0101395cd93b2cfc189f29958b8a0342e882';
   +------+-------------+------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   | item | data_source | status                 | active | processed_records_count | inventory_finished_percentage | incremental_idle_seconds | error_message |
   +------+-------------+------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   | 0    | sysbench_ds | EXECUTE_INVENTORY_TASK | true   | 19996000                | 99                            |                          |               |
   +------+-------------+------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   1 row in set (0.05 sec)
   
   mysql> show migration status 'j0101395cd93b2cfc189f29958b8a0342e882';
   +------+-------------+--------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   | item | data_source | status                   | active | processed_records_count | inventory_finished_percentage | incremental_idle_seconds | error_message |
   +------+-------------+--------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   | 0    | sysbench_ds | EXECUTE_INCREMENTAL_TASK | true   | 20000000                | 100                           |                          |               |
   +------+-------------+--------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+
   1 row in set (0.03 sec)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org