Skip to content

Commit

Permalink
Make HadoopTasks's classloader a single one
Browse files Browse the repository at this point in the history
  • Loading branch information
drcrallen committed Feb 19, 2016
1 parent 5ba8893 commit 87752be
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -116,9 +117,8 @@ protected ClassLoader buildClassLoader(final TaskToolbox toolbox) throws Excepti
final List<URL> nonHadoopNotDruidURLs = Lists.newArrayList(nonHadoopURLs);
nonHadoopNotDruidURLs.removeAll(druidURLs);

// Start from a fresh slate
ClassLoader classLoader = null;
classLoader = new URLClassLoader(nonHadoopNotDruidURLs.toArray(new URL[nonHadoopNotDruidURLs.size()]), classLoader);
final List<URL> localClassLoaderURLs = new ArrayList<>();
localClassLoaderURLs.addAll(nonHadoopNotDruidURLs);

// hadoop dependencies come before druid classes because some extensions depend on them
for (final File hadoopDependency :
Expand All @@ -127,11 +127,12 @@ protected ClassLoader buildClassLoader(final TaskToolbox toolbox) throws Excepti
extensionsConfig
)) {
final ClassLoader hadoopLoader = Initialization.getClassLoaderForExtension(hadoopDependency);
classLoader = new URLClassLoader(((URLClassLoader) hadoopLoader).getURLs(), classLoader);
localClassLoaderURLs.addAll(Arrays.asList(((URLClassLoader) hadoopLoader).getURLs()));
}

classLoader = new URLClassLoader(druidURLs.toArray(new URL[druidURLs.size()]), classLoader);
classLoader = new URLClassLoader(extensionURLs.toArray(new URL[extensionURLs.size()]), classLoader);
localClassLoaderURLs.addAll(druidURLs);
localClassLoaderURLs.addAll(extensionURLs);
final ClassLoader classLoader = new URLClassLoader(localClassLoaderURLs.toArray(new URL[localClassLoaderURLs.size()]), null);

final List<URL> jobUrls = Lists.newArrayList();
jobUrls.addAll(nonHadoopURLs);
Expand Down

0 comments on commit 87752be

Please sign in to comment.