List of usage examples for org.apache.hadoop.util GenericOptionsParser getLibJars
public static URL[] getLibJars(Configuration conf) throws IOException
From source file:com.asakusafw.runtime.stage.launcher.LauncherOptionsParserTest.java
License:Apache License
/** * w/ libjars.// ww w.j a v a 2s . c o m * @throws Exception if failed */ @Test public void w_libjars() throws Exception { File lib = putFile("dummy.jar"); LauncherOptions options = parse( new String[] { MockTool.class.getName(), LauncherOptionsParser.KEY_ARG_LIBRARIES, lib.getPath(), }); assertClasspath(options.getApplicationClassLoader().getURLs(), "testing"); assertThat(lib, is(inClasspath(options.getApplicationClassLoader().getURLs()))); assertClasspath(GenericOptionsParser.getLibJars(conf), "testing"); assertThat(lib, is(inClasspath(GenericOptionsParser.getLibJars(conf)))); JobConf jc = new JobConf(conf); assertThat(jc.getJar(), is(nullValue())); }
From source file:com.asakusafw.runtime.stage.launcher.LauncherOptionsParserTest.java
License:Apache License
/** * w/ libjars.// ww w . j a v a 2 s.com * @throws Exception if failed */ @Test public void w_libjars_w_cache() throws Exception { File cacheRepo = folder.newFolder(); conf.set(LauncherOptionsParser.KEY_CACHE_REPOSITORY, cacheRepo.toURI().toString()); File lib = putFile("dummy.jar"); LauncherOptions options = parse( new String[] { MockTool.class.getName(), LauncherOptionsParser.KEY_ARG_LIBRARIES, lib.getPath(), }); assertClasspath(options.getApplicationClassLoader().getURLs(), "testing"); assertThat(lib, is(inClasspath(options.getApplicationClassLoader().getURLs()))); assertClasspath(GenericOptionsParser.getLibJars(conf), "testing"); assertThat(lib, is(not(inClasspath(GenericOptionsParser.getLibJars(conf))))); }
From source file:com.asakusafw.runtime.stage.launcher.LauncherOptionsParserTest.java
License:Apache License
/** * w/ libjars with disabled cache.//w ww .j a va 2 s . c o m * @throws Exception if failed */ @Test public void w_libjars_disabled() throws Exception { File cacheRepo = folder.newFolder(); conf.set(LauncherOptionsParser.KEY_CACHE_REPOSITORY, cacheRepo.toURI().toString()); conf.setBoolean(LauncherOptionsParser.KEY_CACHE_ENABLED, false); File lib = putFile("dummy.jar"); LauncherOptions options = parse( new String[] { MockTool.class.getName(), LauncherOptionsParser.KEY_ARG_LIBRARIES, lib.getPath(), }); assertClasspath(options.getApplicationClassLoader().getURLs(), "testing"); assertThat(lib, is(inClasspath(options.getApplicationClassLoader().getURLs()))); assertClasspath(GenericOptionsParser.getLibJars(conf), "testing"); assertThat(lib, is(inClasspath(GenericOptionsParser.getLibJars(conf)))); }
From source file:io.apigee.lembos.utils.RunnerUtils.java
License:Apache License
/** * Adds the "-libjars" entries, if any, to the {@link ClassLoader}. * * @param conf the Hadoop configuration//www. j a va 2s .c o m * * @throws IOException if there is an issue creating the new ClassLoader */ public static void addLibJarsToClassLoader(final Configuration conf) throws IOException { final URL[] libJars = GenericOptionsParser.getLibJars(conf); if (libJars != null && libJars.length > 0) { final ClassLoader loader = new URLClassLoader(libJars, conf.getClassLoader()); Thread.currentThread().setContextClassLoader(loader); conf.setClassLoader(loader); } }