@Test (timeout = 120000) public void testSetClasspath() throws IOException { Configuration conf = new Configuration(); conf.setBoolean(MRConfig.MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM, true); Job job = Job.getInstance(conf); Map<String, String> environment = new HashMap<String, String>(); MRApps.setClasspath(environment, job.getConfiguration()); assertTrue(environment.get(ApplicationConstants.Environment.CLASSPATH. name()).startsWith(ApplicationConstants.Environment.PWD.$$() + ApplicationConstants.CLASS_PATH_SEPARATOR)); String yarnAppClasspath = job.getConfiguration().get( YarnConfiguration.YARN_APPLICATION_CLASSPATH, StringUtils.join(",", YarnConfiguration.DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH)); if (yarnAppClasspath != null) { yarnAppClasspath = yarnAppClasspath.replaceAll(",\\s*", ApplicationConstants.CLASS_PATH_SEPARATOR).trim(); } assertTrue(environment.get(ApplicationConstants.Environment. CLASSPATH.name()).contains(yarnAppClasspath)); String mrAppClasspath = job.getConfiguration().get( MRJobConfig.MAPREDUCE_APPLICATION_CLASSPATH, MRJobConfig.DEFAULT_MAPREDUCE_CROSS_PLATFORM_APPLICATION_CLASSPATH); if (mrAppClasspath != null) { mrAppClasspath = mrAppClasspath.replaceAll(",\\s*", ApplicationConstants.CLASS_PATH_SEPARATOR).trim(); } assertTrue(environment.get(ApplicationConstants.Environment.CLASSPATH. name()).contains(mrAppClasspath)); }
@SuppressWarnings("deprecation") public static void setClasspath(Map<String, String> environment, Configuration conf) throws IOException { boolean userClassesTakesPrecedence = conf.getBoolean(MRJobConfig.MAPREDUCE_JOB_USER_CLASSPATH_FIRST, false); String classpathEnvVar = conf.getBoolean(MRJobConfig.MAPREDUCE_JOB_CLASSLOADER, false) ? Environment.APP_CLASSPATH.name() : Environment.CLASSPATH.name(); String hadoopClasspathEnvVar = Environment.HADOOP_CLASSPATH.name(); MRApps.addToEnvironment(environment, classpathEnvVar, crossPlatformifyMREnv(conf, Environment.PWD), conf); MRApps.addToEnvironment(environment, hadoopClasspathEnvVar, crossPlatformifyMREnv(conf, Environment.PWD), conf); if (!userClassesTakesPrecedence) { MRApps.setMRFrameworkClasspath(environment, conf); } addClasspathToEnv(environment, classpathEnvVar, conf); addClasspathToEnv(environment, hadoopClasspathEnvVar, conf); MRApps.addToEnvironment(environment, hadoopClasspathEnvVar, System.getenv(hadoopClasspathEnvVar), conf); if (userClassesTakesPrecedence) { MRApps.setMRFrameworkClasspath(environment, conf); } }
MRApps extends Apps { @SuppressWarnings("deprecation") public static void setClasspath(Map<String, String> environment, Configuration conf) throws IOException { boolean userClassesTakesPrecedence = conf.getBoolean(MRJobConfig.MAPREDUCE_JOB_USER_CLASSPATH_FIRST, false); String classpathEnvVar = conf.getBoolean(MRJobConfig.MAPREDUCE_JOB_CLASSLOADER, false) ? Environment.APP_CLASSPATH.name() : Environment.CLASSPATH.name(); String hadoopClasspathEnvVar = Environment.HADOOP_CLASSPATH.name(); MRApps.addToEnvironment(environment, classpathEnvVar, crossPlatformifyMREnv(conf, Environment.PWD), conf); MRApps.addToEnvironment(environment, hadoopClasspathEnvVar, crossPlatformifyMREnv(conf, Environment.PWD), conf); if (!userClassesTakesPrecedence) { MRApps.setMRFrameworkClasspath(environment, conf); } addClasspathToEnv(environment, classpathEnvVar, conf); addClasspathToEnv(environment, hadoopClasspathEnvVar, conf); MRApps.addToEnvironment(environment, hadoopClasspathEnvVar, System.getenv(hadoopClasspathEnvVar), conf); if (userClassesTakesPrecedence) { MRApps.setMRFrameworkClasspath(environment, conf); } } }
MRApps extends Apps { @SuppressWarnings("deprecation") public static void setClasspath(Map<String, String> environment, Configuration conf) throws IOException { boolean userClassesTakesPrecedence = conf.getBoolean(MRJobConfig.MAPREDUCE_JOB_USER_CLASSPATH_FIRST, false); String classpathEnvVar = conf.getBoolean(MRJobConfig.MAPREDUCE_JOB_CLASSLOADER, false) ? Environment.APP_CLASSPATH.name() : Environment.CLASSPATH.name(); String hadoopClasspathEnvVar = Environment.HADOOP_CLASSPATH.name(); MRApps.addToEnvironment(environment, classpathEnvVar, crossPlatformifyMREnv(conf, Environment.PWD), conf); MRApps.addToEnvironment(environment, hadoopClasspathEnvVar, crossPlatformifyMREnv(conf, Environment.PWD), conf); if (!userClassesTakesPrecedence) { MRApps.setMRFrameworkClasspath(environment, conf); } addClasspathToEnv(environment, classpathEnvVar, conf); addClasspathToEnv(environment, hadoopClasspathEnvVar, conf); MRApps.addToEnvironment(environment, hadoopClasspathEnvVar, System.getenv(hadoopClasspathEnvVar), conf); if (userClassesTakesPrecedence) { MRApps.setMRFrameworkClasspath(environment, conf); } }  }
MRApps extends Apps { @SuppressWarnings("deprecation") public static void setClasspath(Map<String, String> environment, Configuration conf) throws IOException { boolean userClassesTakesPrecedence = conf.getBoolean(MRJobConfig.MAPREDUCE_JOB_USER_CLASSPATH_FIRST, false); String classpathEnvVar = conf.getBoolean(MRJobConfig.MAPREDUCE_JOB_CLASSLOADER, false) ? Environment.APP_CLASSPATH.name() : Environment.CLASSPATH.name(); String hadoopClasspathEnvVar = Environment.HADOOP_CLASSPATH.name(); MRApps.addToEnvironment(environment, classpathEnvVar, crossPlatformifyMREnv(conf, Environment.PWD), conf); MRApps.addToEnvironment(environment, hadoopClasspathEnvVar, crossPlatformifyMREnv(conf, Environment.PWD), conf); if (!userClassesTakesPrecedence) { MRApps.setMRFrameworkClasspath(environment, conf); } addClasspathToEnv(environment, classpathEnvVar, conf); addClasspathToEnv(environment, hadoopClasspathEnvVar, conf); MRApps.addToEnvironment(environment, hadoopClasspathEnvVar, System.getenv(hadoopClasspathEnvVar), conf); if (userClassesTakesPrecedence) { MRApps.setMRFrameworkClasspath(environment, conf); } }  static String toString(JobId jid); static JobId toJobID(String jid); static String toString(TaskId tid); static TaskId toTaskID(String tid); static String toString(TaskAttemptId taid); static TaskAttemptId toTaskAttemptID(String taid); static String taskSymbol(TaskType type); static TaskType taskType(String symbol); static TaskAttemptStateUI taskAttemptState(String attemptStateStr); static TaskStateUI taskState(String taskStateStr); @SuppressWarnings("deprecation") static void setClasspath(Map<String, String> environment,
      Configuration conf); @SuppressWarnings("deprecation") static void addClasspathToEnv(Map<String, String> environment,
      String classpathEnvVar, Configuration conf); static void setJobClassLoader(Configuration conf); static ClassLoader createJobClassLoader(Configuration conf); static void setClassLoader(ClassLoader classLoader,
      Configuration conf); static Path getStagingAreaDir(Configuration conf, String user); static String getJobFile(Configuration conf, String user, 
      org.apache.hadoop.mapreduce.JobID jobId); static Path getEndJobCommitSuccessFile(Configuration conf, String user,
      JobId jobId); static Path getEndJobCommitFailureFile(Configuration conf, String user,
      JobId jobId); static Path getStartJobCommitFile(Configuration conf, String user,
      JobId jobId); @SuppressWarnings("deprecation") static void setupDistributedCache( 
      Configuration conf, 
      Map<String, LocalResource> localResources); @SuppressWarnings("deprecation") static void setupDistributedCacheLocal(Configuration conf); static void addLog4jSystemProperties(
      String logLevel, long logSize, int numBackups, List<String> vargs, 
      Configuration conf); static void setEnvFromInputString(Map<String, String> env,
      String envString, Configuration conf); @Public @Unstable static void addToEnvironment(Map<String, String> environment,
      String variable, String value, Configuration conf); static String crossPlatformifyMREnv(Configuration conf, Environment env); }
MRApps extends Apps { @SuppressWarnings("deprecation") public static void setClasspath(Map<String, String> environment, Configuration conf) throws IOException { boolean userClassesTakesPrecedence = conf.getBoolean(MRJobConfig.MAPREDUCE_JOB_USER_CLASSPATH_FIRST, false); String classpathEnvVar = conf.getBoolean(MRJobConfig.MAPREDUCE_JOB_CLASSLOADER, false) ? Environment.APP_CLASSPATH.name() : Environment.CLASSPATH.name(); String hadoopClasspathEnvVar = Environment.HADOOP_CLASSPATH.name(); MRApps.addToEnvironment(environment, classpathEnvVar, crossPlatformifyMREnv(conf, Environment.PWD), conf); MRApps.addToEnvironment(environment, hadoopClasspathEnvVar, crossPlatformifyMREnv(conf, Environment.PWD), conf); if (!userClassesTakesPrecedence) { MRApps.setMRFrameworkClasspath(environment, conf); } addClasspathToEnv(environment, classpathEnvVar, conf); addClasspathToEnv(environment, hadoopClasspathEnvVar, conf); MRApps.addToEnvironment(environment, hadoopClasspathEnvVar, System.getenv(hadoopClasspathEnvVar), conf); if (userClassesTakesPrecedence) { MRApps.setMRFrameworkClasspath(environment, conf); } }  static String toString(JobId jid); static JobId toJobID(String jid); static String toString(TaskId tid); static TaskId toTaskID(String tid); static String toString(TaskAttemptId taid); static TaskAttemptId toTaskAttemptID(String taid); static String taskSymbol(TaskType type); static TaskType taskType(String symbol); static TaskAttemptStateUI taskAttemptState(String attemptStateStr); static TaskStateUI taskState(String taskStateStr); @SuppressWarnings("deprecation") static void setClasspath(Map<String, String> environment,
      Configuration conf); @SuppressWarnings("deprecation") static void addClasspathToEnv(Map<String, String> environment,
      String classpathEnvVar, Configuration conf); static void setJobClassLoader(Configuration conf); static ClassLoader createJobClassLoader(Configuration conf); static void setClassLoader(ClassLoader classLoader,
      Configuration conf); static Path getStagingAreaDir(Configuration conf, String user); static String getJobFile(Configuration conf, String user, 
      org.apache.hadoop.mapreduce.JobID jobId); static Path getEndJobCommitSuccessFile(Configuration conf, String user,
      JobId jobId); static Path getEndJobCommitFailureFile(Configuration conf, String user,
      JobId jobId); static Path getStartJobCommitFile(Configuration conf, String user,
      JobId jobId); @SuppressWarnings("deprecation") static void setupDistributedCache( 
      Configuration conf, 
      Map<String, LocalResource> localResources); @SuppressWarnings("deprecation") static void setupDistributedCacheLocal(Configuration conf); static void addLog4jSystemProperties(
      String logLevel, long logSize, int numBackups, List<String> vargs, 
      Configuration conf); static void setEnvFromInputString(Map<String, String> env,
      String envString, Configuration conf); @Public @Unstable static void addToEnvironment(Map<String, String> environment,
      String variable, String value, Configuration conf); static String crossPlatformifyMREnv(Configuration conf, Environment env); static final Log LOG; }