@Override public void load(String name, Location targetLocation) throws IOException { bundler.createBundle(targetLocation, classes); } });
@Override public void load(String name, Location targetLocation) throws IOException { bundler.createBundle(targetLocation, ApplicationMasterMain.class, TwillContainerMain.class, OptionSpec.class); } });
@Override public void load(String name, Location targetLocation) throws IOException { bundler.createBundle(targetLocation, classes); } });
@Override public void load(String name, Location targetLocation) throws IOException { bundler.createBundle(targetLocation, classes); } });
@Override public void load(String name, Location targetLocation) throws IOException { bundler.createBundle(targetLocation, ApplicationMasterMain.class, TwillContainerMain.class, OptionSpec.class); } });
@Override public void load(String name, Location targetLocation) throws IOException { bundler.createBundle(targetLocation, classes); } });
@Override public void load(String name, Location targetLocation) throws IOException { // Stuck in the yarnAppClient class to make bundler being able to pickup the right yarn-client version bundler.createBundle(targetLocation, ApplicationMasterMain.class, yarnAppClient.getClass(), TwillContainerMain.class, OptionSpec.class); } });
@Override public void load(String name, Location targetLocation) throws IOException { // Stuck in the yarnAppClient class to make bundler being able to pickup the right yarn-client version bundler.createBundle(targetLocation, ApplicationMasterMain.class, yarnAppClient.getClass(), TwillContainerMain.class, OptionSpec.class); } });
public void createBundle(Location target, Iterable<Class<?>> classes) throws IOException { createBundle(target, classes, ImmutableList.<URI>of()); }
public void createBundle(Location target, Iterable<Class<?>> classes) throws IOException { createBundle(target, classes, ImmutableList.<URI>of()); }
/** * Same as calling {@link #createBundle(Location, Iterable)}. */ public void createBundle(Location target, Class<?> clz, Class<?>...classes) throws IOException { createBundle(target, ImmutableSet.<Class<?>>builder().add(clz).add(classes).build()); }
/** * Same as calling {@link #createBundle(Location, Iterable)}. */ public void createBundle(Location target, Class<?> clz, Class<?>...classes) throws IOException { createBundle(target, ImmutableSet.<Class<?>>builder().add(clz).add(classes).build()); }
private void createResourcesJar(ApplicationBundler bundler, Map<String, LocalFile> localFiles, Path stagingDir) throws IOException { // If there is no resources, no need to create the jar file. if (resources.isEmpty()) { return; } LOG.debug("Create and copy {}", Constants.Files.RESOURCES_JAR); Location location = Locations.toLocation(Files.createTempFile(stagingDir, Constants.Files.RESOURCES_JAR, null)); bundler.createBundle(location, Collections.emptyList(), resources); LOG.debug("Done {}", Constants.Files.RESOURCES_JAR); localFiles.put(Constants.Files.RESOURCES_JAR, createLocalFile(Constants.Files.RESOURCES_JAR, location, true)); }
private void createResourcesJar(ApplicationBundler bundler, Map<String, LocalFile> localFiles, Path stagingDir) throws IOException { // If there is no resources, no need to create the jar file. if (resources.isEmpty()) { return; } LOG.debug("Create and copy {}", Constants.Files.RESOURCES_JAR); Location location = Locations.toLocation(Files.createTempFile(stagingDir, Constants.Files.RESOURCES_JAR, null)); bundler.createBundle(location, Collections.emptyList(), resources); LOG.debug("Done {}", Constants.Files.RESOURCES_JAR); localFiles.put(Constants.Files.RESOURCES_JAR, createLocalFile(Constants.Files.RESOURCES_JAR, location, true)); }
private void createResourcesJar(ApplicationBundler bundler, Map<String, LocalFile> localFiles) throws IOException { // If there is no resources, no need to create the jar file. if (resources.isEmpty()) { return; } LOG.debug("Create and copy {}", Constants.Files.RESOURCES_JAR); Location location = createTempLocation(Constants.Files.RESOURCES_JAR); bundler.createBundle(location, Collections.<Class<?>>emptyList(), resources); LOG.debug("Done {}", Constants.Files.RESOURCES_JAR); localFiles.put(Constants.Files.RESOURCES_JAR, createLocalFile(Constants.Files.RESOURCES_JAR, location, true)); }
private void createResourcesJar(ApplicationBundler bundler, Map<String, LocalFile> localFiles) throws IOException { // If there is no resources, no need to create the jar file. if (resources.isEmpty()) { return; } LOG.debug("Create and copy {}", Constants.Files.RESOURCES_JAR); Location location = createTempLocation(Constants.Files.RESOURCES_JAR); bundler.createBundle(location, Collections.<Class<?>>emptyList(), resources); LOG.debug("Done {}", Constants.Files.RESOURCES_JAR); localFiles.put(Constants.Files.RESOURCES_JAR, createLocalFile(Constants.Files.RESOURCES_JAR, location, true)); }
"org.apache.hbase", "org.apache.hive")); bundler.createBundle(Locations.toLocation(tempFile), clz); } finally { ClassLoaders.setContextClassLoader(remembered);
"org.apache.hbase", "org.apache.hive")); bundler.createBundle(Locations.toLocation(tempFile), clz); } finally { ClassLoaders.setContextClassLoader(remembered);
"org.apache.hbase")); Location jarLocation = locationFactory.create(clz.getName()).getTempFile(".jar"); bundler.createBundle(jarLocation, ImmutableSet.<Class<?>>builder().add(clz).addAll(classes).build());
@Test public void testExtraClassPath() throws IOException, ClassNotFoundException { File tmpDir = TMP_FOLDER.newFolder(); // Create two jars, one with guava, one with gson ApplicationBundler bundler = new ApplicationBundler(new ClassAcceptor()); Location guavaJar = Locations.toLocation(new File(tmpDir, "guava.jar")); bundler.createBundle(guavaJar, ImmutableList.class); Location gsonJar = Locations.toLocation(new File(tmpDir, "gson.jar")); bundler.createBundle(gsonJar, Gson.class); // Unpack them File guavaDir = BundleJarUtil.unJar(guavaJar, TMP_FOLDER.newFolder()); File gsonDir = BundleJarUtil.unJar(gsonJar, TMP_FOLDER.newFolder()); // Create a DirectoryClassLoader using guava dir as the main directory, with the gson dir in the extra classpath String extraClassPath = gsonDir.getAbsolutePath() + File.pathSeparatorChar + gsonDir.getAbsolutePath() + "/lib/*"; ClassLoader cl = new DirectoryClassLoader(guavaDir, extraClassPath, null, Arrays.asList("lib")); // Should be able to load both guava and gson class from the class loader cl.loadClass(ImmutableList.class.getName()); cl.loadClass(Gson.class.getName()); }