From 40db991d5fe04fed7c0d177c03f9cde6ed9ef8d4 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Fri, 29 Nov 2024 14:00:10 +0530 Subject: [PATCH 1/3] Make Sub workflow Priority Object to support parametrised priority --- .../common/metadata/workflow/SubWorkflowParams.java | 6 +++--- .../core/execution/mapper/SubWorkflowTaskMapper.java | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java b/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java index d17378862..ce4fe4fd8 100644 --- a/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java +++ b/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java @@ -46,7 +46,7 @@ public class SubWorkflowParams { private IdempotencyStrategy idempotencyStrategy; // Priority of the sub workflow, not set inherits from the parent - private Integer priority; + private Object priority; public String getIdempotencyKey() { return idempotencyKey; @@ -64,11 +64,11 @@ public void setIdempotencyStrategy(IdempotencyStrategy idempotencyStrategy) { this.idempotencyStrategy = idempotencyStrategy; } - public Integer getPriority() { + public Object getPriority() { return priority; } - public void setPriority(Integer priority) { + public void setPriority(Object priority) { this.priority = priority; } diff --git a/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java b/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java index fae54660b..f59d67364 100644 --- a/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java +++ b/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java @@ -14,6 +14,7 @@ import java.util.*; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -83,8 +84,9 @@ public List getMappedTasks(TaskMapperContext taskMapperContext) { subWorkflowTask.addInput("workflowInput", taskMapperContext.getTaskInput()); subWorkflowTask.setStatus(TaskModel.Status.SCHEDULED); subWorkflowTask.setCallbackAfterSeconds(workflowTask.getStartDelay()); - if (subWorkflowParams.getPriority() != null) { - subWorkflowTask.setWorkflowPriority(subWorkflowParams.getPriority()); + if (subWorkflowParams.getPriority() != null && !StringUtils.isEmpty(subWorkflowParams.getPriority().toString())) { + int priority = Integer.parseInt(subWorkflowParams.getPriority().toString()); + subWorkflowTask.setWorkflowPriority(priority); } LOGGER.debug("SubWorkflowTask {} created to be Scheduled", subWorkflowTask); return List.of(subWorkflowTask); From 8f81e81c2cc74c86724c9ebd528e5dd3bbdec4b6 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Fri, 29 Nov 2024 14:03:35 +0530 Subject: [PATCH 2/3] changes --- .../conductor/core/execution/mapper/SubWorkflowTaskMapper.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java b/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java index f59d67364..7340d36f1 100644 --- a/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java +++ b/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java @@ -78,6 +78,7 @@ public List getMappedTasks(TaskMapperContext taskMapperContext) { TaskModel subWorkflowTask = taskMapperContext.createTaskModel(); subWorkflowTask.setTaskType(TASK_TYPE_SUB_WORKFLOW); subWorkflowTask.addInput("subWorkflowName", subWorkflowName); + subWorkflowTask.addInput("priority", resolvedParams.get("priority")); subWorkflowTask.addInput("subWorkflowVersion", subWorkflowVersion); subWorkflowTask.addInput("subWorkflowTaskToDomain", subWorkflowTaskToDomain); subWorkflowTask.addInput("subWorkflowDefinition", subWorkflowDefinition); @@ -111,6 +112,7 @@ private Map getSubWorkflowInputParameters( WorkflowModel workflowModel, SubWorkflowParams subWorkflowParams) { Map params = new HashMap<>(); params.put("name", subWorkflowParams.getName()); + params.put("priority", subWorkflowParams.getPriority()); Integer version = subWorkflowParams.getVersion(); if (version != null) { From 33d42ab8a3a41b6e03eb61938cf1342aa4d86e56 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Fri, 29 Nov 2024 14:08:23 +0530 Subject: [PATCH 3/3] spotless --- .../conductor/core/execution/mapper/SubWorkflowTaskMapper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java b/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java index 7340d36f1..3b4630c7c 100644 --- a/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java +++ b/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java @@ -85,7 +85,8 @@ public List getMappedTasks(TaskMapperContext taskMapperContext) { subWorkflowTask.addInput("workflowInput", taskMapperContext.getTaskInput()); subWorkflowTask.setStatus(TaskModel.Status.SCHEDULED); subWorkflowTask.setCallbackAfterSeconds(workflowTask.getStartDelay()); - if (subWorkflowParams.getPriority() != null && !StringUtils.isEmpty(subWorkflowParams.getPriority().toString())) { + if (subWorkflowParams.getPriority() != null + && !StringUtils.isEmpty(subWorkflowParams.getPriority().toString())) { int priority = Integer.parseInt(subWorkflowParams.getPriority().toString()); subWorkflowTask.setWorkflowPriority(priority); }