Browse Source
* update english documents * refactor zk client * update documents * update zkclient * update zkclient * update documents * add architecture-design * change i18n * update i18n * update english documents * add architecture-design * update english documents * update en-US documents * add architecture-design * update demo site * add mybatis plus model * modify mybatisplus * modify mybatisplus * change interface by mybatisplus * add unit test * refactor dao interface. * add unit test for dao... * add unit test for dao... * add unit test for dao... * Merge remote-tracking branch 'upstream/dev-db' into dev-db # Conflicts: # dolphinscheduler-dao/src/main/resources/cn.escheduler.dao.mapper/ProjectMapper.xml # dolphinscheduler-dao/src/main/resources/cn.escheduler.dao.mapper/ScheduleMapper.xml # escheduler-dao/src/main/resources/cn.escheduler.dao.mapper/ProcessInstanceMapper.xml # escheduler-dao/src/main/resources/cn.escheduler.dao.mapper/ProjectUserMapper.xml # escheduler-dao/src/main/resources/cn.escheduler.dao.mapper/QueueMapper.xml # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/ProcessInstanceMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/ProjectUserMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/QueueMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/ResourceUserMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/ScheduleMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/SessionMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/TenantMapperTest.java * Merge remote-tracking branch 'upstream/dev-db' into dev-db # Conflicts: # dolphinscheduler-dao/src/main/resources/cn.escheduler.dao.mapper/ProjectMapper.xml # dolphinscheduler-dao/src/main/resources/cn.escheduler.dao.mapper/ScheduleMapper.xml # escheduler-dao/src/main/resources/cn.escheduler.dao.mapper/ProcessInstanceMapper.xml # escheduler-dao/src/main/resources/cn.escheduler.dao.mapper/ProjectUserMapper.xml # escheduler-dao/src/main/resources/cn.escheduler.dao.mapper/QueueMapper.xml # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/ProcessInstanceMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/ProjectUserMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/QueueMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/ResourceUserMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/ScheduleMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/SessionMapperTest.java # escheduler-dao/src/test/java/cn/escheduler/dao/mapper/TenantMapperTest.java * Merge remote-tracking branch 'upstream/dev-db' into dev-db # Conflicts: # dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml # dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.xml # dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml * update some dao bugs * update for some bugs * update some bugs * Merge remote-tracking branch 'upstream/dev-db' into dev-db # Conflicts: # dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml # dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.xml # dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml * update * update * add multiply settings for application.yml * add multiply settings for application.yml * revert * update configuration settings in task record dao... * change application_master to application-master * change application_master to application-master * update application.yml to application.properties * revert * revert * add properties * add properties * revert * revert * add api start up.. add alert send try catch * update dao info level * fix bug: task cannot submit when recovery failover * fix bug: task cannot submit when recovery failover * merge from dev-db * revertpull/2/head
bao liang
5 years ago
committed by
lgcareer
5 changed files with 152 additions and 27 deletions
@ -0,0 +1,114 @@
|
||||
package org.apache.dolphinscheduler.dao.utils; |
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException; |
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.common.enums.TaskDependType; |
||||
import org.apache.dolphinscheduler.common.graph.DAG; |
||||
import org.apache.dolphinscheduler.common.model.TaskNode; |
||||
import org.apache.dolphinscheduler.common.model.TaskNodeRelation; |
||||
import org.apache.dolphinscheduler.common.process.ProcessDag; |
||||
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class DagHelperTest { |
||||
|
||||
|
||||
@Test |
||||
public void testTaskNodeCanSubmit() throws JsonProcessingException { |
||||
|
||||
|
||||
//1->2->3->5
|
||||
//4->3
|
||||
DAG<String, TaskNode, TaskNodeRelation> dag = generateDag(); |
||||
TaskNode taskNode3 = dag.getNode("3"); |
||||
Map<String, TaskInstance > completeTaskList = new HashMap<>(); |
||||
completeTaskList.putIfAbsent("1", new TaskInstance()); |
||||
Boolean canSubmit = false; |
||||
|
||||
// 2/4 are forbidden submit 3
|
||||
TaskNode node2 = dag.getNode("2"); |
||||
node2.setRunFlag(Constants.FLOWNODE_RUN_FLAG_FORBIDDEN); |
||||
TaskNode nodex = dag.getNode("4"); |
||||
nodex.setRunFlag(Constants.FLOWNODE_RUN_FLAG_FORBIDDEN); |
||||
canSubmit = DagHelper.taskNodeCanSubmit(taskNode3, dag, completeTaskList); |
||||
Assert.assertEquals(canSubmit, true); |
||||
|
||||
// 2forbidden, 3 cannot be submit
|
||||
completeTaskList.putIfAbsent("2", new TaskInstance()); |
||||
TaskNode nodey = dag.getNode("4"); |
||||
nodey.setRunFlag(""); |
||||
canSubmit = DagHelper.taskNodeCanSubmit(taskNode3, dag, completeTaskList); |
||||
Assert.assertEquals(canSubmit, false); |
||||
|
||||
// 2/3 forbidden submit 5
|
||||
TaskNode node3 = dag.getNode("3"); |
||||
node3.setRunFlag(Constants.FLOWNODE_RUN_FLAG_FORBIDDEN); |
||||
TaskNode node5 = dag.getNode("5"); |
||||
canSubmit = DagHelper.taskNodeCanSubmit(node5, dag, completeTaskList); |
||||
Assert.assertEquals(canSubmit, true); |
||||
} |
||||
|
||||
/** |
||||
* 1->2->3->5 |
||||
* 4->3 |
||||
* @return |
||||
* @throws JsonProcessingException |
||||
*/ |
||||
private DAG<String, TaskNode, TaskNodeRelation> generateDag() throws JsonProcessingException { |
||||
List<TaskNode> taskNodeList = new ArrayList<>(); |
||||
TaskNode node1 = new TaskNode(); |
||||
node1.setId("1"); |
||||
node1.setName("1"); |
||||
taskNodeList.add(node1); |
||||
|
||||
TaskNode node2 = new TaskNode(); |
||||
node2.setId("2"); |
||||
node2.setName("2"); |
||||
List<String> dep2 = new ArrayList<>(); |
||||
dep2.add("1"); |
||||
node2.setDepList(dep2); |
||||
taskNodeList.add(node2); |
||||
|
||||
|
||||
TaskNode node4 = new TaskNode(); |
||||
node4.setId("4"); |
||||
node4.setName("4"); |
||||
// node4.setRunFlag(Constants.FLOWNODE_RUN_FLAG_FORBIDDEN);
|
||||
taskNodeList.add(node4); |
||||
|
||||
TaskNode node3 = new TaskNode(); |
||||
node3.setId("3"); |
||||
node3.setName("3"); |
||||
List<String> dep3 = new ArrayList<>(); |
||||
dep3.add("2"); |
||||
dep3.add("4"); |
||||
node3.setDepList(dep3); |
||||
taskNodeList.add(node3); |
||||
|
||||
TaskNode node5 = new TaskNode(); |
||||
node5.setId("5"); |
||||
node5.setName("5"); |
||||
List<String> dep5 = new ArrayList<>(); |
||||
dep5.add("3"); |
||||
node5.setDepList(dep5); |
||||
taskNodeList.add(node5); |
||||
|
||||
List<String> startNodes = new ArrayList<>(); |
||||
List<String> recoveryNodes = new ArrayList<>(); |
||||
List<TaskNode> destTaskNodeList = DagHelper.generateFlowNodeListByStartNode(taskNodeList, |
||||
startNodes, recoveryNodes, TaskDependType.TASK_POST); |
||||
List<TaskNodeRelation> taskNodeRelations =DagHelper.generateRelationListByFlowNodes(destTaskNodeList); |
||||
ProcessDag processDag = new ProcessDag(); |
||||
processDag.setEdges(taskNodeRelations); |
||||
processDag.setNodes(destTaskNodeList); |
||||
|
||||
return DagHelper.buildDagGraph(processDag); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue