Pārlūkot izejas kodu

MAPREDUCE-4746. The MR Application Master does not have a config to set environment variables (Rob Parker via bobby)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1404674 13f79535-47bb-0310-9956-ffa450edef68
Robert Joseph Evans 12 gadi atpakaļ
vecāks
revīzija
b50a3c5de3

+ 3 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -623,6 +623,9 @@ Release 0.23.5 - UNRELEASED
     MAPREDUCE-4724. job history web ui applications page should be sorted to
     MAPREDUCE-4724. job history web ui applications page should be sorted to
     display last app first (tgraves via bobby)
     display last app first (tgraves via bobby)
 
 
+    MAPREDUCE-4746. The MR Application Master does not have a config to set
+    environment variables (Rob Parker via bobby)
+
 Release 0.23.4 - UNRELEASED
 Release 0.23.4 - UNRELEASED
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 3 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java

@@ -486,6 +486,9 @@ public interface MRJobConfig {
   public static final int DEFAULT_MR_AM_HISTORY_USE_BATCHED_FLUSH_QUEUE_SIZE_THRESHOLD =
   public static final int DEFAULT_MR_AM_HISTORY_USE_BATCHED_FLUSH_QUEUE_SIZE_THRESHOLD =
       50;
       50;
   
   
+  public static final String MR_AM_ENV =
+      MR_AM_PREFIX + "env";
+  
   public static final String MAPRED_MAP_ADMIN_JAVA_OPTS =
   public static final String MAPRED_MAP_ADMIN_JAVA_OPTS =
       "mapreduce.admin.map.child.java.opts";
       "mapreduce.admin.map.child.java.opts";
 
 

+ 27 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml

@@ -839,6 +839,33 @@
     mapreduce.job.end-notification.max.retry.interval</description>
     mapreduce.job.end-notification.max.retry.interval</description>
 </property>
 </property>
 
 
+<property>
+  <name>yarn.app.mapreduce.am.env</name>
+  <value></value>
+  <description>User added environment variables for the MR App Master 
+  processes. Example :
+  1) A=foo  This will set the env variable A to foo
+  2) B=$B:c This is inherit tasktracker's B env variable.  
+  </description>
+</property>
+
+<property>
+  <name>yarn.app.mapreduce.am.command-opts</name>
+  <value>-Xmx1024m</value>
+  <description>Java opts for the MR App Master processes.  
+  The following symbol, if present, will be interpolated: @taskid@ is replaced 
+  by current TaskID. Any other occurrences of '@' will go unchanged.
+  For example, to enable verbose gc logging to a file named for the taskid in
+  /tmp and to set the heap maximum to be a gigabyte, pass a 'value' of:
+        -Xmx1024m -verbose:gc -Xloggc:/tmp/@taskid@.gc
+  
+  Usage of -Djava.library.path can cause programs to no longer function if
+  hadoop native libraries are used. These values should instead be set as part 
+  of LD_LIBRARY_PATH in the map / reduce JVM env using the mapreduce.map.env and 
+  mapreduce.reduce.env config settings. 
+  </description>
+</property>
+
 <property>
 <property>
   <name>yarn.app.mapreduce.am.job.task.listener.thread-count</name>
   <name>yarn.app.mapreduce.am.job.task.listener.thread-count</name>
   <value>30</value>
   <value>30</value>

+ 5 - 1
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java

@@ -397,7 +397,7 @@ public class YARNRunner implements ClientProtocol {
 
 
 
 
     Vector<String> vargsFinal = new Vector<String>(8);
     Vector<String> vargsFinal = new Vector<String>(8);
-    // Final commmand
+    // Final command
     StringBuilder mergedCommand = new StringBuilder();
     StringBuilder mergedCommand = new StringBuilder();
     for (CharSequence str : vargs) {
     for (CharSequence str : vargs) {
       mergedCommand.append(str).append(" ");
       mergedCommand.append(str).append(" ");
@@ -411,6 +411,10 @@ public class YARNRunner implements ClientProtocol {
     // i.e. add { Hadoop jars, job jar, CWD } to classpath.
     // i.e. add { Hadoop jars, job jar, CWD } to classpath.
     Map<String, String> environment = new HashMap<String, String>();
     Map<String, String> environment = new HashMap<String, String>();
     MRApps.setClasspath(environment, conf);
     MRApps.setClasspath(environment, conf);
+    
+    // Setup the environment variables (LD_LIBRARY_PATH, etc)
+    MRApps.setEnvFromInputString(environment, 
+        conf.get(MRJobConfig.MR_AM_ENV));
 
 
     // Parse distributed cache
     // Parse distributed cache
     MRApps.setupDistributedCache(jobConf, localResources);
     MRApps.setupDistributedCache(jobConf, localResources);