SbloodyS commented on code in PR #10376:
URL: https://github.com/apache/dolphinscheduler/pull/10376#discussion_r893015000


##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java:
##########
@@ -17,12 +17,7 @@
 
 package org.apache.dolphinscheduler.server.master.runner;
 
-import static 
org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE;
-import static 
org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE;
-import static 
org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVERY_START_NODE_STRING;
-import static 
org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING;
-import static 
org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODES;
-import static 
org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP;
+import static org.apache.dolphinscheduler.common.Constants.*;

Review Comment:
   Same here.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java:
##########
@@ -75,13 +71,7 @@
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;

Review Comment:
   Same here.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java:
##########
@@ -740,45 +729,24 @@ protected int createComplementCommandList(Date start, 
Date end, RunMode runMode,
                         }
                     }
                     logger.info("In parallel mode, current 
expectedParallelismNumber:{}", createCount);
-
                     // Distribute the number of tasks equally to each command.
                     // The last command with insufficient quantity will be 
assigned to the remaining tasks.
-                    int itemsPerCommand = (listDateSize / createCount);
-                    int remainingItems = (listDateSize % createCount);
-                    int startDateIndex = 0;
-                    int endDateIndex = 0;
-
-                    for (int i = 1; i <= createCount; i++) {
-                        int extra = (i <= remainingItems) ? 1 : 0;
-                        int singleCommandItems = (itemsPerCommand + extra);
-
-                        if (i == 1) {
-                            endDateIndex += singleCommandItems - 1;
-                        } else {
-                            startDateIndex = endDateIndex + 1;
-                            endDateIndex += singleCommandItems;
+                    for(List<String> stringDate : 
Lists.partition(listDate,createCount)){
+                        String tempDate = "";
+                        for(String date : stringDate){
+                            tempDate  += date +",";

Review Comment:
   It's recommanded to format this line.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java:
##########
@@ -18,13 +18,9 @@
 package org.apache.dolphinscheduler.api.service.impl;
 
 import static 
org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_START;
-import static 
org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE;
-import static 
org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE;
-import static 
org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING;
-import static 
org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODES;
-import static 
org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_PARAMS;
-import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT;
+import static org.apache.dolphinscheduler.common.Constants.*;

Review Comment:
   Please avoid import *



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java:
##########
@@ -740,45 +729,24 @@ protected int createComplementCommandList(Date start, 
Date end, RunMode runMode,
                         }
                     }
                     logger.info("In parallel mode, current 
expectedParallelismNumber:{}", createCount);
-
                     // Distribute the number of tasks equally to each command.
                     // The last command with insufficient quantity will be 
assigned to the remaining tasks.
-                    int itemsPerCommand = (listDateSize / createCount);
-                    int remainingItems = (listDateSize % createCount);
-                    int startDateIndex = 0;
-                    int endDateIndex = 0;
-
-                    for (int i = 1; i <= createCount; i++) {
-                        int extra = (i <= remainingItems) ? 1 : 0;
-                        int singleCommandItems = (itemsPerCommand + extra);
-
-                        if (i == 1) {
-                            endDateIndex += singleCommandItems - 1;
-                        } else {
-                            startDateIndex = endDateIndex + 1;
-                            endDateIndex += singleCommandItems;
+                    for(List<String> stringDate : 
Lists.partition(listDate,createCount)){
+                        String tempDate = "";
+                        for(String date : stringDate){
+                            tempDate  += date +",";
                         }
-
-                        cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, 
DateUtils.dateToString(listDate.get(startDateIndex)));
-                        cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, 
DateUtils.dateToString(listDate.get(endDateIndex)));
+                        cmdParam.put(CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE, 
tempDate.substring(0,tempDate.length() - 1));
                         
command.setCommandParam(JSONUtils.toJsonString(cmdParam));
                         processService.createCommand(command);
-
-                        if (schedules.isEmpty() || complementDependentMode == 
ComplementDependentMode.OFF_MODE) {
-                            logger.info("process code: {} complement dependent 
in off mode or schedule's size is 0, skip "
-                                    + "dependent complement data", 
command.getProcessDefinitionCode());
-                        } else {
-                            dependentProcessDefinitionCreateCount += 
createComplementDependentCommand(schedules, command);
-                        }

Review Comment:
   Why did you remove this? It may cause complement dependent process error.



##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/corn/CronUtils.java:
##########
@@ -35,13 +34,9 @@
 import org.apache.commons.collections.CollectionUtils;
 
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
+import java.util.*;

Review Comment:
   Same here.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java:
##########
@@ -740,45 +729,24 @@ protected int createComplementCommandList(Date start, 
Date end, RunMode runMode,
                         }
                     }
                     logger.info("In parallel mode, current 
expectedParallelismNumber:{}", createCount);
-
                     // Distribute the number of tasks equally to each command.
                     // The last command with insufficient quantity will be 
assigned to the remaining tasks.
-                    int itemsPerCommand = (listDateSize / createCount);
-                    int remainingItems = (listDateSize % createCount);
-                    int startDateIndex = 0;
-                    int endDateIndex = 0;
-
-                    for (int i = 1; i <= createCount; i++) {
-                        int extra = (i <= remainingItems) ? 1 : 0;
-                        int singleCommandItems = (itemsPerCommand + extra);
-
-                        if (i == 1) {
-                            endDateIndex += singleCommandItems - 1;
-                        } else {
-                            startDateIndex = endDateIndex + 1;
-                            endDateIndex += singleCommandItems;
+                    for(List<String> stringDate : 
Lists.partition(listDate,createCount)){
+                        String tempDate = "";
+                        for(String date : stringDate){
+                            tempDate  += date +",";
                         }
-
-                        cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, 
DateUtils.dateToString(listDate.get(startDateIndex)));
-                        cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, 
DateUtils.dateToString(listDate.get(endDateIndex)));
+                        cmdParam.put(CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE, 
tempDate.substring(0,tempDate.length() - 1));

Review Comment:
   I think using it's a little confusing using ```substring``` to remove the 
last comma. Is it more elegant to use ```String.join(",", tmpDateList)``` ?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to