tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hit...@apache.org
Subject git commit: TEZ-1664. Add checks to ensure that the client and AM are compatible. (hitesh)
Date Wed, 29 Oct 2014 01:36:02 GMT
Repository: tez
Updated Branches:
  refs/heads/master 6d0a7b3f0 -> d59b2318d


TEZ-1664. Add checks to ensure that the client and AM are compatible. (hitesh)


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

Branch: refs/heads/master
Commit: d59b2318dd66ee1784dabca28820e9b8e65f8bf1
Parents: 6d0a7b3
Author: Hitesh Shah <hitesh@apache.org>
Authored: Tue Oct 28 18:35:08 2014 -0700
Committer: Hitesh Shah <hitesh@apache.org>
Committed: Tue Oct 28 18:35:08 2014 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 pom.xml                                         |   1 +
 tez-api/pom.xml                                 |  22 ++++
 .../apache/tez/client/TezApiVersionInfo.java    |  29 +++++
 .../java/org/apache/tez/client/TezClient.java   |   9 +-
 .../org/apache/tez/client/TezClientUtils.java   |  21 +++-
 .../org/apache/tez/common/TezYARNUtils.java     |   4 +
 .../java/org/apache/tez/common/VersionInfo.java | 105 +++++++++++++++++
 .../apache/tez/dag/api/TezConfiguration.java    |  10 ++
 .../org/apache/tez/dag/api/TezConstants.java    |   4 +
 .../resources/tez-api-version-info.properties   |  22 ++++
 .../org/apache/tez/common/TestVersionInfo.java  |  66 +++++++++++
 .../resources/test1-version-info.properties     |  22 ++++
 .../resources/test2-version-info.properties     |  21 ++++
 .../resources/test3-version-info.properties     |  22 ++++
 tez-dag/pom.xml                                 |  22 ++++
 .../java/org/apache/tez/client/LocalClient.java |   4 +-
 .../org/apache/tez/dag/app/DAGAppMaster.java    | 114 ++++++++++++++-----
 .../apache/tez/dag/app/TezDagVersionInfo.java   |  28 +++++
 .../utils/Simple2LevelVersionComparator.java    | 105 +++++++++++++++++
 .../resources/tez-dag-version-info.properties   |  22 ++++
 .../apache/tez/dag/app/MockDAGAppMaster.java    |   3 +-
 .../TestSimple2LevelVersionComparator.java      |  66 +++++++++++
 23 files changed, 687 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d64e1c3..d818bae 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -70,6 +70,7 @@ ALL CHANGES:
   TEZ-1710. Add support for cluster default AM/task launch opts.
   TEZ-1713. tez.lib.uris should not require the paths specified to be fully qualified.
   TEZ-1715. Fix use of import java.util.* in MultiMRInput.
+  TEZ-1664. Add checks to ensure that the client and AM are compatible.
 
 Release 0.5.1: 2014-10-02
 

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 02c271c..999e569 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,6 +50,7 @@
     <protoc.path>${env.PROTOC_PATH}</protoc.path>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <scm.url>scm:git:https://git-wip-us.apache.org/repos/asf/tez.git</scm.url>
+    <build.time>${maven.build.timestamp}</build.time>
   </properties>
   <scm>
     <connection>${scm.url}</connection>

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/pom.xml
----------------------------------------------------------------------
diff --git a/tez-api/pom.xml b/tez-api/pom.xml
index 0985845..a2ed5f0 100644
--- a/tez-api/pom.xml
+++ b/tez-api/pom.xml
@@ -106,6 +106,28 @@
   </dependencies>
 
   <build>
+   <!--
+    Include all files in src/main/resources.  By default, do not apply property
+    substitution (filtering=false), but do apply property substitution to
+    version-info.properties (filtering=true).  This will substitute the
+    version information correctly, but prevent Maven from altering other files.
+    -->
+    <resources>
+      <resource>
+        <directory>${basedir}/src/main/resources</directory>
+        <excludes>
+          <exclude>tez-api-version-info.properties</exclude>
+        </excludes>
+        <filtering>false</filtering>
+      </resource>
+      <resource>
+        <directory>${basedir}/src/main/resources</directory>
+        <includes>
+          <include>tez-api-version-info.properties</include>
+        </includes>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
     <plugins>
       <plugin>
         <groupId>org.apache.rat</groupId>

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/main/java/org/apache/tez/client/TezApiVersionInfo.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/client/TezApiVersionInfo.java b/tez-api/src/main/java/org/apache/tez/client/TezApiVersionInfo.java
new file mode 100644
index 0000000..2870ae4
--- /dev/null
+++ b/tez-api/src/main/java/org/apache/tez/client/TezApiVersionInfo.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tez.client;
+
+import org.apache.tez.common.VersionInfo;
+
+public class TezApiVersionInfo extends VersionInfo {
+
+  public TezApiVersionInfo() {
+    super("tez-api");
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/main/java/org/apache/tez/client/TezClient.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/client/TezClient.java b/tez-api/src/main/java/org/apache/tez/client/TezClient.java
index 7728286..049fee3 100644
--- a/tez-api/src/main/java/org/apache/tez/client/TezClient.java
+++ b/tez-api/src/main/java/org/apache/tez/client/TezClient.java
@@ -102,7 +102,8 @@ public class TezClient {
   private JobTokenSecretManager jobTokenSecretManager =
       new JobTokenSecretManager();
   private Map<String, LocalResource> additionalLocalResources = Maps.newHashMap();
-  
+  private TezApiVersionInfo apiVersionInfo;
+
   private int preWarmDAGCounter = 0;
 
 
@@ -133,6 +134,8 @@ public class TezClient {
     // Set in conf for local mode AM to figure out whether in session mode or not
     tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, isSession);
     this.amConfig = new AMConfiguration(tezConf, localResources, credentials);
+    this.apiVersionInfo = new TezApiVersionInfo();
+    LOG.info("Tez Client Version: " + apiVersionInfo.toString());
   }
 
   /**
@@ -307,7 +310,7 @@ public class TezClient {
             TezClientUtils.createApplicationSubmissionContext(
                 sessionAppId,
                 null, clientName, amConfig,
-                tezJarResources, sessionCredentials, usingTezArchiveDeploy);
+                tezJarResources, sessionCredentials, usingTezArchiveDeploy, apiVersionInfo);
   
         // Set Tez Sessions to not retry on AM crashes if recovery is disabled
         if (!amConfig.getTezConfiguration().getBoolean(
@@ -677,7 +680,7 @@ public class TezClient {
       ApplicationSubmissionContext appContext = TezClientUtils
           .createApplicationSubmissionContext( 
               appId, dag, dag.getName(), amConfig, tezJarResources, credentials,
-              usingTezArchiveDeploy);
+              usingTezArchiveDeploy, apiVersionInfo);
       LOG.info("Submitting DAG to YARN"
           + ", applicationId=" + appId
           + ", dagName=" + dag.getName());

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/main/java/org/apache/tez/client/TezClientUtils.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/client/TezClientUtils.java b/tez-api/src/main/java/org/apache/tez/client/TezClientUtils.java
index f236bf1..7be8013 100644
--- a/tez-api/src/main/java/org/apache/tez/client/TezClientUtils.java
+++ b/tez-api/src/main/java/org/apache/tez/client/TezClientUtils.java
@@ -76,6 +76,7 @@ import org.apache.hadoop.yarn.util.Records;
 import org.apache.log4j.Level;
 import org.apache.tez.common.TezCommonUtils;
 import org.apache.tez.common.TezYARNUtils;
+import org.apache.tez.common.VersionInfo;
 import org.apache.tez.common.security.ACLManager;
 import org.apache.tez.common.security.JobTokenIdentifier;
 import org.apache.tez.common.security.JobTokenSecretManager;
@@ -156,19 +157,23 @@ public class TezClientUtils {
     } else {
       // Add tez jars to local resource
       String[] tezJarUris = conf.getStrings(TezConfiguration.TEZ_LIB_URIS);
-        
+
       if (tezJarUris == null || tezJarUris.length == 0) {
         throw new TezUncheckedException("Invalid configuration of tez jars"
             + ", " + TezConfiguration.TEZ_LIB_URIS
             + " is not defined in the configuration");
       }
 
+      LOG.info("Using tez.lib.uris value from configuration: "
+          + conf.get(TezConfiguration.TEZ_LIB_URIS));
+
       if (tezJarUris.length == 1 && (
               tezJarUris[0].endsWith(".tar.gz") ||
               tezJarUris[0].endsWith(".tgz") ||
               tezJarUris[0].endsWith(".zip") ||
               tezJarUris[0].endsWith(".tar"))) {
         String fileName = tezJarUris[0];
+
         FileStatus fStatus = getLRFileStatus(fileName, conf)[0];
         LocalResourceVisibility lrVisibility;
         if (checkAncestorPermissionsForAllUsers(conf, fileName, FsAction.EXECUTE) &&
@@ -400,8 +405,8 @@ public class TezClientUtils {
   static ApplicationSubmissionContext createApplicationSubmissionContext(
       ApplicationId appId, DAG dag, String amName,
       AMConfiguration amConfig, Map<String, LocalResource> tezJarResources,
-      Credentials sessionCreds, boolean tezLrsAsArchive)
-          throws IOException, YarnException{
+      Credentials sessionCreds, boolean tezLrsAsArchive,
+      TezApiVersionInfo apiVersionInfo) throws IOException, YarnException{
 
     Preconditions.checkNotNull(sessionCreds);
     TezConfiguration conf = amConfig.getTezConfiguration();
@@ -495,6 +500,8 @@ public class TezClientUtils {
             entry.getValue(), File.pathSeparator);
       }
     }
+
+    addVersionInfoToEnv(environment, apiVersionInfo);
     
     Map<String, LocalResource> amLocalResources =
         new TreeMap<String, LocalResource>();
@@ -900,4 +907,12 @@ public class TezClientUtils {
     return amOpts;
   }
 
+  private static void addVersionInfoToEnv(Map<String, String> environment,
+      TezApiVersionInfo versionInfo) {
+    if (!versionInfo.getVersion().equals(VersionInfo.UNKNOWN)) {
+      TezYARNUtils.replaceInEnv(environment, TezConstants.TEZ_CLIENT_VERSION_ENV,
+          versionInfo.getVersion());
+    }
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/main/java/org/apache/tez/common/TezYARNUtils.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/common/TezYARNUtils.java b/tez-api/src/main/java/org/apache/tez/common/TezYARNUtils.java
index 74e21c0..fc30780 100644
--- a/tez-api/src/main/java/org/apache/tez/common/TezYARNUtils.java
+++ b/tez-api/src/main/java/org/apache/tez/common/TezYARNUtils.java
@@ -186,4 +186,8 @@ public class TezYARNUtils {
         Environment.PWD.$(), File.pathSeparator);
   }
 
+  public static void replaceInEnv(Map<String, String> env, String key, String value) {
+    env.put(StringInterner.weakIntern(key), StringInterner.weakIntern(value));
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/main/java/org/apache/tez/common/VersionInfo.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/common/VersionInfo.java b/tez-api/src/main/java/org/apache/tez/common/VersionInfo.java
new file mode 100644
index 0000000..0287d0b
--- /dev/null
+++ b/tez-api/src/main/java/org/apache/tez/common/VersionInfo.java
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tez.common;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.util.ClassUtil;
+
+@Private
+@Unstable
+public class VersionInfo {
+  private static final Log LOG = LogFactory.getLog(VersionInfo.class);
+
+  private final Properties info;
+  private final String component;
+
+  private static final String VERSION = "version";
+  private static final String REVISION = "revision";
+  private static final String BUILD_TIME = "buildtime";
+  private static final String SCM_URL = "scmurl";
+
+  public static final String UNKNOWN = "Unknown";
+
+  protected VersionInfo(String component) {
+    this.component = component;
+    info = new Properties();
+    String versionInfoFile = component + "-version-info.properties";
+    InputStream is = null;
+    try {
+      is = Thread.currentThread().getContextClassLoader()
+          .getResourceAsStream(versionInfoFile);
+      if (is == null) {
+        throw new IOException("Resource not found");
+      }
+      info.load(is);
+    } catch (IOException ex) {
+      LogFactory.getLog(getClass()).warn("Could not read '" +
+          versionInfoFile + "', " + ex.toString(), ex);
+    } finally {
+      IOUtils.closeStream(is);
+    }
+  }
+
+  public String getVersion() {
+    return info.getProperty(VERSION, UNKNOWN);
+  }
+
+  public String getBuildTime() {
+    return info.getProperty(BUILD_TIME, UNKNOWN);
+  }
+
+  public String getRevision() {
+    return info.getProperty(REVISION, UNKNOWN);
+  }
+
+  public String getSCMURL() {
+    return info.getProperty(SCM_URL, UNKNOWN);
+  }
+
+  @Override
+  public String toString() {
+    return "[ component=" + component
+        + ", version=" + getVersion()
+        + ", revision=" + getRevision()
+        + ", SCM-URL=" + getSCMURL()
+        + ", buildTIme=" + getBuildTime()
+        + " ]";
+  }
+
+  public static void main(String[] args) {
+    if (args.length != 1) {
+      System.err.println("Invalid no. of args. Usage: VersionInfo <component-name>");
+      System.exit(-1);
+    }
+
+    VersionInfo versionInfo = new VersionInfo(args[0]);
+    System.out.println("VersionInfo: " + versionInfo.toString());
+    System.out.println("This command was run using " +
+        ClassUtil.findContainingJar(VersionInfo.class));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java b/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java
index 05455a2..e3c3c83 100644
--- a/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java
+++ b/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java
@@ -835,4 +835,14 @@ public class TezConfiguration extends Configuration {
    */
   public static final String TEZ_AM_MODIFY_ACLS = TEZ_AM_PREFIX + "modify-acls";
 
+  /**
+   * Boolean value.
+   * Disable version check between client and AM/DAG. Default false.
+   */
+  public static final String TEZ_AM_DISABLE_CLIENT_VERSION_CHECK = TEZ_AM_PREFIX
+      + "disable.client-version-check";
+  public static final boolean TEZ_AM_DISABLE_CLIENT_VERSION_CHECK_DEFAULT = false;
+
+
+
 }

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/main/java/org/apache/tez/dag/api/TezConstants.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/dag/api/TezConstants.java b/tez-api/src/main/java/org/apache/tez/dag/api/TezConstants.java
index 8af7e84..e335da8 100644
--- a/tez-api/src/main/java/org/apache/tez/dag/api/TezConstants.java
+++ b/tez-api/src/main/java/org/apache/tez/dag/api/TezConstants.java
@@ -96,4 +96,8 @@ public class TezConstants {
   public static final String TEZ_DAG_MODIFY_ACLS = TezConfiguration.TEZ_AM_PREFIX + "dag.modify-acls";
 
   public static final long TEZ_DAG_SLEEP_TIME_BEFORE_EXIT = 5000;
+
+  /// Version-related Environment variables
+  public static final String TEZ_CLIENT_VERSION_ENV = "TEZ_CLIENT_VERSION";
+
 }

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/main/resources/tez-api-version-info.properties
----------------------------------------------------------------------
diff --git a/tez-api/src/main/resources/tez-api-version-info.properties b/tez-api/src/main/resources/tez-api-version-info.properties
new file mode 100644
index 0000000..4bb7d40
--- /dev/null
+++ b/tez-api/src/main/resources/tez-api-version-info.properties
@@ -0,0 +1,22 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+version=${pom.version}
+revision=${buildNumber}
+buildtime=${build.time}
+scmurl=${scm.url}

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/test/java/org/apache/tez/common/TestVersionInfo.java
----------------------------------------------------------------------
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestVersionInfo.java b/tez-api/src/test/java/org/apache/tez/common/TestVersionInfo.java
new file mode 100644
index 0000000..d1d3ae7
--- /dev/null
+++ b/tez-api/src/test/java/org/apache/tez/common/TestVersionInfo.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tez.common;
+
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class TestVersionInfo {
+
+  final String version = "0.6.0-SNAPSHOT";
+  final String revision = "d523db65804a5742ce50824e6fcfb8a04d184c0d";
+  final String buildTime = "20141024-1052";
+  final String scmUrl = "scm:git:https://git-wip-us.apache.org/repos/asf/tez.git";
+
+  @Test
+  public void testTest1File() {
+    VersionInfo versionInfo = new VersionInfo("test1");
+    Assert.assertEquals(version, versionInfo.getVersion());
+    Assert.assertEquals(revision, versionInfo.getRevision());
+    Assert.assertEquals(buildTime, versionInfo.getBuildTime());
+    Assert.assertEquals(scmUrl, versionInfo.getSCMURL());
+  }
+
+  @Test
+  public void testTest2File() {
+    VersionInfo versionInfo = new VersionInfo("test2");
+    Assert.assertEquals(version, versionInfo.getVersion());
+    Assert.assertEquals(revision, versionInfo.getRevision());
+    Assert.assertEquals(buildTime, versionInfo.getBuildTime());
+    Assert.assertEquals(VersionInfo.UNKNOWN, versionInfo.getSCMURL());
+  }
+
+  @Test
+  public void testTest3File() {
+    VersionInfo versionInfo = new VersionInfo("test3");
+    Assert.assertEquals(version, versionInfo.getVersion());
+    Assert.assertEquals(revision, versionInfo.getRevision());
+    Assert.assertEquals("", versionInfo.getBuildTime());
+    Assert.assertEquals(scmUrl, versionInfo.getSCMURL());
+  }
+
+  @Test
+  public void testNonExistentFile() {
+    VersionInfo versionInfo = new VersionInfo("test4");
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/test/resources/test1-version-info.properties
----------------------------------------------------------------------
diff --git a/tez-api/src/test/resources/test1-version-info.properties b/tez-api/src/test/resources/test1-version-info.properties
new file mode 100644
index 0000000..ebb4c03
--- /dev/null
+++ b/tez-api/src/test/resources/test1-version-info.properties
@@ -0,0 +1,22 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+version=0.6.0-SNAPSHOT
+revision=d523db65804a5742ce50824e6fcfb8a04d184c0d
+buildtime=20141024-1052
+scmurl=scm:git:https://git-wip-us.apache.org/repos/asf/tez.git

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/test/resources/test2-version-info.properties
----------------------------------------------------------------------
diff --git a/tez-api/src/test/resources/test2-version-info.properties b/tez-api/src/test/resources/test2-version-info.properties
new file mode 100644
index 0000000..ad12f63
--- /dev/null
+++ b/tez-api/src/test/resources/test2-version-info.properties
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+version=0.6.0-SNAPSHOT
+revision=d523db65804a5742ce50824e6fcfb8a04d184c0d
+buildtime=20141024-1052

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-api/src/test/resources/test3-version-info.properties
----------------------------------------------------------------------
diff --git a/tez-api/src/test/resources/test3-version-info.properties b/tez-api/src/test/resources/test3-version-info.properties
new file mode 100644
index 0000000..401f382
--- /dev/null
+++ b/tez-api/src/test/resources/test3-version-info.properties
@@ -0,0 +1,22 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+version=0.6.0-SNAPSHOT
+revision=d523db65804a5742ce50824e6fcfb8a04d184c0d
+buildtime=
+scmurl=scm:git:https://git-wip-us.apache.org/repos/asf/tez.git

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-dag/pom.xml
----------------------------------------------------------------------
diff --git a/tez-dag/pom.xml b/tez-dag/pom.xml
index e5d6d22..12f0561 100644
--- a/tez-dag/pom.xml
+++ b/tez-dag/pom.xml
@@ -128,6 +128,28 @@
   </dependencies>
 
   <build>
+   <!--
+    Include all files in src/main/resources.  By default, do not apply property
+    substitution (filtering=false), but do apply property substitution to
+    version-info.properties (filtering=true).  This will substitute the
+    version information correctly, but prevent Maven from altering other files.
+    -->
+    <resources>
+      <resource>
+        <directory>${basedir}/src/main/resources</directory>
+        <excludes>
+          <exclude>tez-dag-version-info.properties</exclude>
+        </excludes>
+        <filtering>false</filtering>
+      </resource>
+      <resource>
+        <directory>${basedir}/src/main/resources</directory>
+        <includes>
+          <include>tez-dag-version-info.properties</include>
+        </includes>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
     <plugins>
       <plugin>
         <groupId>org.apache.rat</groupId>

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-dag/src/main/java/org/apache/tez/client/LocalClient.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/client/LocalClient.java b/tez-dag/src/main/java/org/apache/tez/client/LocalClient.java
index bd7089f..9848159 100644
--- a/tez-dag/src/main/java/org/apache/tez/client/LocalClient.java
+++ b/tez-dag/src/main/java/org/apache/tez/client/LocalClient.java
@@ -68,6 +68,7 @@ public class LocalClient extends FrameworkClient {
   private final long TIME_OUT = 60 * 1000;
   private int appIdNumber = 1;
   private boolean isSession;
+  private TezApiVersionInfo versionInfo = new TezApiVersionInfo();
 
   public LocalClient() {
   }
@@ -314,6 +315,7 @@ public class LocalClient extends FrameworkClient {
       ContainerId cId, String currentHost, int nmPort, int nmHttpPort,
       Clock clock, long appSubmitTime, boolean isSession, String userDir) {
     return new DAGAppMaster(applicationAttemptId, cId, currentHost, nmPort, nmHttpPort,
-        new SystemClock(), appSubmitTime, isSession, userDir);
+        new SystemClock(), appSubmitTime, isSession, userDir, versionInfo.getVersion());
   }
+
 }

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java b/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
index 407ede1..20da85b 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
@@ -91,6 +91,7 @@ import org.apache.hadoop.yarn.util.SystemClock;
 import org.apache.tez.common.TezCommonUtils;
 import org.apache.tez.common.TezConverterUtils;
 import org.apache.tez.common.TezUtilsInternal;
+import org.apache.tez.common.VersionInfo;
 import org.apache.tez.common.counters.Limits;
 import org.apache.tez.common.security.JobTokenIdentifier;
 import org.apache.tez.common.security.TokenCache;
@@ -150,6 +151,7 @@ import org.apache.tez.dag.records.TezDAGID;
 import org.apache.tez.dag.utils.Graph;
 import org.apache.tez.dag.utils.RelocalizationUtils;
 import org.apache.tez.common.security.JobTokenSecretManager;
+import org.apache.tez.dag.utils.Simple2LevelVersionComparator;
 import org.codehaus.jettison.json.JSONException;
 
 import com.google.common.annotations.VisibleForTesting;
@@ -260,13 +262,20 @@ public class DAGAppMaster extends AbstractService {
   private final AtomicInteger killedDAGs = new AtomicInteger();
   private ACLManager aclManager;
 
+  // Version checks
+  private TezDagVersionInfo dagVersionInfo;
+  private String clientVersion;
+  private boolean versionMismatch = false;
+  private String versionMismatchDiagnostics;
+
   // must be LinkedHashMap to preserve order of service addition
   Map<Service, ServiceWithDependency> services =
       new LinkedHashMap<Service, ServiceWithDependency>();
 
   public DAGAppMaster(ApplicationAttemptId applicationAttemptId,
       ContainerId containerId, String nmHost, int nmPort, int nmHttpPort,
-      Clock clock, long appSubmitTime, boolean isSession, String workingDirectory) {
+      Clock clock, long appSubmitTime, boolean isSession, String workingDirectory,
+      String clientVersion) {
     super(DAGAppMaster.class.getName());
     this.clock = clock;
     this.startTime = clock.getTime();
@@ -280,15 +289,26 @@ public class DAGAppMaster extends AbstractService {
     this.isSession = isSession;
     this.workingDirectory = workingDirectory;
     this.shutdownHandler = new DAGAppMasterShutdownHandler();
+    this.dagVersionInfo = new TezDagVersionInfo();
+    this.clientVersion = clientVersion;
 
     // TODO Metrics
     //this.metrics = DAGAppMetrics.create();
-    LOG.info("Created DAGAppMaster for application " + applicationAttemptId);
+    LOG.info("Created DAGAppMaster for application " + applicationAttemptId
+        + ", versionInfo=" + dagVersionInfo.toString());
   }
 
   @Override
   public synchronized void serviceInit(final Configuration conf) throws Exception {
 
+    this.amConf = conf;
+    this.isLocal = conf.getBoolean(TezConfiguration.TEZ_LOCAL_MODE,
+        TezConfiguration.TEZ_LOCAL_MODE_DEFAULT);
+
+    boolean disableVersionCheck = conf.getBoolean(
+        TezConfiguration.TEZ_AM_DISABLE_CLIENT_VERSION_CHECK,
+        TezConfiguration.TEZ_AM_DISABLE_CLIENT_VERSION_CHECK_DEFAULT);
+
     int maxAppAttempts = 1;
     String maxAppAttemptsEnv = System.getenv(
         ApplicationConstants.MAX_APP_ATTEMPTS_ENV);
@@ -297,9 +317,24 @@ public class DAGAppMaster extends AbstractService {
     }
     isLastAMRetry = appAttemptID.getAttemptId() >= maxAppAttempts;
 
-    this.amConf = conf;
-    this.isLocal = conf.getBoolean(TezConfiguration.TEZ_LOCAL_MODE,
-        TezConfiguration.TEZ_LOCAL_MODE_DEFAULT);
+    // Check client - AM version compatibility
+    LOG.info("Comparing client version with AM version"
+        + ", clientVersion=" + clientVersion
+        + ", AMVersion=" + dagVersionInfo.getVersion());
+    Simple2LevelVersionComparator versionComparator = new Simple2LevelVersionComparator();
+    if (versionComparator.compare(clientVersion, dagVersionInfo.getVersion()) != 0) {
+      versionMismatchDiagnostics = "Incompatible versions found"
+          + ", clientVersion=" + clientVersion
+          + ", AMVersion=" + dagVersionInfo.getVersion();
+      if (disableVersionCheck) {
+        LOG.warn("Ignoring client-AM version mismatch as check disabled. "
+            + versionMismatchDiagnostics);
+      } else {
+        LOG.fatal(versionMismatchDiagnostics);
+        versionMismatch = true;
+      }
+    }
+
     if (isLocal) {
        UserGroupInformation.setConfiguration(conf);
        appMasterUgi = UserGroupInformation.getCurrentUser();
@@ -390,6 +425,7 @@ public class DAGAppMaster extends AbstractService {
     this.sessionTimeoutInterval = 1000 * amConf.getInt(
             TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS,
             TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS_DEFAULT);
+
     recoveryDataDir = TezCommonUtils.getRecoveryPath(tezSystemStagingDir, conf);
     recoveryFS = recoveryDataDir.getFileSystem(conf);
     currentRecoveryDataDir = TezCommonUtils.getAttemptRecoveryPath(recoveryDataDir,
@@ -399,34 +435,39 @@ public class DAGAppMaster extends AbstractService {
           + " tezSystemStagingDir :" + tezSystemStagingDir + " recoveryDataDir :" + recoveryDataDir
           + " recoveryAttemptDir :" + currentRecoveryDataDir);
     }
-    if (isSession) {
-      FileInputStream sessionResourcesStream = null;
-      try {
-        sessionResourcesStream = new FileInputStream(
-          new File(workingDirectory, TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
-        PlanLocalResourcesProto amLocalResourceProto = PlanLocalResourcesProto
-            .parseDelimitedFrom(sessionResourcesStream);
-        amResources.putAll(DagTypeConverters.convertFromPlanLocalResources(amLocalResourceProto));
-      } finally {
-        if (sessionResourcesStream != null) {
-          sessionResourcesStream.close();
+    recoveryEnabled = conf.getBoolean(TezConfiguration.DAG_RECOVERY_ENABLED,
+        TezConfiguration.DAG_RECOVERY_ENABLED_DEFAULT);
+
+    if (!versionMismatch) {
+      if (isSession) {
+        FileInputStream sessionResourcesStream = null;
+        try {
+          sessionResourcesStream = new FileInputStream(
+              new File(workingDirectory, TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
+          PlanLocalResourcesProto amLocalResourceProto = PlanLocalResourcesProto
+              .parseDelimitedFrom(sessionResourcesStream);
+          amResources.putAll(DagTypeConverters.convertFromPlanLocalResources(amLocalResourceProto));
+        } finally {
+          if (sessionResourcesStream != null) {
+            sessionResourcesStream.close();
+          }
         }
       }
     }
 
-    recoveryEnabled = conf.getBoolean(TezConfiguration.DAG_RECOVERY_ENABLED,
-        TezConfiguration.DAG_RECOVERY_ENABLED_DEFAULT);
-
     initServices(conf);
     super.serviceInit(conf);
 
-    AMLaunchedEvent launchedEvent = new AMLaunchedEvent(appAttemptID,
-        startTime, appSubmitTime, appMasterUgi.getShortUserName());
-    historyEventHandler.handle(
-        new DAGHistoryEvent(launchedEvent));
-
-    this.state = DAGAppMasterState.INITED;
+    if (!versionMismatch) {
+      AMLaunchedEvent launchedEvent = new AMLaunchedEvent(appAttemptID,
+          startTime, appSubmitTime, appMasterUgi.getShortUserName());
+      historyEventHandler.handle(
+          new DAGHistoryEvent(launchedEvent));
 
+      this.state = DAGAppMasterState.INITED;
+    } else {
+      this.state = DAGAppMasterState.ERROR;
+    }
   }
 
   @VisibleForTesting
@@ -923,6 +964,9 @@ public class DAGAppMaster extends AbstractService {
   }
 
   public List<String> getDiagnostics() {
+    if (versionMismatch) {
+      return Collections.singletonList(versionMismatchDiagnostics);
+    }
     if (!isSession) {
       if(currentDAG != null) {
         return currentDAG.getDiagnostics();
@@ -1006,6 +1050,10 @@ public class DAGAppMaster extends AbstractService {
 
   public synchronized String submitDAGToAppMaster(DAGPlan dagPlan,
       Map<String, LocalResource> additionalResources) throws TezException {
+    if (this.versionMismatch) {
+      throw new TezException("Unable to accept DAG submissions as the ApplicationMaster is"
+          + " incompatible with the client. " + versionMismatchDiagnostics);
+    }
     if(currentDAG != null
         && !state.equals(DAGAppMasterState.IDLE)) {
       throw new TezException("App master already running a DAG");
@@ -1479,7 +1527,14 @@ public class DAGAppMaster extends AbstractService {
     //start all the components
     startServices();
     super.serviceStart();
-    
+
+    if (versionMismatch) {
+      // Short-circuit and return as no DAG should not be run
+      this.taskSchedulerEventHandler.setShouldUnregisterFlag();
+      shutdownHandler.shutdown();
+      return;
+    }
+
     // metrics system init is really init & start.
     // It's more test friendly to put it here.
     DefaultMetricsSystem.initialize("DAGAppMaster");
@@ -1721,6 +1776,10 @@ public class DAGAppMaster extends AbstractService {
           System.getenv(Environment.NM_HTTP_PORT.name());
       String appSubmitTimeStr =
           System.getenv(ApplicationConstants.APP_SUBMIT_TIME_ENV);
+      String clientVersion = System.getenv(TezConstants.TEZ_CLIENT_VERSION_ENV);
+      if (clientVersion == null) {
+        clientVersion = VersionInfo.UNKNOWN;
+      }
 
       validateInputParam(appSubmitTimeStr,
           ApplicationConstants.APP_SUBMIT_TIME_ENV);
@@ -1731,7 +1790,6 @@ public class DAGAppMaster extends AbstractService {
 
       long appSubmitTime = Long.parseLong(appSubmitTimeStr);
 
-
       String jobUserName = System
           .getenv(ApplicationConstants.Environment.USER.name());
 
@@ -1747,7 +1805,7 @@ public class DAGAppMaster extends AbstractService {
               Integer.parseInt(nodePortString),
               Integer.parseInt(nodeHttpPortString), new SystemClock(), appSubmitTime,
               cliParser.hasOption(TezConstants.TEZ_SESSION_MODE_CLI_OPTION),
-              System.getenv(Environment.PWD.name()));
+              System.getenv(Environment.PWD.name()), clientVersion);
       ShutdownHookManager.get().addShutdownHook(
         new DAGAppMasterShutdownHook(appMaster), SHUTDOWN_HOOK_PRIORITY);
 

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-dag/src/main/java/org/apache/tez/dag/app/TezDagVersionInfo.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/TezDagVersionInfo.java b/tez-dag/src/main/java/org/apache/tez/dag/app/TezDagVersionInfo.java
new file mode 100644
index 0000000..38b42a2
--- /dev/null
+++ b/tez-dag/src/main/java/org/apache/tez/dag/app/TezDagVersionInfo.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tez.dag.app;
+
+import org.apache.tez.common.VersionInfo;
+
+public class TezDagVersionInfo extends VersionInfo {
+
+  public TezDagVersionInfo() {
+    super("tez-dag");
+  }
+}

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-dag/src/main/java/org/apache/tez/dag/utils/Simple2LevelVersionComparator.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/utils/Simple2LevelVersionComparator.java b/tez-dag/src/main/java/org/apache/tez/dag/utils/Simple2LevelVersionComparator.java
new file mode 100644
index 0000000..c36c0d0
--- /dev/null
+++ b/tez-dag/src/main/java/org/apache/tez/dag/utils/Simple2LevelVersionComparator.java
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tez.dag.utils;
+
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Basic class to compare 2 version strings.
+ * Handles basic versions containing integers separated by '.' followed by a
+ * hyphen and a classifier.
+ * For example, 0.1.1 or 0.1-SNAPSHOT or 1.0.0-SNAPSHOT
+ * When comparing, it only compares the first 2 integer digits. i.e. for versions in
+ * the format x.y.z-qualifier, it will only look for and compare x.y. For example,
+ * 0.1.1 will be equal to 0.1.2 but 0.1.2 and 0.2.1 are not equal.
+ */
+public class Simple2LevelVersionComparator {
+
+  private static final Log LOG = LogFactory.getLog(Simple2LevelVersionComparator.class);
+
+  public static class Version {
+
+    int majorVersion = -1;
+    int minorVersion = -1;
+
+    public Version(String versionString) {
+      int index = 0;
+      StringTokenizer tokenizer = new StringTokenizer(versionString, ".-", true);
+      while (tokenizer.hasMoreTokens()) {
+        String token = tokenizer.nextToken();
+        if (token.equals("-")) {
+          break;
+        }
+        if (token.equals(".")) {
+          continue;
+        }
+        try {
+          int i = Integer.valueOf(token);
+          if (index == 0) {
+            majorVersion = i;
+          } else if (index == 1) {
+            minorVersion = i;
+            break;
+          }
+          ++index;
+        } catch (NumberFormatException nfe) {
+          break;
+        }
+      }
+    }
+
+  }
+
+  public int compare(String versionStr1, String versionStr2) {
+    Version v1 = new Version(versionStr1);
+    Version v2 = new Version(versionStr2);
+
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Comparing versions"
+          + " version1=" + v1.majorVersion + "." + v1.minorVersion
+          + ", version2=" + v2.majorVersion + "." + v2.minorVersion);
+    }
+
+    if (v1.majorVersion == -1 || v2.majorVersion == -1) {
+      return -1;
+    }
+    if (v1.majorVersion == v2.majorVersion) {
+      if ((v1.minorVersion == -1 && v2.minorVersion != -1)
+          || (v1.minorVersion != -1 && v2.minorVersion == -1)) {
+        return -1;
+      }
+      if (v1.minorVersion > v2.minorVersion) {
+        return 1;
+      } else if (v1.minorVersion < v2.minorVersion) {
+        return -1;
+      } else {
+        return 0;
+      }
+    } else {
+      if (v1.majorVersion > v2.majorVersion) {
+        return 1;
+      } else {
+        return -1;
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-dag/src/main/resources/tez-dag-version-info.properties
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/resources/tez-dag-version-info.properties b/tez-dag/src/main/resources/tez-dag-version-info.properties
new file mode 100644
index 0000000..4bb7d40
--- /dev/null
+++ b/tez-dag/src/main/resources/tez-dag-version-info.properties
@@ -0,0 +1,22 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+version=${pom.version}
+revision=${buildNumber}
+buildtime=${build.time}
+scmurl=${scm.url}

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-dag/src/test/java/org/apache/tez/dag/app/MockDAGAppMaster.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/MockDAGAppMaster.java b/tez-dag/src/test/java/org/apache/tez/dag/app/MockDAGAppMaster.java
index 570bf66..b4109e7 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/MockDAGAppMaster.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/MockDAGAppMaster.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
 import org.apache.hadoop.yarn.api.records.ContainerStatus;
 import org.apache.hadoop.yarn.util.Clock;
+import org.apache.tez.client.TezApiVersionInfo;
 import org.apache.tez.common.ContainerContext;
 import org.apache.tez.common.ContainerTask;
 import org.apache.tez.dag.api.TezUncheckedException;
@@ -264,7 +265,7 @@ public class MockDAGAppMaster extends DAGAppMaster {
       String nmHost, int nmPort, int nmHttpPort, Clock clock, long appSubmitTime,
       boolean isSession, String workingDirectory, AtomicBoolean launcherGoFlag) {
     super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, clock, appSubmitTime,
-        isSession, workingDirectory);
+        isSession, workingDirectory, new TezApiVersionInfo().getVersion());
     containerLauncher = new MockContainerLauncher(launcherGoFlag);
     shutdownHandler = new MockDAGAppMasterShutdownHandler();
   }

http://git-wip-us.apache.org/repos/asf/tez/blob/d59b2318/tez-dag/src/test/java/org/apache/tez/dag/utils/TestSimple2LevelVersionComparator.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/utils/TestSimple2LevelVersionComparator.java b/tez-dag/src/test/java/org/apache/tez/dag/utils/TestSimple2LevelVersionComparator.java
new file mode 100644
index 0000000..1152313
--- /dev/null
+++ b/tez-dag/src/test/java/org/apache/tez/dag/utils/TestSimple2LevelVersionComparator.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tez.dag.utils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestSimple2LevelVersionComparator {
+
+  private final Simple2LevelVersionComparator comparator = new Simple2LevelVersionComparator();
+
+  @Test
+  public void testBasicEqualChecks() {
+    Assert.assertEquals(0, comparator.compare("1-SNAPSHOT", "1-SNAPSHOT"));
+    Assert.assertEquals(0, comparator.compare("1.1-SNAPSHOT", "1.1-SNAPSHOT"));
+    Assert.assertEquals(0, comparator.compare("1.1.0-SNAPSHOT", "1.1.0-SNAPSHOT"));
+    Assert.assertEquals(0, comparator.compare("0.1.0", "0.1.0"));
+    Assert.assertEquals(0, comparator.compare("0.1", "0.1"));
+    Assert.assertEquals(0, comparator.compare("0.1.2", "0.1.3"));
+    Assert.assertEquals(0, comparator.compare("1.1.2", "1.1.5-RC"));
+    Assert.assertEquals(0, comparator.compare("1", "1"));
+    Assert.assertEquals(0, comparator.compare("1.1.x", "1.1.x"));
+    Assert.assertEquals(0, comparator.compare("1-SNAP.x", "1-SNAP.x"));
+  }
+
+  @Test
+  public void testInvalidVersions() {
+    Assert.assertEquals(-1, comparator.compare("x.1", "x.1"));
+    Assert.assertEquals(-1, comparator.compare("x.1", "0.1"));
+    Assert.assertEquals(-1, comparator.compare("1.x", "1.1"));
+    Assert.assertEquals(-1, comparator.compare("1.1", "x.1"));
+    Assert.assertEquals(-1, comparator.compare("1.1", "1.x"));
+    Assert.assertEquals(-1, comparator.compare("1.1", "Unknown"));
+    Assert.assertEquals(-1, comparator.compare("Unknown", "1.1"));
+    Assert.assertEquals(-1, comparator.compare("Unknown", "Unknown"));
+  }
+
+  @Test
+  public void testInequalityChecks() {
+    Assert.assertEquals(-1, comparator.compare("1.1", "2.1"));
+    Assert.assertEquals(1, comparator.compare("1.1", "0.1"));
+    Assert.assertEquals(1, comparator.compare("1.1.2", "0.1.2"));
+    Assert.assertEquals(-1, comparator.compare("1.1.9", "4.1.9"));
+    Assert.assertEquals(-1, comparator.compare("1.1-RC", "2.1.x"));
+    Assert.assertEquals(-1, comparator.compare("1.1", ""));
+    Assert.assertEquals(-1, comparator.compare("", "1.1"));
+  }
+
+
+}


Mime
View raw message