Skip to content

Commit

Permalink
fix apache#16768: Add schedule time parameter to sub-workflow instance
Browse files Browse the repository at this point in the history
  • Loading branch information
reele committed Nov 5, 2024
1 parent 5b93e15 commit c7432f5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.Command;
import org.apache.dolphinscheduler.dao.entity.WorkflowDefinition;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import org.apache.dolphinscheduler.dao.utils.EnvironmentUtils;
import org.apache.dolphinscheduler.dao.utils.WorkerGroupUtils;
import org.apache.dolphinscheduler.extract.master.command.RunWorkflowCommandParam;
import org.apache.dolphinscheduler.server.master.engine.workflow.trigger.AbstractWorkflowTrigger;

import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Date;
Expand Down Expand Up @@ -87,12 +88,24 @@ protected WorkflowInstance constructWorkflowInstance(final SubWorkflowTriggerReq
@Override
protected Command constructTriggerCommand(final SubWorkflowTriggerRequest subWorkflowTriggerRequest,
final WorkflowInstance workflowInstance) {
throw new NotImplementedException();
final RunWorkflowCommandParam runWorkflowCommandParam = RunWorkflowCommandParam.builder()
.commandParams(subWorkflowTriggerRequest.getStartParamList())
.startNodes(subWorkflowTriggerRequest.getStartNodes())
.timeZone(DateUtils.getTimezone())
.build();
return Command.builder()
.commandType(CommandType.START_PROCESS)
.workflowDefinitionCode(subWorkflowTriggerRequest.getWorkflowDefinitionCode())
.workflowDefinitionVersion(subWorkflowTriggerRequest.getWorkflowDefinitionVersion())
.workflowInstanceId(workflowInstance.getId())
.workflowInstancePriority(workflowInstance.getWorkflowInstancePriority())
.commandParam(JSONUtils.toJsonString(runWorkflowCommandParam))
.build();
}

@Override
protected SubWorkflowTriggerResponse onTriggerSuccess(WorkflowInstance workflowInstance) {
throw new NotImplementedException();
return SubWorkflowTriggerResponse.success(workflowInstance.getId());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@

package org.apache.dolphinscheduler.server.master.runner.task.subworkflow.trigger;

import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.TaskDependType;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.plugin.task.api.model.Property;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.apache.dolphinscheduler.server.master.runner.task.subworkflow.trigger;

import org.apache.commons.lang3.NotImplementedException;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -37,11 +35,17 @@ public class SubWorkflowTriggerResponse {
private Integer workflowInstanceId;

public static SubWorkflowTriggerResponse fail(String message) {
throw new NotImplementedException();
return SubWorkflowTriggerResponse.builder()
.success(false)
.message(message)
.build();
}

public static SubWorkflowTriggerResponse success(Integer workflowInstanceId) {
throw new NotImplementedException();
return SubWorkflowTriggerResponse.builder()
.success(true)
.workflowInstanceId(workflowInstanceId)
.build();
}

}

0 comments on commit c7432f5

Please sign in to comment.