hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077549 - in /hadoop/common/branches/branch-0.20-security-patches: bin/hadoop src/mapred/org/apache/hadoop/mapred/TaskRunner.java
Date Fri, 04 Mar 2011 04:28:01 GMT
Author: omalley
Date: Fri Mar  4 04:28:01 2011
New Revision: 1077549

URL: http://svn.apache.org/viewvc?rev=1077549&view=rev
Log:
commit af96a354d0684509cee3e42941fe0aefd025d60d
Author: Devaraj Das <ddas@yahoo-inc.com>
Date:   Thu Jul 15 23:42:06 2010 -0700

    MAPREDUCE-1938. Introduces a configuration for putting user classes before the system
classes during job submission and in task launches. Contributed by Devaraj Das.
    
    +++ b/YAHOO-CHANGES.txt
    +    MAPREDUCE-1938. Introduces a configuration for putting user classes before
    +    the system classes during job submission and in task launches. (ddas)
    +

Modified:
    hadoop/common/branches/branch-0.20-security-patches/bin/hadoop
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/TaskRunner.java

Modified: hadoop/common/branches/branch-0.20-security-patches/bin/hadoop
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/bin/hadoop?rev=1077549&r1=1077548&r2=1077549&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/bin/hadoop (original)
+++ hadoop/common/branches/branch-0.20-security-patches/bin/hadoop Fri Mar  4 04:28:01 2011
@@ -24,6 +24,12 @@
 #
 #   HADOOP_CLASSPATH Extra Java CLASSPATH entries.
 #
+#   HADOOP_USER_CLASSPATH_FIRST      When defined, the HADOOP_CLASSPATH is 
+#                                    added in the beginning of the global
+#                                    classpath. Can be defined, for example,
+#                                    by doing 
+#                                    export HADOOP_USER_CLASSPATH_FIRST=true
+#
 #   HADOOP_HEAPSIZE  The maximum amount of heap to use, in MB. 
 #                    Default is 1000.
 #
@@ -123,6 +129,9 @@ fi
 # CLASSPATH initially contains $HADOOP_CONF_DIR
 CLASSPATH="${HADOOP_CONF_DIR}"
 CLASSPATH=${CLASSPATH}:$JAVA_HOME/lib/tools.jar
+if [ "$HADOOP_USER_CLASSPATH_FIRST" != "" ] && [ "$HADOOP_CLASSPATH" != "" ] ; then
+  CLASSPATH=${CLASSPATH}:${HADOOP_CLASSPATH}
+fi
 
 # for developers, add Hadoop classes to CLASSPATH
 if [ -d "$HADOOP_HOME/build/classes" ]; then
@@ -172,7 +181,7 @@ for f in $HADOOP_HOME/build/hadoop-tools
 done
 
 # add user-specified CLASSPATH last
-if [ "$HADOOP_CLASSPATH" != "" ]; then
+if [ "$HADOOP_USER_CLASSPATH_FIRST" = "" ] && [ "$HADOOP_CLASSPATH" != "" ]; then
   CLASSPATH=${CLASSPATH}:${HADOOP_CLASSPATH}
 fi
 

Modified: hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/TaskRunner.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/TaskRunner.java?rev=1077549&r1=1077548&r2=1077549&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/TaskRunner.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/TaskRunner.java
Fri Mar  4 04:28:01 2011
@@ -65,6 +65,8 @@ abstract class TaskRunner extends Thread
   private boolean exitCodeSet = false;
   
   private static String SYSTEM_PATH_SEPARATOR = System.getProperty("path.separator");
+  static final String MAPREDUCE_USER_CLASSPATH_FIRST =
+        "mapreduce.user.classpath.first"; //a semi-hidden config
 
   
   private TaskTracker tracker;
@@ -482,8 +484,14 @@ abstract class TaskRunner extends Thread
       throws IOException {
     // Accumulates class paths for child.
     List<String> classPaths = new ArrayList<String>();
-    // start with same classpath as parent process
-    appendSystemClasspaths(classPaths);
+    
+    boolean userClassesTakesPrecedence = 
+      conf.getBoolean(MAPREDUCE_USER_CLASSPATH_FIRST,false);
+    
+    if (!userClassesTakesPrecedence) {
+      // start with same classpath as parent process
+      appendSystemClasspaths(classPaths);
+    }
 
     // include the user specified classpath
     appendJobJarClasspaths(conf.getJar(), classPaths);
@@ -493,6 +501,12 @@ abstract class TaskRunner extends Thread
     
     // Include the working dir too
     classPaths.add(workDir.toString());
+
+    if (userClassesTakesPrecedence) {
+      // parent process's classpath is added last
+      appendSystemClasspaths(classPaths);
+    }
+    
     return classPaths;
   }
 



Mime
View raw message