本文整理汇总了Java中org.apache.hadoop.yarn.util.Apps.setEnvFromInputString方法的典型用法代码示例。如果您正苦于以下问题:Java Apps.setEnvFromInputString方法的具体用法?Java Apps.setEnvFromInputString怎么用?Java Apps.setEnvFromInputString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.yarn.util.Apps
的用法示例。
在下文中一共展示了Apps.setEnvFromInputString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setVMEnv
import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void setVMEnv(Map<String, String> environment, Configuration conf) {
// Add the env variables passed by the user
String setEnv = getChildEnv(conf);
Apps.setEnvFromInputString(environment, setEnv);
// 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.put("HADOOP_ROOT_LOGGER", getChildLogLevel(conf) + ",CLA");
String hadoopClientOpts = System.getenv("HADOOP_CLIENT_OPTS");
if (hadoopClientOpts == null) {
hadoopClientOpts = "";
} else {
hadoopClientOpts = hadoopClientOpts + " ";
}
long logSize = 0;
Vector<String> logProps = new Vector<String>(4);
setupLog4jProperties(conf, logProps, logSize);
Iterator<String> it = logProps.iterator();
StringBuilder buffer = new StringBuilder();
while (it.hasNext()) {
buffer.append(" ").append(it.next());
}
hadoopClientOpts = hadoopClientOpts + buffer.toString();
environment.put("HADOOP_CLIENT_OPTS", hadoopClientOpts);
}
示例2: setVMEnv
import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
/**
* Set environment variables of worker attempt process
* @param environment environment variables of ps attempt process
* @param conf application configuration
*/
public static void setVMEnv(Map<String, String> environment, Configuration conf) {
// Add the env variables passed by the user
String workerChildEnv = getChildEnv(conf);
LOG.info("worker env=" + workerChildEnv);
try{
Apps.setEnvFromInputString(environment, workerChildEnv);
} catch (Exception x) {
LOG.error("set worker env failed.", x);
}
// Set logging level in the environment.
environment.put("HADOOP_ROOT_LOGGER", getChildLogLevel(conf) + ",CLA");
String hadoopClientOpts = System.getenv("HADOOP_CLIENT_OPTS");
if (hadoopClientOpts == null) {
hadoopClientOpts = "";
} else {
hadoopClientOpts = hadoopClientOpts + " ";
}
long logSize = 0;
Vector<String> logProps = new Vector<String>(4);
setupLog4jProperties(conf, logProps, logSize);
Iterator<String> it = logProps.iterator();
StringBuilder buffer = new StringBuilder();
while (it.hasNext()) {
buffer.append(" ").append(it.next());
}
hadoopClientOpts = hadoopClientOpts + buffer.toString();
environment.put("HADOOP_CLIENT_OPTS", hadoopClientOpts);
}
示例3: setVMEnv
import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
/**
* Set environment variables of ps attempt process
* @param environment environment variables of ps attempt process
* @param conf application configuration
*/
public static void setVMEnv(Map<String, String> environment, Configuration conf) {
// Add the env variables passed by the user
String setEnv = getChildEnv(conf);
try{
Apps.setEnvFromInputString(environment, setEnv);
} catch (Exception x) {
LOG.error("set ps env faile.", x);
}
// Set logging level in the environment.
environment.put("HADOOP_ROOT_LOGGER", getChildLogLevel(conf) + ",CLA");
String hadoopClientOpts = System.getenv("HADOOP_CLIENT_OPTS");
if (hadoopClientOpts == null) {
hadoopClientOpts = "";
} else {
hadoopClientOpts = hadoopClientOpts + " ";
}
long logSize = 0;
Vector<String> logProps = new Vector<String>(4);
setupLog4jProperties(conf, logProps, logSize);
Iterator<String> it = logProps.iterator();
StringBuilder buffer = new StringBuilder();
while (it.hasNext()) {
buffer.append(" ").append(it.next());
}
hadoopClientOpts = hadoopClientOpts + buffer.toString();
environment.put("HADOOP_CLIENT_OPTS", hadoopClientOpts);
}
示例4: setEnvFromInputString
import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
public static void setEnvFromInputString(Map<String, String> env,
String envString, Configuration conf) {
String classPathSeparator =
conf.getBoolean(MRConfig.MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM,
MRConfig.DEFAULT_MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM)
? ApplicationConstants.CLASS_PATH_SEPARATOR : File.pathSeparator;
Apps.setEnvFromInputString(env, envString, classPathSeparator);
}
示例5: setVMEnv
import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
public static void setVMEnv(Map<String, String> environment,
Task task) {
JobConf conf = task.conf;
// Add the env variables passed by the user
String mapredChildEnv = getChildEnv(conf, task.isMapTask());
Apps.setEnvFromInputString(environment, mapredChildEnv);
// 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.put(
"HADOOP_ROOT_LOGGER",
getChildLogLevel(conf, task.isMapTask()) + ",CLA");
// TODO: The following is useful for instance in streaming tasks. Should be
// set in ApplicationMaster's env by the RM.
String hadoopClientOpts = System.getenv("HADOOP_CLIENT_OPTS");
if (hadoopClientOpts == null) {
hadoopClientOpts = "";
} else {
hadoopClientOpts = hadoopClientOpts + " ";
}
// FIXME: don't think this is also needed given we already set java
// properties.
long logSize = TaskLog.getTaskLogLength(conf);
Vector<String> logProps = new Vector<String>(4);
setupLog4jProperties(task, logProps, logSize);
Iterator<String> it = logProps.iterator();
StringBuffer buffer = new StringBuffer();
while (it.hasNext()) {
buffer.append(" " + it.next());
}
hadoopClientOpts = hadoopClientOpts + buffer.toString();
environment.put("HADOOP_CLIENT_OPTS", hadoopClientOpts);
// Add stdout/stderr env
environment.put(
MRJobConfig.STDOUT_LOGFILE_ENV,
getTaskLogFile(TaskLog.LogName.STDOUT)
);
environment.put(
MRJobConfig.STDERR_LOGFILE_ENV,
getTaskLogFile(TaskLog.LogName.STDERR)
);
}