tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeag...@apache.org
Subject [22/27] tez git commit: TEZ-1805. Tez client DAG cycle detection should detect self loops (zjffdu)
Date Wed, 10 Dec 2014 03:30:32 GMT
TEZ-1805. Tez client DAG cycle detection should detect self loops (zjffdu)


Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/8cc5a82e
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/8cc5a82e
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/8cc5a82e

Branch: refs/heads/TEZ-8
Commit: 8cc5a82ee8a28ebd39f1ba60de3b97e3bca4867c
Parents: 2b30d01
Author: Jeff Zhang <zjffdu@apache.org>
Authored: Mon Dec 8 16:39:06 2014 +0800
Committer: Jeff Zhang <zjffdu@apache.org>
Committed: Mon Dec 8 16:39:06 2014 +0800

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../main/java/org/apache/tez/dag/api/DAG.java   |  9 +++++++
 .../org/apache/tez/dag/api/TestDAGVerify.java   | 26 ++++++++++++++++++++
 3 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/8cc5a82e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ef5a987..e6230a9 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -6,6 +6,7 @@ Release 0.6.0: Unreleased
 INCOMPATIBLE CHANGES
 
 ALL CHANGES:
+  TEZ-1805. Tez client DAG cycle detection should detect self loops
   TEZ-1816. It is possible to receive START event when DAG is failed
   TEZ-1787. Counters for speculation
   TEZ-1773. Add attempt failure cause enum to the attempt failed/killed

http://git-wip-us.apache.org/repos/asf/tez/blob/8cc5a82e/tez-api/src/main/java/org/apache/tez/dag/api/DAG.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/dag/api/DAG.java b/tez-api/src/main/java/org/apache/tez/dag/api/DAG.java
index edaf800..91b468d 100644
--- a/tez-api/src/main/java/org/apache/tez/dag/api/DAG.java
+++ b/tez-api/src/main/java/org/apache/tez/dag/api/DAG.java
@@ -591,6 +591,15 @@ public class DAG {
         }
         message.append(av.v.getName());
         throw new IllegalStateException("DAG contains a cycle: " + message);
+      } else {
+        // detect self-cycle
+        if (edgeMap.containsKey(pop.v)) {
+          for (Edge edge : edgeMap.get(pop.v)) {
+            if (edge.getOutputVertex().equals(pop.v)) {
+              throw new IllegalStateException("DAG contains a self-cycle on vertex:" + pop.v.getName());
+            }
+          }
+        }
       }
       topologicalVertexStack.push(av.v.getName());
     }

http://git-wip-us.apache.org/repos/asf/tez/blob/8cc5a82e/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java
----------------------------------------------------------------------
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java
index 7edc7e5..7a95c9a 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java
@@ -471,6 +471,32 @@ public class TestDAGVerify {
     Assert.assertTrue(ex.getMessage().startsWith("DAG contains a cycle"));
   }
 
+  // v1 -> v1
+  @Test(timeout = 5000)
+  public void testSelfCycle(){
+    IllegalStateException ex=null;
+    Vertex v1 = Vertex.create("v1",
+        ProcessorDescriptor.create("MapProcessor"),
+        dummyTaskCount, dummyTaskResource);
+    Edge e1 = Edge.create(v1, v1,
+        EdgeProperty.create(DataMovementType.SCATTER_GATHER,
+            DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL,
+            OutputDescriptor.create("dummy output class"),
+            InputDescriptor.create("dummy input class")));
+    DAG dag = DAG.create("testDag");
+    dag.addVertex(v1);
+    dag.addEdge(e1);
+    try{
+      dag.verify();
+    }
+    catch (IllegalStateException e){
+      ex = e;
+    }
+    Assert.assertNotNull(ex);
+    System.out.println(ex.getMessage());
+    Assert.assertTrue(ex.getMessage().startsWith("DAG contains a self-cycle"));
+  }
+
   @Test(timeout = 5000)
   public void repeatedVertexName() {
     IllegalStateException ex=null;


Mime
View raw message