|
|
@ -79,6 +79,7 @@ public class MasterExecThread implements Runnable { |
|
|
|
private Map<String, TaskInstance> completeTaskList = new ConcurrentHashMap<>(); |
|
|
|
private Map<String, TaskInstance> completeTaskList = new ConcurrentHashMap<>(); |
|
|
|
private Map<String, TaskInstance> readyToSubmitTaskList = new ConcurrentHashMap<>(); |
|
|
|
private Map<String, TaskInstance> readyToSubmitTaskList = new ConcurrentHashMap<>(); |
|
|
|
private Map<String, TaskInstance> dependFailedTask = new ConcurrentHashMap<>(); |
|
|
|
private Map<String, TaskInstance> dependFailedTask = new ConcurrentHashMap<>(); |
|
|
|
|
|
|
|
private Map<String, TaskNode> forbiddenTaskList = new ConcurrentHashMap<>(); |
|
|
|
private List<TaskInstance> recoverToleranceFaultTaskList = new ArrayList<>(); |
|
|
|
private List<TaskInstance> recoverToleranceFaultTaskList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
private AlertManager alertManager = new AlertManager(); |
|
|
|
private AlertManager alertManager = new AlertManager(); |
|
|
@ -269,6 +270,7 @@ public class MasterExecThread implements Runnable { |
|
|
|
private void buildFlowDag() throws Exception { |
|
|
|
private void buildFlowDag() throws Exception { |
|
|
|
recoverNodeIdList = getStartTaskInstanceList(processInstance.getCommandParam()); |
|
|
|
recoverNodeIdList = getStartTaskInstanceList(processInstance.getCommandParam()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
forbiddenTaskList = DagHelper.getForbiddenTaskNodeMaps(processInstance.getProcessInstanceJson()); |
|
|
|
// generate process to get DAG info
|
|
|
|
// generate process to get DAG info
|
|
|
|
List<String> recoveryNameList = getRecoveryNodeNameList(); |
|
|
|
List<String> recoveryNameList = getRecoveryNodeNameList(); |
|
|
|
List<String> startNodeNameList = parseStartNodeName(processInstance.getCommandParam()); |
|
|
|
List<String> startNodeNameList = parseStartNodeName(processInstance.getCommandParam()); |
|
|
@ -279,7 +281,8 @@ public class MasterExecThread implements Runnable { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// generate process dag
|
|
|
|
// generate process dag
|
|
|
|
dag = buildDagGraph(processDag); |
|
|
|
dag = DagHelper.buildDagGraph(processDag); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initTaskQueue(){ |
|
|
|
private void initTaskQueue(){ |
|
|
@ -411,24 +414,7 @@ public class MasterExecThread implements Runnable { |
|
|
|
return taskInstance; |
|
|
|
return taskInstance; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Collection<String> getStartVertex(String parentNodeName, DAG<String, TaskNode, TaskNodeRelation> dag){ |
|
|
|
|
|
|
|
Collection<String> startVertex = null; |
|
|
|
|
|
|
|
if(StringUtils.isNotEmpty(parentNodeName)){ |
|
|
|
|
|
|
|
startVertex = dag.getSubsequentNodes(parentNodeName); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
startVertex = dag.getBeginNode(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(String start : startVertex){ |
|
|
|
|
|
|
|
TaskNode node = dag.getNode(start); |
|
|
|
|
|
|
|
if(node.isForbidden()){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return startVertex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* get post task instance by node |
|
|
|
* get post task instance by node |
|
|
@ -440,10 +426,12 @@ public class MasterExecThread implements Runnable { |
|
|
|
private List<TaskInstance> getPostTaskInstanceByNode(DAG<String, TaskNode, TaskNodeRelation> dag, String parentNodeName){ |
|
|
|
private List<TaskInstance> getPostTaskInstanceByNode(DAG<String, TaskNode, TaskNodeRelation> dag, String parentNodeName){ |
|
|
|
|
|
|
|
|
|
|
|
List<TaskInstance> postTaskList = new ArrayList<>(); |
|
|
|
List<TaskInstance> postTaskList = new ArrayList<>(); |
|
|
|
Collection<String> startVertex = getStartVertex(parentNodeName, dag); |
|
|
|
Collection<String> startVertex = DagHelper.getStartVertex(parentNodeName, dag); |
|
|
|
|
|
|
|
if(startVertex == null){ |
|
|
|
|
|
|
|
return postTaskList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (String nodeName : startVertex){ |
|
|
|
for (String nodeName : startVertex){ |
|
|
|
|
|
|
|
|
|
|
|
// encapsulation task instance
|
|
|
|
// encapsulation task instance
|
|
|
|
TaskInstance taskInstance = createTaskInstance(processInstance, nodeName , |
|
|
|
TaskInstance taskInstance = createTaskInstance(processInstance, nodeName , |
|
|
|
dag.getNode(nodeName),parentNodeName); |
|
|
|
dag.getNode(nodeName),parentNodeName); |
|
|
@ -532,8 +520,8 @@ public class MasterExecThread implements Runnable { |
|
|
|
List<String> depsNameList = taskNode.getDepList(); |
|
|
|
List<String> depsNameList = taskNode.getDepList(); |
|
|
|
for(String depsNode : depsNameList ){ |
|
|
|
for(String depsNode : depsNameList ){ |
|
|
|
|
|
|
|
|
|
|
|
// dependencies must be all complete
|
|
|
|
// dependencies must be fully completed or run prohibited
|
|
|
|
if(!completeTaskList.containsKey(depsNode)){ |
|
|
|
if(!completeTaskList.containsKey(depsNode) || !forbiddenTaskList.containsKey(depsNode)){ |
|
|
|
return DependResult.WAITING; |
|
|
|
return DependResult.WAITING; |
|
|
|
} |
|
|
|
} |
|
|
|
ExecutionStatus taskState = completeTaskList.get(depsNode).getState(); |
|
|
|
ExecutionStatus taskState = completeTaskList.get(depsNode).getState(); |
|
|
@ -919,35 +907,6 @@ public class MasterExecThread implements Runnable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* generate dag graph |
|
|
|
|
|
|
|
* @param processDag |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public DAG<String, TaskNode, TaskNodeRelation> buildDagGraph(ProcessDag processDag) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DAG<String,TaskNode,TaskNodeRelation> dag = new DAG<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* add vertex |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(processDag.getNodes())){ |
|
|
|
|
|
|
|
for (TaskNode node : processDag.getNodes()){ |
|
|
|
|
|
|
|
dag.addNode(node.getName(),node); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* add edge |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(processDag.getEdges())){ |
|
|
|
|
|
|
|
for (TaskNodeRelation edge : processDag.getEdges()){ |
|
|
|
|
|
|
|
dag.addEdge(edge.getStartNode(),edge.getEndNode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return dag; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* whether the retry interval is timed out |
|
|
|
* whether the retry interval is timed out |
|
|
|
* @param taskInstance |
|
|
|
* @param taskInstance |
|
|
|