-
Notifications
You must be signed in to change notification settings - Fork 232
✨ 新功能 实现普通节点的一拖多/多对一的分支并行处理 #600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
swfnotswift
wants to merge
16
commits into
ModelEngine-Group:hzjh-main
Choose a base branch
from
swfnotswift:swf
base: hzjh-main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
66993f7
Merge pull request #1 from ModelEngine-Group/main
swfnotswift 6a6942e
修改前端代码
3dd9244
修改后端代码,实现条件流程校验阶段对多节点的支持
9d7fc0f
修改后端代码,实现条件流程校验阶段对多节点的支持
851f414
修改前端代码,新增放开连线限制按钮
35a7bf2
根据PR修复部分代码
793d668
重构merge节点逻辑
aa2ba28
重写前端页面,用户无法通过按钮放开连线逻辑,可通过elsa-stage中 connectionLimitDisabled: …
d338eb7
根据修改意见进行更改,并且调整了merge的逻辑
33558d1
补充测试
0bdfdf6
debug修改1
5c45e25
bug修改
371c93c
bug修改3
51c2854
测试修改
24f4e71
修改2
5dcc8e0
修改校验测试文件
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -265,6 +265,29 @@ public <R> List<FlowContext<R>> generate(List<R> data, String position) { | |
| return data.stream().map(d -> this.generate(d, position, LocalDateTime.now())).collect(Collectors.toList()); | ||
| } | ||
|
|
||
| /** | ||
| * fork一个新的context用于一拖多分支,继承当前context的运行元数据,但生成新的contextId。 | ||
| * | ||
| * @return 新的分支context | ||
| */ | ||
| public FlowContext<T> fork() { | ||
| return this.convertData(this.data); | ||
| } | ||
|
|
||
| /** | ||
| * convertData | ||
| * | ||
| * @param <R> 转换后的数据类型 | ||
| * @param data 转换后的数据 | ||
| * @return 转换后的context | ||
| */ | ||
| public <R> FlowContext<R> convertData(R data) { | ||
| FlowContext<R> context = this.copyContextWithoutID(data); | ||
| context.previous = this.previous; | ||
| context.nextPositionId = this.nextPositionId; | ||
| return context; | ||
| } | ||
|
|
||
| /** | ||
| * 用于when.convert数据时候的转换context,除了包裹的数据类型不一样,所有其他信息都一样 | ||
| * | ||
|
|
@@ -274,12 +297,17 @@ public <R> List<FlowContext<R>> generate(List<R> data, String position) { | |
| * @return 转换后的context | ||
| */ | ||
| public <R> FlowContext<R> convertData(R data, String id) { | ||
| FlowContext<R> context = this.copyContextWithoutID(data); | ||
| context.previous = this.previous; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 看下copyContext整体调整后,这里应该不再需要为previous赋值 |
||
| context.id = id; | ||
| return context; | ||
| } | ||
|
|
||
| private <R> FlowContext<R> copyContextWithoutID(R data) { | ||
| FlowContext<R> context = new FlowContext<>(this.streamId, this.rootId, data, this.traceId, this.position, | ||
| this.parallel, this.parallelMode, LocalDateTime.now()); | ||
| context.previous = this.previous; | ||
| context.status = this.status; | ||
| context.trans = this.trans; | ||
| context.id = id; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果是copyContext的含义,不应该删除previous和id的赋值 |
||
| context.batchId = this.batchId; | ||
| context.toBatch = this.toBatch; | ||
| context.createAt = this.createAt; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
.../main/java/modelengine/fit/waterflow/flowsengine/domain/flows/streams/FlowDataMerger.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved. | ||
| * This file is a part of the ModelEngine Project. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| package modelengine.fit.waterflow.flowsengine.domain.flows.streams; | ||
|
|
||
| import modelengine.fit.waterflow.flowsengine.domain.flows.context.FlowContext; | ||
| import modelengine.fit.waterflow.flowsengine.domain.flows.context.FlowData; | ||
| import modelengine.fit.waterflow.flowsengine.utils.FlowUtil; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * FlowData 类型数据的多输入合并器 | ||
| * 用于 fan-in 场景下将多条 FlowData 输入合并为单条处理 | ||
| * | ||
| * @author 沈维枫 | ||
| * @since 2026/04/07 | ||
| */ | ||
| public class FlowDataMerger implements Processors.Merger<FlowData> { | ||
|
|
||
| @Override | ||
| public FlowContext<FlowData> merge(List<FlowContext<FlowData>> contexts) { | ||
| if (contexts == null || contexts.isEmpty()) { | ||
| return null; | ||
| } | ||
| FlowContext<FlowData> baseContext = contexts.get(0); | ||
| FlowData mergedFlowData = mergeFlowData(contexts); | ||
| return baseContext.convertData(mergedFlowData, baseContext.getId()); | ||
| } | ||
|
|
||
| private FlowData mergeFlowData(List<FlowContext<FlowData>> contexts) { | ||
| FlowData first = contexts.get(0).getData(); | ||
| Map<String, Object> businessData = new HashMap<>( | ||
| Optional.ofNullable(first.getBusinessData()).orElseGet(HashMap::new)); | ||
| Map<String, Object> contextData = new HashMap<>( | ||
| Optional.ofNullable(first.getContextData()).orElseGet(HashMap::new)); | ||
| Map<String, Object> passData = new HashMap<>( | ||
| Optional.ofNullable(first.getPassData()).orElseGet(HashMap::new)); | ||
|
|
||
| contexts.stream().skip(1).map(FlowContext::getData).forEach(flowData -> { | ||
| businessData.putAll(FlowUtil.mergeMaps(businessData, | ||
| Optional.ofNullable(flowData.getBusinessData()).orElseGet(HashMap::new))); | ||
| contextData.putAll(FlowUtil.mergeMaps(contextData, | ||
| Optional.ofNullable(flowData.getContextData()).orElseGet(HashMap::new))); | ||
| passData.putAll(FlowUtil.mergeMaps(passData, | ||
| Optional.ofNullable(flowData.getPassData()).orElseGet(HashMap::new))); | ||
| }); | ||
| return FlowData.builder() | ||
| .operator(first.getOperator()) | ||
| .startTime(first.getStartTime()) | ||
| .businessData(businessData) | ||
| .contextData(contextData) | ||
| .passData(passData) | ||
| .errorMessage(first.getErrorMessage()) | ||
| .errorInfo(first.getErrorInfo()) | ||
| .build(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是聚合连线的数量,当前可以默认为10个,先不要放到100这个量级