/** * Populates the list of {@link URL} that this ClassLoader uses, including all URLs used by the parent of the * given ClassLoader. This is the same as calling {@link #getClassLoaderURLs(ClassLoader, boolean, Collection)} with * {@code childFirst} set to {@code false}. * * @param classLoader the {@link ClassLoader} for searching urls * @param urls a {@link Collection} for storing the {@link URL}s * @return the same {@link Collection} passed from the parameter */ public static <T extends Collection<? super URL>> T getClassLoaderURLs(ClassLoader classLoader, T urls) { return getClassLoaderURLs(classLoader, false, urls); }
/** * Populates the list of {@link URL} that this ClassLoader uses, including all URLs used by the parent of the * given ClassLoader. This is the same as calling {@link #getClassLoaderURLs(ClassLoader, boolean, Collection)} with * {@code childFirst} set to {@code false}. * * @param classLoader the {@link ClassLoader} for searching urls * @param urls a {@link Collection} for storing the {@link URL}s * @return the same {@link Collection} passed from the parameter */ public static <T extends Collection<? super URL>> T getClassLoaderURLs(ClassLoader classLoader, T urls) { return getClassLoaderURLs(classLoader, false, urls); }
/** * Returns an array of URLs to be used for creation of classloader for Spark, based on the urls used by the * given {@link ClassLoader}. */ private URL[] getSparkClassloaderURLs(ClassLoader classLoader) throws IOException { List<URL> urls = ClassLoaders.getClassLoaderURLs(classLoader, new LinkedList<URL>()); // If Spark classes are not available in the given ClassLoader, try to locate the Spark framework // This class cannot have dependency on Spark directly, hence using the class resource to discover if SparkContext // is there if (classLoader.getResource("org/apache/spark/SparkContext.class") == null) { // The scala from the Spark library should replace the one from the parent classloader // CDH also packages spark-yarn-shuffle.jar linked to spark-<version>-yarn-shuffle.jar in yarn's lib dir Iterator<URL> itor = urls.iterator(); while (itor.hasNext()) { URL url = itor.next(); String filename = Paths.get(url.getPath()).getFileName().toString(); if (filename.startsWith("org.scala-lang") || filename.startsWith("spark-")) { itor.remove(); } } for (File file : SparkPackageUtils.getLocalSparkLibrary(providerSparkCompat)) { urls.add(file.toURI().toURL()); } } return urls.toArray(new URL[urls.size()]); }
/** * Returns an array of URLs to be used for creation of classloader for Spark, based on the urls used by the * given {@link ClassLoader}. */ private URL[] getSparkClassloaderURLs(ClassLoader classLoader) throws IOException { List<URL> urls = ClassLoaders.getClassLoaderURLs(classLoader, new LinkedList<URL>()); // If Spark classes are not available in the given ClassLoader, try to locate the Spark framework // This class cannot have dependency on Spark directly, hence using the class resource to discover if SparkContext // is there if (classLoader.getResource("org/apache/spark/SparkContext.class") == null) { // The scala from the Spark library should replace the one from the parent classloader // CDH also packages spark-yarn-shuffle.jar linked to spark-<version>-yarn-shuffle.jar in yarn's lib dir Iterator<URL> itor = urls.iterator(); while (itor.hasNext()) { URL url = itor.next(); String filename = Paths.get(url.getPath()).getFileName().toString(); if (filename.startsWith("org.scala-lang") || filename.startsWith("spark-")) { itor.remove(); } } for (File file : SparkPackageUtils.getLocalSparkLibrary(providerSparkCompat)) { urls.add(file.toURI().toURL()); } } return urls.toArray(new URL[urls.size()]); }
/** * Returns an array of URLs to be used for creation of classloader for Spark, based on the urls used by the * given {@link ClassLoader}. */ private URL[] getSparkClassloaderURLs(ClassLoader classLoader) throws IOException { List<URL> urls = ClassLoaders.getClassLoaderURLs(classLoader, new LinkedList<URL>()); // If Spark classes are not available in the given ClassLoader, try to locate the Spark framework // This class cannot have dependency on Spark directly, hence using the class resource to discover if SparkContext // is there if (classLoader.getResource("org/apache/spark/SparkContext.class") == null) { // The scala from the Spark library should replace the one from the parent classloader // CDH also packages spark-yarn-shuffle.jar linked to spark-<version>-yarn-shuffle.jar in yarn's lib dir Iterator<URL> itor = urls.iterator(); while (itor.hasNext()) { URL url = itor.next(); String filename = Paths.get(url.getPath()).getFileName().toString(); if (filename.startsWith("org.scala-lang") || filename.startsWith("spark-")) { itor.remove(); } } for (File file : SparkPackageUtils.getLocalSparkLibrary(providerSparkCompat)) { urls.add(file.toURI().toURL()); } } return urls.toArray(new URL[urls.size()]); }
List<URL> urls = ClassLoaders.getClassLoaderURLs(getClass().getClassLoader(), new ArrayList<URL>()); for (File libJar : LoggingUtil.getExtensionJars(cConf)) { urls.add(libJar.toURI().toURL());
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler()); ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); List<URL> urls = ClassLoaders.getClassLoaderURLs(systemClassLoader, new ArrayList<URL>());
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler()); ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); List<URL> urls = ClassLoaders.getClassLoaderURLs(systemClassLoader, new ArrayList<URL>());
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler()); ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); Set<URL> urls = ClassLoaders.getClassLoaderURLs(systemClassLoader, new LinkedHashSet<URL>());
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler()); ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); Set<URL> urls = ClassLoaders.getClassLoaderURLs(systemClassLoader, new LinkedHashSet<URL>());
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler()); ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); Set<URL> urls = ClassLoaders.getClassLoaderURLs(systemClassLoader, new LinkedHashSet<URL>());
List<URL> urls = ClassLoaders.getClassLoaderURLs(getClass().getClassLoader(), new ArrayList<URL>()); ClassLoader cl = new InterceptableClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader().getParent()) {