-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from lunasaw/2.5.9
2.5.9 增加流程引擎
- Loading branch information
Showing
17 changed files
with
809 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
|
||
更新日志 | ||
|
||
- 2024-05-29 流程引擎 | ||
- 2023-09-24 断点续传 | ||
|
||
|
||
|
This file contains 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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/luna/common/engine/model/EngineContext.java
This file contains 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,22 @@ | ||
package com.luna.common.engine.model; | ||
|
||
import com.google.common.collect.Maps; | ||
import lombok.Data; | ||
|
||
import java.util.Map; | ||
|
||
@Data | ||
public class EngineContext { | ||
|
||
/** | ||
* adaptor的结果缓存 | ||
*/ | ||
private Map<String/** ResultKey **/ | ||
, Object> adaptorMap = Maps.newConcurrentMap(); | ||
|
||
/** | ||
* engin是否继续执行 | ||
*/ | ||
private boolean isStop; | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/luna/common/engine/model/EngineRunData.java
This file contains 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,15 @@ | ||
package com.luna.common.engine.model; | ||
|
||
import lombok.Data; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* @author luna | ||
*/ | ||
@Data | ||
public class EngineRunData { | ||
|
||
private Map<String, Object> runData = new ConcurrentHashMap<>(); | ||
} |
This file contains 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,88 @@ | ||
package com.luna.common.engine.model; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import com.google.common.collect.Maps; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
/** | ||
* <p> | ||
* detailNode的存储类 | ||
*/ | ||
@Getter | ||
@Setter | ||
public class NodeChain { | ||
|
||
private Map<NodeName, NodeConf> nodeMap = Maps.newLinkedHashMap(); | ||
|
||
private static NodeName getNodeName(String groupName, Class nodeClass) { | ||
NodeName nodeName; | ||
if (StringUtils.isNotBlank(groupName)) { | ||
nodeName = new NodeName(groupName, nodeClass.getName()); | ||
} else { | ||
nodeName = new NodeName(null, nodeClass.getName()); | ||
} | ||
return nodeName; | ||
} | ||
|
||
public void add(String groupName, Class nodeClass, NodeConf nodeConf) { | ||
NodeName nodeName = getNodeName(groupName, nodeClass); | ||
add(nodeName, nodeConf); | ||
} | ||
|
||
public void add(Class nodeName, NodeConf nodeConf) { | ||
add(nodeName.getName(), nodeName, nodeConf); | ||
} | ||
|
||
public void add(NodeName nodeName, NodeConf nodeConf) { | ||
if (nodeMap.containsKey(nodeName)) { | ||
return; | ||
} | ||
nodeMap.put(nodeName, nodeConf); | ||
} | ||
|
||
public void replace(String groupName, Class nodeClass, NodeConf nodeConf) { | ||
NodeName nodeName = getNodeName(groupName, nodeClass); | ||
|
||
nodeMap.put(nodeName, nodeConf); | ||
} | ||
|
||
public void replace(NodeName nodeName, NodeConf nodeConf) { | ||
nodeMap.put(nodeName, nodeConf); | ||
} | ||
|
||
public void replace(Class nodeName, NodeConf nodeConf) { | ||
replace(nodeName.getName(), nodeName, nodeConf); | ||
} | ||
|
||
public void remove(Class nodeName) { | ||
remove(nodeName.getName(), nodeName); | ||
} | ||
|
||
public void remove(String groupName, Class nodeClass) { | ||
NodeName nodeName = getNodeName(groupName, nodeClass); | ||
nodeMap.remove(nodeName); | ||
} | ||
|
||
public Set<String> getNodeNameList() { | ||
return getNodeList().stream().map(NodeName::getNodeName).collect(Collectors.toSet()); | ||
} | ||
|
||
public Set<NodeName> getNodeList() { | ||
return nodeMap.keySet(); | ||
} | ||
|
||
public NodeChain deepClone() { | ||
LinkedHashMap<NodeName, NodeConf> cloneMap = new LinkedHashMap<>(nodeMap); | ||
NodeChain nodeChain = new NodeChain(); | ||
nodeChain.setNodeMap(cloneMap); | ||
return nodeChain; | ||
} | ||
} |
This file contains 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,24 @@ | ||
package com.luna.common.engine.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* 节点配置 | ||
*/ | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Data | ||
public class NodeConf { | ||
|
||
/** | ||
* 是否是强依赖 | ||
*/ | ||
private boolean isStrongRely = true; | ||
/** | ||
* 并行执行超时时间 | ||
* 默认200ms | ||
*/ | ||
private int timeout = 200; | ||
} |
This file contains 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,55 @@ | ||
package com.luna.common.engine.model; | ||
|
||
import com.luna.common.check.Assert; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* 节点Key | ||
*/ | ||
@NoArgsConstructor | ||
@Data | ||
public class NodeName { | ||
|
||
/** | ||
* 节点组 | ||
*/ | ||
private String groupName; | ||
/** | ||
* 节点名称 | ||
*/ | ||
private String nodeName; | ||
|
||
public NodeName(String groupName, String nodeName) { | ||
Assert.notNull(nodeName, "节点名称不能为空"); | ||
this.groupName = groupName; | ||
this.nodeName = nodeName; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
NodeName nodeName1 = (NodeName)o; | ||
return Objects.equals(groupName, nodeName1.groupName) && Objects.equals(nodeName, nodeName1.nodeName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(groupName, nodeName); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuffer sb = new StringBuffer("NodeName{"); | ||
sb.append("groupName='").append(groupName).append('\''); | ||
sb.append(", nodeName='").append(nodeName).append('\''); | ||
sb.append('}'); | ||
return sb.toString(); | ||
} | ||
} |
Oops, something went wrong.