public static void SetVMEnv(IDictionary <string, string> environment, Task task) { JobConf conf = task.conf; // Add the env variables passed by the user string mapredChildEnv = GetChildEnv(conf, task.IsMapTask()); MRApps.SetEnvFromInputString(environment, mapredChildEnv, conf); // Set logging level in the environment. // This is so that, if the child forks another "bin/hadoop" (common in // streaming) it will have the correct loglevel. environment["HADOOP_ROOT_LOGGER"] = MRApps.GetChildLogLevel(conf, task.IsMapTask( )) + ",console"; // TODO: The following is useful for instance in streaming tasks. Should be // set in ApplicationMaster's env by the RM. string hadoopClientOpts = Runtime.Getenv("HADOOP_CLIENT_OPTS"); if (hadoopClientOpts == null) { hadoopClientOpts = string.Empty; } else { hadoopClientOpts = hadoopClientOpts + " "; } environment["HADOOP_CLIENT_OPTS"] = hadoopClientOpts; // setEnvFromInputString above will add env variable values from // mapredChildEnv to existing variables. We want to overwrite // HADOOP_ROOT_LOGGER and HADOOP_CLIENT_OPTS if the user set it explicitly. IDictionary <string, string> tmpEnv = new Dictionary <string, string>(); MRApps.SetEnvFromInputString(tmpEnv, mapredChildEnv, conf); string[] keys = new string[] { "HADOOP_ROOT_LOGGER", "HADOOP_CLIENT_OPTS" }; foreach (string key in keys) { if (tmpEnv.Contains(key)) { environment[key] = tmpEnv[key]; } } // Add stdout/stderr env environment[MRJobConfig.StdoutLogfileEnv] = GetTaskLogFile(TaskLog.LogName.Stdout ); environment[MRJobConfig.StderrLogfileEnv] = GetTaskLogFile(TaskLog.LogName.Stderr ); }