Example usage for org.apache.hadoop.mapred JobConf MAPRED_REDUCE_TASK_ENV

List of usage examples for org.apache.hadoop.mapred JobConf MAPRED_REDUCE_TASK_ENV

Introduction

In this page you can find the example usage for org.apache.hadoop.mapred JobConf MAPRED_REDUCE_TASK_ENV.

Prototype

String MAPRED_REDUCE_TASK_ENV

To view the source code for org.apache.hadoop.mapred JobConf MAPRED_REDUCE_TASK_ENV.

Click Source Link

Document

Configuration key to set the environment of the child reduce tasks.

Usage

From source file:com.google.mr4c.hadoop.HadoopUtils.java

License:Open Source License

/**
  * @param varMap apply environment variable values from this map
  * @param vars apply existing values of these environment variables
*///from  w  w w .j a va 2 s . co m
public static void applyEnvironmentVariables(JobConf conf, Map<String, String> varMap, List<String> vars) {
    Map<String, String> allMap = new HashMap<String, String>(System.getenv());
    allMap.keySet().retainAll(vars); // only the env we wanted
    allMap.putAll(varMap);
    List<String> assigns = new ArrayList<String>();
    for (String var : allMap.keySet()) {
        String val = allMap.get(var);
        if (!StringUtils.isEmpty(val)) {
            assigns.add(var + "=" + val);
        }
    }
    String value = StringUtils.join(assigns, ", ");
    conf.set(JobConf.MAPRED_MAP_TASK_ENV, value);
    conf.set(JobConf.MAPRED_REDUCE_TASK_ENV, value);
}