当前位置: 首页>>代码示例>>Java>>正文


Java Apps.addToEnvironment方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.util.Apps.addToEnvironment方法的典型用法代码示例。如果您正苦于以下问题:Java Apps.addToEnvironment方法的具体用法?Java Apps.addToEnvironment怎么用?Java Apps.addToEnvironment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.util.Apps的用法示例。


在下文中一共展示了Apps.addToEnvironment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupAppMasterEnv

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
private void setupAppMasterEnv(Map<String, String> appMasterEnv, String exclasspath) {
	for (String c: conf.getStrings(
			YarnConfiguration.YARN_APPLICATION_CLASSPATH, 
			YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) {
		Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(), c.trim());
	}
	Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(),
			Environment.PWD.$() + File.separator +"*");
	
	System.out.println("##env pwd:"+Environment.PWD.$());
	/*
	String[] excparray = exclasspath.split(",");
	for (String cp: excparray) {
		Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(), cp);
	}*/
	
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:18,代码来源:Client.java

示例2: getEnvironmentVariables

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
/**
 * Get environment variables in a {@link java.util.Map} used when launching a Yarn container.
 *
 * @param yarnConfiguration a Hadoop {@link Configuration} object carrying Hadoop/Yarn configuration properties
 * @return a {@link java.util.Map} storing environment variables used when launching a Yarn container
 */
public static Map<String, String> getEnvironmentVariables(Configuration yarnConfiguration) {
  Map<String, String> environmentVariableMap = Maps.newHashMap();

  Apps.addToEnvironment(environmentVariableMap, ApplicationConstants.Environment.JAVA_HOME.key(),
      System.getenv(ApplicationConstants.Environment.JAVA_HOME.key()));

  // Add jars/files in the working directory of the ApplicationMaster to the CLASSPATH
  Apps.addToEnvironment(environmentVariableMap, ApplicationConstants.Environment.CLASSPATH.key(),
      ApplicationConstants.Environment.PWD.$());
  Apps.addToEnvironment(environmentVariableMap, ApplicationConstants.Environment.CLASSPATH.key(),
      ApplicationConstants.Environment.PWD.$() + File.separator + "*");

  String[] classpaths = yarnConfiguration.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
      YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH);
  if (classpaths != null) {
    for (String classpath : classpaths) {
      Apps.addToEnvironment(
          environmentVariableMap, ApplicationConstants.Environment.CLASSPATH.key(), classpath.trim());
    }
  }

  return environmentVariableMap;
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:30,代码来源:YarnHelixUtils.java

示例3: setupAppClasspath

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
void setupAppClasspath(boolean miniClusterEnv, Configuration conf, Map<String, String> appMasterEnv) {
  if(miniClusterEnv) {
    String cps = System.getProperty("java.class.path") ;
    String[] cp = cps.split(":") ;
    for(String selCp : cp) {
      Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(), selCp, ":");
    }
  } else {
    StringBuilder classPathEnv = new StringBuilder();
    classPathEnv.append(Environment.CLASSPATH.$()).append(File.pathSeparatorChar);
    classPathEnv.append("./*");

    String[] classpath = conf.getStrings(
        YarnConfiguration.YARN_APPLICATION_CLASSPATH,
        YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH
    ) ;
    for (String selClasspath : classpath) {
      classPathEnv.append(File.pathSeparatorChar);
      classPathEnv.append(selClasspath.trim());
    }
    appMasterEnv.put(Environment.CLASSPATH.name(), classPathEnv.toString());
    System.err.println("CLASSPATH: " + classPathEnv);
  }
  Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(), Environment.PWD.$() + File.separator + "*", ":");
}
 
开发者ID:DemandCube,项目名称:Scribengin,代码行数:26,代码来源:YarnManager.java

示例4: createContainerLaunchContext

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
static ContainerLaunchContext createContainerLaunchContext(
    Map<ApplicationAccessType, String> applicationACLs, Configuration conf,
    PSAgentAttemptId attemptId, final ApplicationId appid, MasterService masterService,
    Credentials credentials) {

  synchronized (commonContainerSpecLock) {
    if (commonContainerSpec == null) {
      commonContainerSpec =
          createCommonContainerLaunchContext(masterService, applicationACLs, conf, appid,
              credentials);
    }
  }

  Map<String, String> env = commonContainerSpec.getEnvironment();
  Map<String, String> myEnv = new HashMap<String, String>(env.size());
  myEnv.putAll(env);

  Apps.addToEnvironment(myEnv, AngelEnvironment.PSAGENT_ID.name(),
      Integer.toString(attemptId.getPsAgentId().getIndex()));
  Apps.addToEnvironment(myEnv, AngelEnvironment.PSAGENT_ATTEMPT_ID.name(),
      Integer.toString(attemptId.getIndex()));

  //ParameterServerJVM.setVMEnv(myEnv, conf);

  // Set up the launch command
  List<String> commands = PSAgentAttemptJVM.getVMCommand(conf, appid, attemptId);

  // Duplicate the ByteBuffers for access by multiple containers.
  Map<String, ByteBuffer> myServiceData = new HashMap<String, ByteBuffer>();
  for (Entry<String, ByteBuffer> entry : commonContainerSpec.getServiceData().entrySet()) {
    myServiceData.put(entry.getKey(), entry.getValue().duplicate());
  }

  // Construct the actual Container
  ContainerLaunchContext container =
      ContainerLaunchContext.newInstance(commonContainerSpec.getLocalResources(), myEnv,
          commands, myServiceData, commonContainerSpec.getTokens().duplicate(), applicationACLs);

  return container;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:41,代码来源:PSAgentAttempt.java

示例5: setClasspath

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void setClasspath(Map<String, String> environment, Configuration conf)
    throws IOException {
  String classpathEnvVar = Environment.CLASSPATH.name();
  Apps.addToEnvironment(environment, classpathEnvVar, Environment.PWD.$());
  Apps.addToEnvironment(environment, classpathEnvVar, Environment.PWD.$() + Path.SEPARATOR + "*");
  // a * in the classpath will only find a .jar, so we need to filter out
  // all .jars and add everything else
  addToClasspathIfNotJar(DistributedCache.getFileClassPaths(conf),
      DistributedCache.getCacheFiles(conf), conf, environment, classpathEnvVar);
  addToClasspathIfNotJar(DistributedCache.getArchiveClassPaths(conf),
      DistributedCache.getCacheArchives(conf), conf, environment, classpathEnvVar);
  
  AngelApps.setAngelFrameworkClasspath(environment, conf);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:16,代码来源:AngelApps.java

示例6: setupAppEnv

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
private void setupAppEnv(Map<String, String> appEnv, String exclasspath) {
	for (String c: conf.getStrings(
			YarnConfiguration.YARN_APPLICATION_CLASSPATH, 
			YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) {
		Apps.addToEnvironment(appEnv, Environment.CLASSPATH.name(), c.trim());
	}
	Apps.addToEnvironment(appEnv, Environment.CLASSPATH.name(),
			Environment.PWD.$() + File.separator + "*");
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:ApplicationMasterKMS.java

示例7: addToEnvironment

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
@Public
@Unstable
public static void addToEnvironment(Map<String, String> environment,
    String variable, String value, 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.addToEnvironment(environment, variable, value, classPathSeparator);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:MRApps.java

示例8: setupAppMasterEnv

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
private void setupAppMasterEnv(YarnConfiguration conf, Map<String, String> appMasterEnv) {
    String[] defaultPaths = conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
                                            YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH);
    for (String c : defaultPaths) {
        Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(),
                              c.trim(), File.pathSeparator);
    }
    Apps.addToEnvironment(appMasterEnv,
                          Environment.CLASSPATH.name(),
                          Environment.PWD.$() + File.separator + "*",
                          File.pathSeparator);
}
 
开发者ID:kazuki,项目名称:hadoop-yarn-appmaster-bridge,代码行数:13,代码来源:Client.java

示例9: setupAppMasterEnv

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
/**
 * @param envs Environment variables.
 * @param conf Yarn configuration.
 */
private static void setupAppMasterEnv(Map<String, String> envs, YarnConfiguration conf) {
    for (String c : conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
        YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH))
        Apps.addToEnvironment(envs, Environment.CLASSPATH.name(),
                c.trim(), File.pathSeparator);

    Apps.addToEnvironment(envs,
            Environment.CLASSPATH.name(),
            Environment.PWD.$() + File.separator + "*",
            File.pathSeparator);
}
 
开发者ID:apache,项目名称:ignite,代码行数:16,代码来源:IgniteYarnClient.java

示例10: setupAppMasterEnv

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void setupAppMasterEnv(Map<String, String> appMasterEnv) {
    for (String c : conf.getStrings(
            YarnConfiguration.YARN_APPLICATION_CLASSPATH,
            YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) {
        Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(),
                c.trim());
    }
    Apps.addToEnvironment(appMasterEnv,
            Environment.CLASSPATH.name(),
            Environment.PWD.$() + File.separator + "*");
}
 
开发者ID:sakserv,项目名称:hadoop-mini-clusters,代码行数:13,代码来源:Client.java

示例11: getEnvironmentVariables

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
/**
 * Get environment variables in a {@link java.util.Map} used when launching a Yarn container.
 *
 * @param yarnConfiguration a Hadoop {@link Configuration} object carrying Hadoop/Yarn configuration properties
 * @return a {@link java.util.Map} storing environment variables used when launching a Yarn container
 */
@SuppressWarnings("deprecation")
public static Map<String, String> getEnvironmentVariables(Configuration yarnConfiguration) {
  Map<String, String> environmentVariableMap = Maps.newHashMap();

  if (System.getenv().containsKey(ApplicationConstants.Environment.JAVA_HOME.key())) {
    Apps.addToEnvironment(environmentVariableMap, ApplicationConstants.Environment.JAVA_HOME.key(),
        System.getenv(ApplicationConstants.Environment.JAVA_HOME.key()));
  }

  // Add jars/files in the working directory of the ApplicationMaster to the CLASSPATH
  Apps.addToEnvironment(environmentVariableMap, ApplicationConstants.Environment.CLASSPATH.key(),
      ApplicationConstants.Environment.PWD.$());
  Apps.addToEnvironment(environmentVariableMap, ApplicationConstants.Environment.CLASSPATH.key(),
      ApplicationConstants.Environment.PWD.$() + File.separator + "*");

  String[] classpaths = yarnConfiguration.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
      YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH);
  if (classpaths != null) {
    for (String classpath : classpaths) {
      Apps.addToEnvironment(
          environmentVariableMap, ApplicationConstants.Environment.CLASSPATH.key(), classpath.trim());
    }
  }

  return environmentVariableMap;
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:33,代码来源:YarnHelixUtils.java

示例12: setupAppMasterEnv

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
static public void setupAppMasterEnv(boolean miniClusterEnv, Configuration conf, Map<String, String> appMasterEnv) {
  if(miniClusterEnv) {
    String cps = System.getProperty("java.class.path") ;
    String[] cp = cps.split(":") ;
    for(String selCp : cp) {
      Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(), selCp, ":");
    }
  } else {
    StringBuilder classPathEnv = new StringBuilder();
    classPathEnv.append(Environment.CLASSPATH.$()).append(File.pathSeparatorChar);
    classPathEnv.append("./*");

    String[] classpath = conf.getStrings(
        YarnConfiguration.YARN_APPLICATION_CLASSPATH,
        YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH
    ) ;
    for (String selClasspath : classpath) {
      classPathEnv.append(File.pathSeparatorChar);
      classPathEnv.append(selClasspath.trim());
      System.out.println("add classpath: " + selClasspath);
    }

    String envStr = classPathEnv.toString();
    appMasterEnv.put(Environment.CLASSPATH.name(), envStr);
  }
  Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(), Environment.PWD.$() + File.separator + "*", ":");
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:28,代码来源:Util.java

示例13: setupAppMasterEnv

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
private void setupAppMasterEnv(Map<String, String> appMasterEnv) {
  String cps = System.getProperty("java.class.path") ;
  String[] cp = cps.split(":") ;
  for(String selCp : cp) {
    System.out.println("Add classpath: " + selCp);
    Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(), selCp, ":");
  }
  Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(), Environment.PWD.$() + File.separator + "*", ":");
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:10,代码来源:HelloApplicationMasterUnitTest.java

示例14: setupAppMasterEnv

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
private void setupAppMasterEnv(Map<String, String> appMasterEnv) {
  for (String c : conf.getStrings(
      YarnConfiguration.YARN_APPLICATION_CLASSPATH,
      YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) {
    Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(),
        c.trim());
  }
  Apps.addToEnvironment(appMasterEnv,
      Environment.CLASSPATH.name(),
      Environment.PWD.$() + File.separator + "*");
}
 
开发者ID:codeboyyong,项目名称:distributed-shell,代码行数:12,代码来源:ApplicationMasterClient.java

示例15: setupAppMasterEnv

import org.apache.hadoop.yarn.util.Apps; //导入方法依赖的package包/类
protected void setupAppMasterEnv(CommandLine cli, Map<String, String> appMasterEnv) throws IOException {
  for (String c : conf.getStrings(
          YarnConfiguration.YARN_APPLICATION_CLASSPATH,
          YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) {
    Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(), c.trim());
  }
  Apps.addToEnvironment(appMasterEnv,
          Environment.CLASSPATH.name(),
          Environment.PWD.$() + File.separator + "*");

  if (cli.hasOption("extclasspath")) {
    String extclasspathArg = cli.getOptionValue("extclasspath");
    File extclasspathFile = new File(extclasspathArg);
    StringBuilder sb = new StringBuilder();
    BufferedReader reader = null;
    String line = null;
    try {
      reader = new BufferedReader(
        new InputStreamReader(new FileInputStream(extclasspathFile), Charset.forName("UTF-8")));
      while ((line = reader.readLine()) != null)
        sb.append(line.trim()).append(":");
    } finally {
      if (reader != null) {
        reader.close();
      }
    }
    for (String part : sb.toString().split(":")) {
      if (part.length() > 0)
        Apps.addToEnvironment(appMasterEnv, Environment.CLASSPATH.name(), part);
    }
  }
}
 
开发者ID:lucidworks,项目名称:yarn-proto,代码行数:33,代码来源:SolrClient.java


注:本文中的org.apache.hadoop.yarn.util.Apps.addToEnvironment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。