MAPREDUCE-3389. MRApps loads the 'mrapp-generated-classpath' file with classpath from the build machine. (tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1210548 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2011-12-05 18:02:47 +00:00
parent 0acc00bbab
commit 6a358ee140
2 changed files with 17 additions and 8 deletions

View File

@ -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

View File

@ -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);