diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index fbdcba77da4..70d42bf8a8d 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -74,6 +74,9 @@ Trunk (unreleased changes) MAPREDUCE-3500. MRJobConfig creates an LD_LIBRARY_PATH using the platform ARCH. (tucu) + MAPREDUCE-3389. MRApps loads the 'mrapp-generated-classpath' file with + classpath from the build machine. (tucu) + Release 0.23.1 - Unreleased INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java index 11eca7ea3d7..510278c65b2 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java @@ -22,6 +22,7 @@ import static org.apache.hadoop.yarn.util.StringHelper._join; import static org.apache.hadoop.yarn.util.StringHelper._split; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -180,18 +181,23 @@ public class MRApps extends Apps { String mrAppGeneratedClasspathFile = "mrapp-generated-classpath"; classpathFileStream = thisClassLoader.getResourceAsStream(mrAppGeneratedClasspathFile); + // Put the file itself on classpath for tasks. + String classpathElement = thisClassLoader.getResource(mrAppGeneratedClasspathFile).getFile(); + if (classpathElement.contains("!")) { + classpathElement = classpathElement.substring(0, classpathElement.indexOf("!")); + } + else { + classpathElement = new File(classpathElement).getParent(); + } + Apps.addToEnvironment( + environment, + Environment.CLASSPATH.name(), classpathElement); + reader = new BufferedReader(new InputStreamReader(classpathFileStream)); String cp = reader.readLine(); if (cp != null) { Apps.addToEnvironment(environment, Environment.CLASSPATH.name(), cp.trim()); - } - // Put the file itself on classpath for tasks. - Apps.addToEnvironment( - environment, - Environment.CLASSPATH.name(), - thisClassLoader.getResource(mrAppGeneratedClasspathFile).getFile() - .split("!")[0]); - + } // Add standard Hadoop classes for (String c : ApplicationConstants.APPLICATION_CLASSPATH) { Apps.addToEnvironment(environment, Environment.CLASSPATH.name(), c);