tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hit...@apache.org
Subject tez git commit: TEZ-3376. Fix groupId generation to account for dagId starting with 1. (Harish Jaiprakash via hitesh)
Date Tue, 26 Jul 2016 18:11:09 GMT
Repository: tez
Updated Branches:
  refs/heads/branch-0.8 152f1420b -> c882d829f


TEZ-3376. Fix groupId generation to account for dagId starting with 1. (Harish Jaiprakash
via hitesh)

(cherry picked from commit d3011a9bcc70a0cc4003005aba8aa3369a9b4d1c)

Conflicts:
	CHANGES.txt


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

Branch: refs/heads/branch-0.8
Commit: c882d829fc2278525568fbb46f29ca843c6f518f
Parents: 152f142
Author: Hitesh Shah <hitesh@apache.org>
Authored: Tue Jul 26 11:10:16 2016 -0700
Committer: Hitesh Shah <hitesh@apache.org>
Committed: Tue Jul 26 11:11:01 2016 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/tez/dag/records/TezDAGID.java    |  5 ++--
 .../org/apache/tez/dag/records/TestTezIds.java  | 24 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/c882d829/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 71d31ac..db8a084 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -7,6 +7,7 @@ INCOMPATIBLE CHANGES
 
 ALL CHANGES:
 
+  TEZ-3376. Fix groupId generation to account for dagId starting with 1.
   TEZ-3359. Add granular log levels for HistoryLoggingService.
   TEZ-3374. Change TEZ_HISTORY_LOGGING_TIMELINE_NUM_DAGS_PER_GROUP conf key name.
   TEZ-3358. Support using the same TimelineGroupId for multiple DAGs.

http://git-wip-us.apache.org/repos/asf/tez/blob/c882d829/tez-common/src/main/java/org/apache/tez/dag/records/TezDAGID.java
----------------------------------------------------------------------
diff --git a/tez-common/src/main/java/org/apache/tez/dag/records/TezDAGID.java b/tez-common/src/main/java/org/apache/tez/dag/records/TezDAGID.java
index 58ab509..b7a2c8f 100644
--- a/tez-common/src/main/java/org/apache/tez/dag/records/TezDAGID.java
+++ b/tez-common/src/main/java/org/apache/tez/dag/records/TezDAGID.java
@@ -187,12 +187,13 @@ public class TezDAGID extends TezID {
    */
   public String getGroupId(int numDagsPerGroup) {
     if (numDagsPerGroup <= 1) {
-      throw new IllegalArgumentException("numDagsPerGroup has to be more than one. Got: "
+ numDagsPerGroup);
+      throw new IllegalArgumentException("numDagsPerGroup has to be more than one. Got: "
+
+          numDagsPerGroup);
     }
     return DAG_GROUPID_PREFIX + SEPARATOR +
         getApplicationId().getClusterTimestamp() + SEPARATOR +
         tezAppIdFormat.get().format(getApplicationId().getId()) + SEPARATOR +
-        tezDagIdFormat.get().format(getId() / numDagsPerGroup);
+        tezDagIdFormat.get().format((getId() - 1) / numDagsPerGroup);
   }
 
   public static TezDAGID fromString(String dagId) {

http://git-wip-us.apache.org/repos/asf/tez/blob/c882d829/tez-common/src/test/java/org/apache/tez/dag/records/TestTezIds.java
----------------------------------------------------------------------
diff --git a/tez-common/src/test/java/org/apache/tez/dag/records/TestTezIds.java b/tez-common/src/test/java/org/apache/tez/dag/records/TestTezIds.java
index 04a2b35..5e1552d 100644
--- a/tez-common/src/test/java/org/apache/tez/dag/records/TestTezIds.java
+++ b/tez-common/src/test/java/org/apache/tez/dag/records/TestTezIds.java
@@ -146,5 +146,29 @@ public class TestTezIds {
   }
 
 
+  public void testGetGroupIds() {
+    ApplicationId appId = ApplicationId.newInstance(0, 1);
+    int numDagsPerGroup = 5;
+    TezDAGID dagId = TezDAGID.getInstance(appId, 1);
+
+    // All dags within one group should have same id.
+    String groupId1 = dagId.getGroupId(numDagsPerGroup);
+    for (int i = 0; i < numDagsPerGroup; ++i) {
+      Assert.assertEquals(TezDAGID.getInstance(appId, i + 1).getGroupId(numDagsPerGroup),
groupId1);
+    }
+
+    // Assert different id across groups.
+    Assert.assertNotEquals(
+        TezDAGID.getInstance(appId, numDagsPerGroup + 1).getGroupId(numDagsPerGroup), groupId1);
+
+    // Invalid values -1, 0, 1 should throw IllegalArgumentException.
+    for (int i = -1; i < 2; ++i) {
+      try {
+        dagId.getGroupId(i);
+        Assert.fail("Expected IllegalArgumentException for numDagsPerGroup: " + i);
+      } catch (IllegalArgumentException e) {
+      }
+    }
+  }
 
 }


Mime
View raw message