Beispiel #1
0
  public static void setupDefaultEnv(
      Map<String, String> env,
      Configuration conf,
      String userEnvKey,
      String userEnvDefault,
      String clusterDefaultEnvKey,
      String clusterDefaultEnvDefault,
      boolean usingArchive) {
    // Setup the CLASSPATH in environment
    // i.e. add { Hadoop jars, job jar, CWD } to classpath.
    String classpath = getFrameworkClasspath(conf, usingArchive);
    TezYARNUtils.addToEnvironment(
        env, ApplicationConstants.Environment.CLASSPATH.name(), classpath, File.pathSeparator);

    // Pre-pend pwd to LD_LIBRARY_PATH
    // Done separately here because this is known to work platform
    // independent
    TezYARNUtils.addToEnvironment(
        env, Environment.LD_LIBRARY_PATH.name(), Environment.PWD.$(), File.pathSeparator);
    TezYARNUtils.appendToEnvFromInputString(
        env, conf.get(userEnvKey, userEnvDefault), File.pathSeparator);
    // set any env from config if it is not set already
    TezYARNUtils.appendToEnvFromInputString(
        env, conf.get(clusterDefaultEnvKey, clusterDefaultEnvDefault), File.pathSeparator);
  }
Beispiel #2
0
 /**
  * Build up the classpath for execution -behaves very differently on a mini test cluster vs a
  * production production one.
  *
  * @param hoyaConfDir relative path to the dir containing hoya config options to put on the
  *     classpath -or null
  * @param libdir directory containing the JAR files
  * @param config the configuration
  * @param usingMiniMRCluster flag to indicate the MiniMR cluster is in use (and hence the current
  *     classpath should be used, not anything built up)
  * @return a classpath
  */
 public static String buildClasspath(
     String hoyaConfDir, String libdir, Configuration config, boolean usingMiniMRCluster) {
   // Add AppMaster.jar location to classpath
   // At some point we should not be required to add
   // the hadoop specific classpaths to the env.
   // It should be provided out of the box.
   // For now setting all required classpaths including
   // the classpath to "." for the application jar
   StringBuilder classPathEnv = new StringBuilder();
   // add the runtime classpath needed for tests to work
   if (usingMiniMRCluster) {
     // for mini cluster we pass down the java CP properties
     // and nothing else
     classPathEnv.append(System.getProperty("java.class.path"));
   } else {
     char col = File.pathSeparatorChar;
     classPathEnv.append(ApplicationConstants.Environment.CLASSPATH.$());
     String[] strs =
         config.getStrings(
             YarnConfiguration.YARN_APPLICATION_CLASSPATH,
             YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH);
     if (strs != null) {
       for (String c : strs) {
         classPathEnv.append(col);
         classPathEnv.append(c.trim());
       }
     }
     classPathEnv.append(col).append("./").append(libdir).append("/*");
     if (hoyaConfDir != null) {
       classPathEnv.append(col).append(hoyaConfDir);
     }
   }
   return classPathEnv.toString();
 }