hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acmur...@apache.org
Subject svn commit: r1378795 - in /hadoop/common/branches/branch-1-win: ./ src/core/org/apache/hadoop/util/ src/mapred/org/apache/hadoop/mapred/ src/test/org/apache/hadoop/mapred/
Date Thu, 30 Aug 2012 02:38:12 GMT
Author: acmurthy
Date: Thu Aug 30 02:38:11 2012
New Revision: 1378795

URL: http://svn.apache.org/viewvc?rev=1378795&view=rev
Log:
MAPREDUCE-4374. Completed support for configurable environment for child map/reduce tasks.
Contributed by Chuan Liu. 

Modified:
    hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
    hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/Shell.java
    hadoop/common/branches/branch-1-win/src/mapred/org/apache/hadoop/mapred/JobConf.java
    hadoop/common/branches/branch-1-win/src/mapred/org/apache/hadoop/mapred/TaskRunner.java
    hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestMiniMRChildTask.java
    hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestTaskEnvironment.java

Modified: hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt?rev=1378795&r1=1378794&r2=1378795&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt (original)
+++ hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt Thu Aug 30 02:38:11 2012
@@ -71,6 +71,9 @@ branch-hadoop-1-win - unreleased
 
     HADOOP-8453. Added unit tests for winutils. (Chuan Liu via acmurthy)
 
+    MAPREDUCE-4374. Completed support for configurable environment for child
+    map/reduce tasks. (Chuan Liu via acmurthy)
+
 BUG FIXES
 
     HDFS-6527. Backport HADOOP-7389: Use of TestingGroups by tests causes
@@ -91,3 +94,4 @@ BUG FIXES
 
     HADOOP-8732. Fix intermittent failures in tests by serializing process
     creation to get around a bug in MS Windows. (Ivan Mitic via acmurthy)
+

Modified: hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/Shell.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/Shell.java?rev=1378795&r1=1378794&r2=1378795&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/Shell.java (original)
+++ hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/Shell.java Thu Aug
30 02:38:11 2012
@@ -85,6 +85,12 @@ abstract public class Shell {
     return (WINDOWS) ? new String[] { WINUTILS, "chmod", perm }
                      : new String[] { "chmod", perm };
   }
+  
+  /** Return a regular expression string that match environment variables */
+  public static String getEnvironmentVariableRegex() {
+    return (WINDOWS) ? "%([A-Za-z_][A-Za-z0-9_]*?)%" :
+      "\\$([A-Za-z_][A-Za-z0-9_]*)";
+  }
 
   /** Return a command to set owner */
   public static String[] getSetOwnerCommand(String owner) {

Modified: hadoop/common/branches/branch-1-win/src/mapred/org/apache/hadoop/mapred/JobConf.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/mapred/org/apache/hadoop/mapred/JobConf.java?rev=1378795&r1=1378794&r2=1378795&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/mapred/org/apache/hadoop/mapred/JobConf.java (original)
+++ hadoop/common/branches/branch-1-win/src/mapred/org/apache/hadoop/mapred/JobConf.java Thu
Aug 30 02:38:11 2012
@@ -270,12 +270,14 @@ public class JobConf extends Configurati
    * Configuration key to set the environment of the child map/reduce tasks.
    * 
    * The format of the value is <code>k1=v1,k2=v2</code>. Further it can 
-   * reference existing environment variables via <code>$key</code>.
+   * reference existing environment variables via <code>$key</code> on
+   * Linux or <code>%key%</code> on Windows.
    * 
    * Example:
    * <ul>
    *   <li> A=foo - This will set the env variable A to foo. </li>
-   *   <li> B=$X:c This is inherit tasktracker's X env variable. </li>
+   *   <li> B=$X:c This is inherit tasktracker's X env variable on Linux. </li>
+   *   <li> B=%X%;c This is inherit tasktracker's X env variable on Windows. </li>
    * </ul>
    * 
    * @deprecated Use {@link #MAPRED_MAP_TASK_ENV} or 
@@ -285,31 +287,33 @@ public class JobConf extends Configurati
   public static final String MAPRED_TASK_ENV = "mapred.child.env";
 
   /**
-   * Configuration key to set the maximum virutal memory available to the
-   * map tasks.
+   * Configuration key to set the environment of the child map tasks.
    * 
    * The format of the value is <code>k1=v1,k2=v2</code>. Further it can 
-   * reference existing environment variables via <code>$key</code>.
+   * reference existing environment variables via <code>$key</code> on
+   * Linux or <code>%key%</code> on Windows.
    * 
    * Example:
    * <ul>
    *   <li> A=foo - This will set the env variable A to foo. </li>
-   *   <li> B=$X:c This is inherit tasktracker's X env variable. </li>
+   *   <li> B=$X:c This is inherit tasktracker's X env variable on Linux. </li>
+   *   <li> B=%X%;c This is inherit tasktracker's X env variable on Windows. </li>

    * </ul>
    */
   public static final String MAPRED_MAP_TASK_ENV = "mapred.map.child.env";
   
   /**
-   * Configuration key to set the maximum virutal memory available to the
-   * reduce tasks.
+   * Configuration key to set the environment of the child reduce tasks.
    * 
    * The format of the value is <code>k1=v1,k2=v2</code>. Further it can 
-   * reference existing environment variables via <code>$key</code>.
+   * reference existing environment variables via <code>$key</code> on
+   * Linux or <code>%key%</code> on Windows..
    * 
    * Example:
    * <ul>
    *   <li> A=foo - This will set the env variable A to foo. </li>
-   *   <li> B=$X:c This is inherit tasktracker's X env variable. </li>
+   *   <li> B=$X:c This is inherit tasktracker's X env variable on Linux. </li>
+   *   <li> B=%X%;c This is inherit tasktracker's X env variable on Windows. </li>
    * </ul>
    */
   public static final String MAPRED_REDUCE_TASK_ENV =

Modified: hadoop/common/branches/branch-1-win/src/mapred/org/apache/hadoop/mapred/TaskRunner.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/mapred/org/apache/hadoop/mapred/TaskRunner.java?rev=1378795&r1=1378794&r2=1378795&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/mapred/org/apache/hadoop/mapred/TaskRunner.java
(original)
+++ hadoop/common/branches/branch-1-win/src/mapred/org/apache/hadoop/mapred/TaskRunner.java
Thu Aug 30 02:38:11 2012
@@ -30,6 +30,8 @@ import java.util.Map;
 import java.util.Random;
 import java.util.Vector;
 import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -71,7 +73,8 @@ abstract class TaskRunner extends Thread
   static final String MAPRED_ADMIN_USER_HOME_DIR =
     "mapreduce.admin.user.home.dir";
 
-  static final String DEFAULT_HOME_DIR= "/homes/";
+  static final String DEFAULT_HOME_DIR =
+      System.getenv(Shell.WINDOWS ? "USERPROFILE" : "HOME");
   
   static final String HADOOP_WORK_DIR = "HADOOP_WORK_DIR";
   
@@ -507,13 +510,10 @@ abstract class TaskRunner extends Thread
 
     // if temp directory path is not absolute, prepend it with workDir.
     if (!tmpDir.isAbsolute()) {
-      if (Shell.WINDOWS) {
-        //review minwei:
-        String acmeDir = workDir.toString();
-        if (acmeDir.charAt(0) == '"') 
-          acmeDir = acmeDir.substring(1,acmeDir.length()-1);
-        tmpDir = new Path(acmeDir+ "/tmp");
-      } else
+      if (Shell.WINDOWS)
+        // trim leading and trailing quotes on Windows
+        tmpDir = new Path(workDir.toString().replaceAll("^\"|\"$", ""), tmp);
+      else
         tmpDir = new Path(workDir.toString(), tmp);
       if (createDir) {
         FileSystem localFs = FileSystem.getLocal(conf);
@@ -523,6 +523,13 @@ abstract class TaskRunner extends Thread
               tmpDir.toString());
         }
       }
+    } else if (createDir) {
+      FileSystem localFs = FileSystem.getLocal(conf);
+      if (!localFs.exists(tmpDir) && !localFs.mkdirs(tmpDir) && 
+          !localFs.getFileStatus(tmpDir).isDir()) {
+            throw new IOException("Mkdirs failed to create " +
+                tmpDir.toString());
+      }
     }
     return tmpDir;
   }
@@ -627,34 +634,24 @@ abstract class TaskRunner extends Thread
       for (String cEnv : childEnvs) {
         try {
           String[] parts = cEnv.split("="); // split on '='
-          String value = env.get(parts[0]);
-          
-          if (value != null) {
+          Pattern p = Pattern.compile(Shell.getEnvironmentVariableRegex());
+          Matcher m = p.matcher(parts[1]);
+          StringBuffer sb = new StringBuffer();
+          while (m.find()) {
+            String var = m.group(1);
             // replace $env with the child's env constructed by tt's
-            // example LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp
-            value = parts[1].replace("$" + parts[0], value);
-          } else {
-            // this key is not configured by the tt for the child .. get it
+            String replace = env.get(var);
+            // if this key is not configured by the tt for the child .. get it
             // from the tt's env
-            // example PATH=$PATH:/tmp
-            value = System.getenv(parts[0]);
-            if (value != null) {
-              // the env key is present in the tt's env
-              value = parts[1].replace("$" + parts[0], value);
-            } else {
-              // check for simple variable substitution
-              // for e.g. ROOT=$HOME
-              String envValue = System.getenv(parts[1].substring(1)); 
-              if (envValue != null) {
-                value = envValue;
-              } else {
-                // the env key is note present anywhere .. simply set it
-                // example X=$X:/tmp or X=/tmp
-                value = parts[1].replace("$" + parts[0], "");
-              }
-            }
+            if (replace == null)
+              replace = System.getenv(var);
+            // the env key is note present anywhere .. simply set it
+            if (replace == null)
+              replace = "";
+            m.appendReplacement(sb, Matcher.quoteReplacement(replace));
           }
-          env.put(parts[0], value);
+          m.appendTail(sb);
+          env.put(parts[0], sb.toString());
         } catch (Throwable t) {
           // set the error msg
           errorInfo = "Invalid User environment settings : " + mapredChildEnv
@@ -798,13 +795,11 @@ abstract class TaskRunner extends Thread
   private static void symlink(File workDir, String target, String link)
       throws IOException {
     if (link != null) {
-      if (Shell.WINDOWS){
-        String path = workDir.toString();
-        path = path.substring(1,path.length()-1); //strip leading and trailing quotes
-        link = path + "\\" + link;
-      }
+      if (Shell.WINDOWS)
+        // trim leading and trailing quotes on Windows
+        link = workDir.toString().replaceAll("^\"|\"$", "") + File.separator + link;
       else
-        link = workDir.toString() + Path.SEPARATOR + link;
+        link = workDir.toString() + File.separator + link;
       File flink = new File(link);
       if (!flink.exists()) {
         LOG.info(String.format("Creating symlink: %s <- %s", target, link));

Modified: hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestMiniMRChildTask.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestMiniMRChildTask.java?rev=1378795&r1=1378794&r2=1378795&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestMiniMRChildTask.java
(original)
+++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestMiniMRChildTask.java
Thu Aug 30 02:38:11 2012
@@ -32,6 +32,7 @@ import org.apache.hadoop.io.WritableComp
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapred.lib.IdentityReducer;
+import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 
@@ -48,6 +49,8 @@ public class TestMiniMRChildTask extends
   private final static String TASK_OPTS_VAL = "-Xmx200m";
   private final static String MAP_OPTS_VAL = "-Xmx200m";
   private final static String REDUCE_OPTS_VAL = "-Xmx300m";
+  
+  private final static String TMP_PATH = Shell.WINDOWS ? "C:\\tmp" : "/tmp";
 
   private MiniMRCluster mr;
   private MiniDFSCluster dfs;
@@ -158,11 +161,14 @@ public class TestMiniMRChildTask extends
 
   private static void checkEnv(String envName, String expValue, String mode) {
     String envValue = System.getenv(envName).trim();
+    // trim leading and trailing quotes on Windows 
+    if (Shell.WINDOWS)
+      envValue = envValue.replaceAll("^\"|\"$", "");
     if ("append".equals(mode)) {
-      if (envValue == null || !envValue.contains(":")) {
+      if (envValue == null || !envValue.contains(File.pathSeparator)) {
         throw new RuntimeException("Missing env variable");
       } else {
-        String parts[] = envValue.split(":");
+        String parts[] = envValue.split(File.pathSeparator);
         // check if the value is appended
         if (!parts[parts.length - 1].equals(expValue)) {
           throw new RuntimeException("Wrong env variable in append mode");
@@ -174,6 +180,30 @@ public class TestMiniMRChildTask extends
       }
     }
   }
+  
+  private static void checkEnvs(JobConf job) {
+    String path = job.get("path");
+    
+    // check if the pwd is there in LD_LIBRARY_PATH on Linux
+    if (!Shell.WINDOWS) {        
+      String pwd = System.getenv("PWD");
+      assertTrue("LD_LIBRARY_PATH doesnt contain pwd", System.getenv("LD_LIBRARY_PATH")
+          .contains(pwd));
+    }
+    
+    // check if X=$X:/abc or X=%X%;C:\abc works for LD_LIBRARY_PATH
+    checkEnv("LD_LIBRARY_PATH", TMP_PATH, "append");
+    // check if X=/tmp works for an already existing parameter
+    checkEnv("HOME", TMP_PATH, "noappend");
+    // check if X=/tmp for a new env variable
+    checkEnv("MY_PATH", TMP_PATH, "noappend");
+    // check if X=$X:/tmp or X=%X%;C:\tmp works for a new env var and results
+    // into :/tmp or ;C:\tmp on Linux or Windows respectively
+    checkEnv("NEW_PATH", File.pathSeparator + TMP_PATH, "noappend");
+    // check if X=$(tt's X var):/tmp or X=%(tt's X var)%:C:\tmp for an old env
+    // variable inherited from the tt
+    checkEnv("PATH", path + File.pathSeparator + TMP_PATH, "noappend");
+  }
 
   // Mappers that simply checks if the desired user env are present or not
   static class EnvCheckMapper extends MapReduceBase implements
@@ -196,26 +226,7 @@ public class TestMiniMRChildTask extends
                      mapJavaOpts, 
                      mapJavaOpts, MAP_OPTS_VAL);
       }
-
-      String path = job.get("path");
-      
-      // check if the pwd is there in LD_LIBRARY_PATH
-      String pwd = System.getenv("PWD");
-      
-      assertTrue("LD doesnt contain pwd", 
-                 System.getenv("LD_LIBRARY_PATH").contains(pwd));
-      
-      // check if X=$X:/abc works for LD_LIBRARY_PATH
-      checkEnv("LD_LIBRARY_PATH", "/tmp", "append");
-      // check if X=/tmp works for an already existing parameter
-      checkEnv("HOME", "/tmp", "noappend");
-      // check if X=/tmp for a new env variable
-      checkEnv("MY_PATH", "/tmp", "noappend");
-      // check if X=$X:/tmp works for a new env var and results into :/tmp
-      checkEnv("NEW_PATH", ":/tmp", "noappend");
-      // check if X=$(tt's X var):/tmp for an old env variable inherited from 
-      // the tt
-      checkEnv("PATH",  path + ":/tmp", "noappend");
+      checkEnvs(job);
     }
 
     public void map(WritableComparable key, Writable value,
@@ -246,27 +257,7 @@ public class TestMiniMRChildTask extends
                      reduceJavaOpts, 
                      reduceJavaOpts, REDUCE_OPTS_VAL);
       }
-
-      String path = job.get("path");
-      
-      // check if the pwd is there in LD_LIBRARY_PATH
-      String pwd = System.getenv("PWD");
-      
-      assertTrue("LD doesnt contain pwd", 
-                 System.getenv("LD_LIBRARY_PATH").contains(pwd));
-      
-      // check if X=$X:/abc works for LD_LIBRARY_PATH
-      checkEnv("LD_LIBRARY_PATH", "/tmp", "append");
-      // check if X=/tmp works for an already existing parameter
-      checkEnv("HOME", "/tmp", "noappend");
-      // check if X=/tmp for a new env variable
-      checkEnv("MY_PATH", "/tmp", "noappend");
-      // check if X=$X:/tmp works for a new env var and results into :/tmp
-      checkEnv("NEW_PATH", ":/tmp", "noappend");
-      // check if X=$(tt's X var):/tmp for an old env variable inherited from 
-      // the tt
-      checkEnv("PATH",  path + ":/tmp", "noappend");
-
+      checkEnvs(job);
     }
 
     @Override
@@ -403,12 +394,15 @@ public class TestMiniMRChildTask extends
       mapTaskJavaOptsKey = reduceTaskJavaOptsKey = JobConf.MAPRED_TASK_JAVA_OPTS;
       mapTaskJavaOpts = reduceTaskJavaOpts = TASK_OPTS_VAL;
     }
-    conf.set(mapTaskEnvKey,
-             "MY_PATH=/tmp,HOME=/tmp,LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp," +
-             "PATH=$PATH:/tmp,NEW_PATH=$NEW_PATH:/tmp");
-    conf.set(reduceTaskEnvKey,
-             "MY_PATH=/tmp,HOME=/tmp,LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp," +
-             "PATH=$PATH:/tmp,NEW_PATH=$NEW_PATH:/tmp");
+
+    String envKey = String.format(Shell.WINDOWS ? "MY_PATH=%1$s,HOME=%1$s,"
+        + "LD_LIBRARY_PATH=%%LD_LIBRARY_PATH%%;%1$s,"
+        + "PATH=%%PATH%%;%1$s,NEW_PATH=%%NEW_PATH%%;%1$s"
+        : "MY_PATH=%1$s,HOME=%1$s,LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%1$s,"
+            + "PATH=$PATH:%1$s,NEW_PATH=$NEW_PATH:%1$s", TMP_PATH);
+
+    conf.set(mapTaskEnvKey, envKey);
+    conf.set(reduceTaskEnvKey, envKey);
 
     conf.set("path", System.getenv("PATH"));
 

Modified: hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestTaskEnvironment.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestTaskEnvironment.java?rev=1378795&r1=1378794&r2=1378795&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestTaskEnvironment.java
(original)
+++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestTaskEnvironment.java
Thu Aug 30 02:38:11 2012
@@ -17,35 +17,21 @@
  */
 package org.apache.hadoop.mapred;
 
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
 import java.io.IOException;
-import java.util.Vector;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.filecache.TrackerDistributedCacheManager;
-import org.apache.hadoop.fs.FileUtil;
-import org.apache.hadoop.mapred.JvmManager.JvmManagerForType;
-import org.apache.hadoop.mapred.JvmManager.JvmManagerForType.JvmRunner;
-import org.apache.hadoop.mapred.JvmManager.JvmEnv;
 import org.apache.hadoop.mapred.TaskTracker.RunningJob;
 import org.apache.hadoop.mapred.TaskTracker.TaskInProgress;
-import org.apache.hadoop.mapreduce.TaskType;
 import org.apache.hadoop.mapreduce.server.tasktracker.userlogs.UserLogManager;
+import org.apache.hadoop.util.Shell;
 import org.junit.After;
 import static org.junit.Assert.*;
 import org.junit.Before;
 import org.junit.Test;
 
 public class TestTaskEnvironment {
-  private static File TEST_DIR = new File(System.getProperty("test.build.data",
-      "/tmp"), TestJvmManager.class.getSimpleName());
   private static int MAP_SLOTS = 1;
   private static int REDUCE_SLOTS = 1;
   private TaskTracker tt;
@@ -54,12 +40,10 @@ public class TestTaskEnvironment {
 
   @Before
   public void setUp() {
-    TEST_DIR.mkdirs();
   }
 
   @After
   public void tearDown() throws IOException {
-    FileUtil.fullyDelete(TEST_DIR);
   }
 
   public TestTaskEnvironment() throws Exception {
@@ -75,26 +59,12 @@ public class TestTaskEnvironment {
     tt.setUserLogManager(new UserLogManager(ttConf));
   }
 
-  // write a shell script to execute the command.
-  private File writeScript(String fileName, String cmd, File pidFile) throws IOException
{
-    File script = new File(TEST_DIR, fileName);
-    FileOutputStream out = new FileOutputStream(script);
-    // write pid into a file
-    out.write(("echo $$ >" + pidFile.toString() + ";").getBytes());
-    // ignore SIGTERM
-    out.write(("trap '' 15\n").getBytes());
-    // write the actual command it self.
-    out.write(cmd.getBytes());
-    out.close();
-    script.setExecutable(true);
-    return script;
-  }
-
   @Test
   public void testTaskEnv() throws Throwable {
     ttConf.set("mapreduce.admin.user.shell", "/bin/testshell");
     ttConf.set("mapreduce.admin.user.env", "key1=value1,key2=value2");
-    ttConf.set("mapred.child.env", "ROOT=$HOME");
+    ttConf.set("mapred.child.env", (Shell.WINDOWS ? "ROOT=%USERPROFILE%"
+        : "ROOT=$HOME"));
     final Map<String, String> env = new HashMap<String, String>();
     String user = "test";
     JobConf taskConf = new JobConf(ttConf);
@@ -115,13 +85,6 @@ public class TestTaskEnvironment {
     taskRunner.updateUserLoginEnv(errorInfo, user, taskConf, env);
     taskRunner.setEnvFromInputString(errorInfo, env, mapredChildEnv);
 
-    final Vector<String> vargs = new Vector<String>(1);
-    File pidFile = new File(TEST_DIR, "pid");
-    vargs.add(writeScript("ENV", "/bin/env ", pidFile).getAbsolutePath());
-    final File workDir = new File(TEST_DIR, "work");
-    workDir.mkdir();
-    final File stdout = new File(TEST_DIR, "stdout");
-    final File stderr = new File(TEST_DIR, "stderr");
     Map<String, String> jvmenvmap = env;
     String javaOpts = taskRunner.getChildJavaOpts(ttConf, 
       JobConf.MAPRED_MAP_TASK_JAVA_OPTS);
@@ -134,6 +97,7 @@ public class TestTaskEnvironment {
     assertTrue(javaOpts, javaOpts.contains("IPv4"));
     
     String root = jvmenvmap.get("ROOT");
-    assertTrue(root, root.contentEquals(System.getenv("HOME")));
+    assertTrue(root, root.contentEquals(System
+        .getenv((Shell.WINDOWS ? "USERPROFILE" : "HOME"))));
   }
 }



Mime
View raw message