kezhenxu94 commented on a change in pull request #6850:
URL: https://github.com/apache/dolphinscheduler/pull/6850#discussion_r749350711
##########
File path:
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerService.java
##########
@@ -175,81 +185,124 @@ public void run() {
/**
* 1. get command by slot
* 2. donot handle command if slot is empty
- *
- * @throws Exception
*/
private void scheduleProcess() throws Exception {
+ List<Command> commands = findCommands();
+ if (CollectionUtils.isEmpty(commands)) {
+ //indicate that no command ,sleep for 1s
+ Thread.sleep(Constants.SLEEP_TIME_MILLIS);
+ return;
+ }
- // make sure to scan and delete command table in one transaction
- Command command = findOneCommand();
- if (command != null) {
- logger.info("find one command: id: {}, type: {}", command.getId(),
command.getCommandType());
- try {
- ProcessInstance processInstance =
processService.handleCommand(logger,
- getLocalAddress(),
- command,
- processDefinitionCacheMaps);
- if (!masterConfig.isCacheProcessDefinition()
- && processDefinitionCacheMaps.size() > 0) {
- processDefinitionCacheMaps.clear();
+ if (!masterConfig.isCacheProcessDefinition() &&
processDefinitionCacheMaps.size() > 0) {
+ processDefinitionCacheMaps.clear();
+ }
+
+ List<ProcessInstance> processInstances =
command2ProcessInstance(commands);
+ if (CollectionUtils.isEmpty(processInstances)) {
+ return;
+ }
+
+ for (ProcessInstance processInstance : processInstances) {
+ if (processInstance == null) {
+ continue;
+ }
+
+ WorkflowExecuteThread workflowExecuteThread = new
WorkflowExecuteThread(
+ processInstance
+ , processService
+ , nettyExecutorManager
+ , processAlertManager
+ , masterConfig
+ , taskTimeoutCheckList);
+
+
this.processInstanceExecCacheManager.cache(processInstance.getId(),
workflowExecuteThread);
+ if (processInstance.getTimeout() > 0) {
+ this.processTimeoutCheckList.put(processInstance.getId(),
processInstance);
+ }
+ masterExecService.execute(workflowExecuteThread);
+ }
+ }
+
+ private List<ProcessInstance> command2ProcessInstance(List<Command>
commands) {
+ if (CollectionUtils.isEmpty(commands)) {
+ return null;
+ }
+
+ List<ProcessInstance> processInstances = new
ArrayList<>(commands.size());
+ CountDownLatch latch = new CountDownLatch(commands.size());
+ for (int i = 0; i < commands.size(); i++) {
+ int index = i;
+ this.masterPrepareExecService.execute(() -> {
+ Command command = commands.get(index);
+ // slot check again
+ if (!slotCheck(command)) {
+ return;
Review comment:
The `latch` is not counted down in this branch
--
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]