Browse Source

[Fix-6478] [Server] Fix the lack of scheduling time in complement parallelism mode (#6491)

* fix missing history data

* update code style

* update ExecutorServiceTest test class.
3.0.0/version-upgrade
Kerwin 3 years ago committed by GitHub
parent
commit
88690462b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
  2. 31
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
  3. 1
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/cron/CronUtils.java

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java

@ -604,15 +604,15 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
createCount = Math.min(listDate.size(), expectedParallelismNumber);
}
logger.info("In parallel mode, current expectedParallelismNumber:{}", createCount);
listDate.addLast(end);
int chunkSize = listDate.size() / createCount;
for (int i = 0; i < createCount; i++) {
int rangeStart = i == 0 ? i : (i * chunkSize);
int rangeEnd = i == createCount - 1 ? listDate.size() - 1
: rangeStart + chunkSize;
if (rangeEnd == listDate.size()) {
rangeEnd = listDate.size() - 1;
}
cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(listDate.get(rangeStart)));
cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(listDate.get(rangeEnd)));
command.setCommandParam(JSONUtils.toJsonString(cmdParam));

31
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java

@ -58,12 +58,15 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* executor service 2 test
*/
@RunWith(MockitoJUnitRunner.Silent.class)
public class ExecutorServiceTest {
private static final Logger logger = LoggerFactory.getLogger(ExecutorServiceTest.class);
@InjectMocks
private ExecutorServiceImpl executorService;
@ -326,4 +329,32 @@ public class ExecutorServiceTest {
result.put(Constants.STATUS, Status.SUCCESS);
return result;
}
@Test
public void testCreateComplementToParallel() {
List<String> result = new ArrayList<>();
int expectedParallelismNumber = 3;
LinkedList<Integer> listDate = new LinkedList<>();
listDate.add(0);
listDate.add(1);
listDate.add(2);
listDate.add(3);
int createCount = Math.min(listDate.size(), expectedParallelismNumber);
logger.info("In parallel mode, current expectedParallelismNumber:{}", createCount);
listDate.addLast(4);
int chunkSize = listDate.size() / createCount;
for (int i = 0; i < createCount; i++) {
int rangeStart = i == 0 ? i : (i * chunkSize);
int rangeEnd = i == createCount - 1 ? listDate.size() - 1 : rangeStart + chunkSize;
logger.info("rangeStart:{}, rangeEnd:{}",rangeStart, rangeEnd);
result.add(listDate.get(rangeStart) + "," + listDate.get(rangeEnd));
}
Assert.assertEquals("0,1", result.get(0));
Assert.assertEquals("1,2", result.get(1));
Assert.assertEquals("2,4", result.get(2));
}
}

1
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/cron/CronUtils.java

@ -190,6 +190,7 @@ public class CronUtils {
return result;
}
// support left closed and right open time interval (startDate <= N < endDate)
Date from = new Date(startTime.getTime() - Constants.SECOND_TIME_MILLIS);
Date to = new Date(endTime.getTime() - Constants.SECOND_TIME_MILLIS);

Loading…
Cancel
Save