org.apache.hadoop.yarn.util.Apps.setEnvFromInputProperty()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中org.apache.hadoop.yarn.util.Apps.setEnvFromInputProperty()方法的一些代码示例,展示了Apps.setEnvFromInputProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Apps.setEnvFromInputProperty()方法的具体详情如下:
包路径:org.apache.hadoop.yarn.util.Apps
类名称:Apps
方法名:setEnvFromInputProperty

Apps.setEnvFromInputProperty介绍

[英]Set environment variables from the given environment input property. For example, given the property mapreduce.map.env, this method will extract environment variables from: the comma-separated string value of mapreduce.map.env, and the values of any properties of the form mapreduce.map.env.VAR_NAME Variables specified via the latter syntax take precedence over those specified using the former syntax.
[中]从给定的环境输入属性设置环境变量。例如,给定属性mapreduce。地图env,此方法将从以下内容提取环境变量:mapreduce的逗号分隔字符串值。地图以及表单mapreduce的任何属性的值。地图环境。通过后一种语法指定的VAR_NAME变量优先于使用前一种语法指定的变量。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-common

public static void setEnvFromInputProperty(Map<String, String> env,
  String propName, String defaultPropValue, 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.setEnvFromInputProperty(env, propName, defaultPropValue, conf,
   classPathSeparator);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

@Test
 public void testSetEnvFromInputPropertyNull() {
  Configuration conf = new Configuration(false);
  Map<String, String> env = new HashMap<>();
  String propName = "mapreduce.map.env";
  String defaultPropName = "mapreduce.child.env";
  // Setup environment input properties
  conf.set(propName, "env1=env1_val,env2=env2_val,env3=env3_val");
  conf.set(propName + ".env4", "env4_val");
  conf.set(propName + ".env2", "new_env2_val");
  // Setup some default values - we shouldn't see these values
  conf.set(defaultPropName, "env1=def1_val,env2=def2_val,env3=def3_val");
  String defaultPropValue = conf.get(defaultPropName);
  // These should never be referenced.
  conf.set(defaultPropName + ".env4", "def4_val");
  conf.set(defaultPropName + ".env2", "new_def2_val");
  // Try with null inputs
  Apps.setEnvFromInputProperty(env, "bogus1", null, conf, File.pathSeparator);
  assertTrue(env.isEmpty());
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

@Test
public void testSetEnvFromInputPropertyCommas() {
 Configuration conf = new Configuration(false);
 Map<String, String> env = new HashMap<>();
 String propName = "mapreduce.reduce.env";
 conf.set(propName, "env1=env1_val,env2=env2_val,env3=env3_val");
 conf.set(propName + ".env2", "new2_val1,new2_val2,new2_val3");
 conf.set(propName + ".env4", "new4_valwith=equals");
 // Setup some default values - we shouldn't see these values
 String defaultPropName = "mapreduce.child.env";
 conf.set(defaultPropName, "env1=def1_val,env2=def2_val,env3=def3_val");
 String defaultPropValue = conf.get(defaultPropName);
 Apps.setEnvFromInputProperty(env, propName, defaultPropValue, conf,
   File.pathSeparator);
 // Check values from string
 assertEquals("env1_val", env.get("env1"));
 assertEquals("env3_val", env.get("env3"));
 // Check individual value
 assertEquals("new4_valwith=equals", env.get("env4"));
 // Check individual value that eclipses one in string
 assertEquals("new2_val1,new2_val2,new2_val3", env.get("env2"));
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

@Test
public void testSetEnvFromInputProperty() {
 Configuration conf = new Configuration(false);
 Map<String, String> env = new HashMap<>();
 String propName = "mapreduce.map.env";
 String defaultPropName = "mapreduce.child.env";
 // Setup environment input properties
 conf.set(propName, "env1=env1_val,env2=env2_val,env3=env3_val");
 conf.set(propName + ".env4", "env4_val");
 conf.set(propName + ".env2", "new_env2_val");
 // Setup some default values - we shouldn't see these values
 conf.set(defaultPropName, "env1=def1_val,env2=def2_val,env3=def3_val");
 String defaultPropValue = conf.get(defaultPropName);
 // These should never be referenced.
 conf.set(defaultPropName + ".env4", "def4_val");
 conf.set(defaultPropName + ".env2", "new_def2_val");
 Apps.setEnvFromInputProperty(env, propName, defaultPropValue, conf,
   File.pathSeparator);
 // Check values from string
 assertEquals("env1_val", env.get("env1"));
 assertEquals("env3_val", env.get("env3"));
 // Check individual value
 assertEquals("env4_val", env.get("env4"));
 // Check individual value that eclipses one in string
 assertEquals("new_env2_val", env.get("env2"));
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

@Test
public void testSetEnvFromInputPropertyOverrideDefault() {
 Configuration conf = new Configuration(false);
 Map<String, String> env = new HashMap<>();
 // Try using default value, but specify some individual values using
 // the main propName, but no main value, so it should get values from
 // the default string, and then the individual values.
 String propName = "mapreduce.reduce.env";
 conf.set(propName + ".env2", "new2_val");
 conf.set(propName + ".env4", "new4_val");
 // Setup some default values - we shouldn't see these values
 String defaultPropName = "mapreduce.child.env";
 conf.set(defaultPropName, "env1=def1_val,env2=def2_val,env3=def3_val");
 String defaultPropValue = conf.get(defaultPropName);
 // These should never be referenced.
 conf.set(defaultPropName + ".env4", "def4_val");
 conf.set(defaultPropName + ".env2", "new_def2_val");
 Apps.setEnvFromInputProperty(env, propName, defaultPropValue, conf,
   File.pathSeparator);
 // Check values from string
 assertEquals("def1_val", env.get("env1"));
 assertEquals("def3_val", env.get("env3"));
 // Check individual value
 assertEquals("new4_val", env.get("env4"));
 // Check individual value that eclipses one in string
 assertEquals("new2_val", env.get("env2"));
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

@Test
public void testSetEnvFromInputPropertyDefault() {
 Configuration conf = new Configuration(false);
 Map<String, String> env = new HashMap<>();
 String propName = "mapreduce.map.env";
 String defaultPropName = "mapreduce.child.env";
 // Setup environment input properties
 conf.set(propName, "env1=env1_val,env2=env2_val,env3=env3_val");
 conf.set(propName + ".env4", "env4_val");
 conf.set(propName + ".env2", "new_env2_val");
 // Setup some default values
 conf.set(defaultPropName, "env1=def1_val,env2=def2_val,env3=def3_val");
 String defaultPropValue = conf.get(defaultPropName);
 // These should never be referenced.
 conf.set(defaultPropName + ".env4", "def4_val");
 conf.set(defaultPropName + ".env2", "new_def2_val");
 // Test using default value for the string.
 // Individually specified env properties do not have defaults,
 // so this should just get things from the defaultPropName string.
 String bogusProp = propName + "bogus";
 Apps.setEnvFromInputProperty(env, bogusProp, defaultPropValue, conf,
   File.pathSeparator);
 // Check values from string
 assertEquals("def1_val", env.get("env1"));
 assertEquals("def2_val", env.get("env2"));
 assertEquals("def3_val", env.get("env3"));
 // Check individual value is not set.
 assertNull(env.get("env4"));
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-nodemanager

Apps.setEnvFromInputProperty(environment,
  YarnConfiguration.NM_ADMIN_USER_ENV, defEnvStr, conf,
  File.pathSeparator);

相关文章