List of usage examples for org.apache.hadoop.mapred JobConf findContainingJar
public static String findContainingJar(Class my_class)
From source file:com.cloudera.branchreduce.BranchReduceJob.java
License:Open Source License
public BranchReduceJob<T, G> setJarByClass(Class<?> clazz) { String jarPath = JobConf.findContainingJar(clazz); if (jarPath != null) { File jarFile = new File(jarPath); env.put(BRANCH_REDUCE_JAR_PATH, jarPath); env.put(BRANCH_REDUCE_JAR, jarFile.getName()); } else {/*from w w w . j ava 2 s . c o m*/ LOG.warn("branch reduce jar file not set; class files may not be found"); } return this; }
From source file:husky.client.HuskyYarnClient.java
License:Apache License
private boolean init(String[] args) throws ParseException, IOException { // parse options CommandLine cliParser = new GnuParser().parse(createClientOptions(), args); // analyze options if (args.length == 0 || cliParser.hasOption("help")) { printUsage();//from w w w.j a v a 2s .c o m return false; } mAppName = cliParser.getOptionValue("app_name", cliParser.getOptionValue("app_name", DEFAULT_APP_NAME)); mLocalResourceHDFSPaths = cliParser.getOptionValue("local_resrcrt", LOCAL_RESOURCES_HDFS_ROOT); mLocalFiles = cliParser.getOptionValue("local_files", ""); mLocalArchives = cliParser.getOptionValue("local_archives", ""); if (cliParser.hasOption("jar")) { mAppMasterJar = cliParser.getOptionValue("jar"); } else { mAppMasterJar = JobConf.findContainingJar(HuskyApplicationMaster.class); if (mAppMasterJar == null) { throw new IllegalArgumentException("No jar specified for husky application master"); } } LOG.info("Husky Application Master's jar is " + mAppMasterJar); if (cliParser.hasOption("worker_infos")) { for (String i : cliParser.getOptionValue("worker_infos").split(",")) { String[] pair = i.trim().split(":"); if (pair.length != 2) { throw new IllegalArgumentException("Invalid worker info: " + i.trim()); } try { Pair<String, Integer> p = new Pair<String, Integer>(pair[0], Integer.parseInt(pair[1])); if (p.getSecond() <= 0) { throw new IllegalArgumentException( "Invalid worker info, number of worker should be large than 0: " + i.trim()); } mWorkerInfos.add(p); } catch (NumberFormatException e) { LOG.log(Level.SEVERE, "Invalid number of worker given in worker_infos: " + i.trim()); throw e; } } if (mWorkerInfos.isEmpty()) { throw new IllegalArgumentException("Parameter `worker_infos` is empty."); } } else { throw new IllegalArgumentException( "No worker information is provided. Parameter `worker_infos` is not set."); } mAppMasterMemory = Integer.parseInt(cliParser.getOptionValue("master_memory", "2048")); if (mAppMasterMemory <= 0) { throw new IllegalArgumentException( "Illegal memory specified for application master. Specified memory: " + mAppMasterMemory); } mContainerMemory = Integer.parseInt(cliParser.getOptionValue("container_memory", "512")); if (mContainerMemory <= 0) { throw new IllegalArgumentException( "Illegal memory specified for container. Specified memory: " + mContainerMemory); } mNumVirtualCores = Integer.parseInt(cliParser.getOptionValue("container_vcores", "1")); if (mNumVirtualCores <= 0) { throw new IllegalArgumentException( "Illegal number of virtual cores specified for container. Specified number of vcores: " + mNumVirtualCores); } mAppPriority = Integer.parseInt(cliParser.getOptionValue("app_priority", "1")); if (mAppPriority <= 0) { throw new IllegalArgumentException( "Illegal priority for husky application. Specified priority: " + mAppPriority); } if (!cliParser.hasOption("master")) { throw new IllegalArgumentException("No executable specified for c++ husky master"); } mMasterExec = cliParser.getOptionValue("master"); if (!cliParser.hasOption("application")) { throw new IllegalArgumentException("No application specified for c++ husky workers"); } mAppExec = cliParser.getOptionValue("application"); if (!cliParser.hasOption("config")) { throw new IllegalArgumentException("No config file given for c++ husky master and application"); } mConfigFile = cliParser.getOptionValue("config"); mLdLibraryPath = cliParser.getOptionValue("ld_library_path", ""); mKeyTabFile = cliParser.getOptionValue("key_tab", ""); mUserName = cliParser.getOptionValue("user_name", ""); mLogPathToHDFS = cliParser.getOptionValue("log_to_hdfs", ""); if (!mLogPathToHDFS.isEmpty()) { if (!mFileSystem.isDirectory(new Path(mLogPathToHDFS))) { throw new IllegalArgumentException( "The given log path is not a directory on HDFS: " + mLogPathToHDFS); } } return true; }