diff --git a/src/main/java/mvd/jester/model/SystemSetup.java b/src/main/java/mvd/jester/model/SystemSetup.java index 1cce652..a2ada5b 100644 --- a/src/main/java/mvd/jester/model/SystemSetup.java +++ b/src/main/java/mvd/jester/model/SystemSetup.java @@ -317,7 +317,7 @@ public class SystemSetup { try { jobDag.addDagEdge(pairs.getKey(), pairs.getValue()); } catch (final Exception e) { - // TODO: handle exception + // nothing to do here } } } diff --git a/src/main/java/mvd/jester/utils/DagUtils.java b/src/main/java/mvd/jester/utils/DagUtils.java index 8b1c76f..c99a8f9 100644 --- a/src/main/java/mvd/jester/utils/DagUtils.java +++ b/src/main/java/mvd/jester/utils/DagUtils.java @@ -147,7 +147,7 @@ public class DagUtils { try { modifiedJobDag.addDagEdge(p, sink); } catch (final Exception exception) { - // TODO: handle exception + } } continue nextEdge; @@ -296,10 +296,11 @@ public class DagUtils { final Job forkNode, final Job sink, final List joinNodes) { for (final Job j : joinNodes) { final Set ancestorsOfJ = jobDag.getAncestors(jobDag, j); - final Set ancesotorsOfFork = jobDag.getAncestors(jobDag, forkNode); - ancesotorsOfFork.add(forkNode); + final Set ancestorsOfFork = jobDag.getAncestors(jobDag, forkNode); + ancestorsOfFork.add(forkNode); final Set inbetweenJobs = new HashSet<>(ancestorsOfJ); - inbetweenJobs.removeAll(ancesotorsOfFork); + inbetweenJobs.removeAll(ancestorsOfFork); + inbetweenJobs.add(j); if (inbetweenJobs.isEmpty()) { continue; } diff --git a/src/test/java/mvd/jester/model/TestDagUtils.java b/src/test/java/mvd/jester/model/TestDagUtils.java index a22e20d..f1fa9b8 100644 --- a/src/test/java/mvd/jester/model/TestDagUtils.java +++ b/src/test/java/mvd/jester/model/TestDagUtils.java @@ -1,16 +1,13 @@ package mvd.jester.model; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.util.List; -import java.util.Stack; +import java.util.concurrent.ThreadLocalRandom; import org.jgrapht.Graphs; import org.jgrapht.experimental.dag.DirectedAcyclicGraph; import org.jgrapht.graph.DefaultEdge; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import mvd.jester.utils.DagUtils; -import mvd.jester.utils.BinaryDecompositionTree.Node; -import mvd.jester.utils.BinaryDecompositionTree.NodeType; import mvd.jester.model.SystemSetup.DagTaskBuilder; import mvd.jester.utils.BinaryDecompositionTree; @@ -38,7 +35,7 @@ public class TestDagUtils { @Test @DisplayName("Check if NFJ DAGs are created correctly.") void checkNfjDagCreation() { - for (int i = 0; i < 10000; ++i) { + for (int i = 0; i < 100; ++i) { DagTaskBuilder b = new DagTaskBuilder(); DagTask t = b.generateTask(); @@ -49,55 +46,11 @@ public class TestDagUtils { } - private long countLeafs(BinaryDecompositionTree tree) { - Node node = tree.getRootNode(); - // Base Case - if (node == null) { - return 0; - } - - // Create an empty stack and push root to it - Stack> nodeStack = new Stack<>(); - nodeStack.push(node); - - long count = 0; - while (nodeStack.empty() == false) { - - // Pop the top item from stack and print it - Node mynode = nodeStack.peek(); - if (mynode.getNodeType() == NodeType.LEAF) { - count++; - } - nodeStack.pop(); - - // Push right and left children of the popped node to stack - if (mynode.getLeftNode() != null) { - nodeStack.push(mynode.getLeftNode()); - } - if (mynode.getRightNode() != null) { - nodeStack.push(mynode.getRightNode()); - } - } - return count; - } - - private void drawGraph(DirectedAcyclicGraph nfjJobDag) { - for (Job j : nfjJobDag) { - List predecessors = Graphs.predecessorListOf(nfjJobDag, j); - List successors = Graphs.successorListOf(nfjJobDag, j); - int test = 4; - } - } - @Test @DisplayName("Check if Decomposition Tree is created correctly for NFJ Dag.") void checkDecompositionTreeCreation() { - for (int i = 0; i < 10000; ++i) { - // { - // int i = 610; - // System.out.println(i); - // long numberOfProcessors = ThreadLocalRandom.current().nextLong(4, 16); - long numberOfProcessors = 4; + for (int i = 0; i < 100; ++i) { + long numberOfProcessors = ThreadLocalRandom.current().nextLong(4, 16); DagTaskBuilder b = new DagTaskBuilder().setNumberOfProcessors(numberOfProcessors); DagTask t = b.generateTask(); DirectedAcyclicGraph jobDag = t.getJobDag(); @@ -107,22 +60,13 @@ public class TestDagUtils { DirectedAcyclicGraph jobDagFromTree = DagUtils.createNFJfromDecompositionTree(tree); - // drawGraph(nfjJobDag); - // drawGraph(nfjJobDag); - boolean ja = DagUtils.checkNFJProperty(nfjJobDag); - System.out.println("Bei i = " + i + ": nfj = " + ja); - assertTrue(jobDag.vertexSet().size() == nfjJobDag.vertexSet().size()); assertTrue(jobDag.vertexSet().size() == jobDagFromTree.vertexSet().size()); assertTrue(jobDagFromTree.edgeSet().size() == nfjJobDag.edgeSet().size()); - for (DefaultEdge e : nfjJobDag.edgeSet()) { Job target = nfjJobDag.getEdgeTarget(e); Job source = nfjJobDag.getEdgeSource(e); - if (!jobDagFromTree.containsEdge(source, target)) { - drawGraph(jobDag); - } assertTrue(jobDagFromTree.containsEdge(source, target)); }