From 346cf0e04cc6d78cbb089ea6bdab2836994a7e98 Mon Sep 17 00:00:00 2001 From: fjy Date: Thu, 14 Nov 2013 18:18:39 -0800 Subject: [PATCH] fix out of order in urls for hadoop classpath --- .../druid/indexing/common/task/HadoopIndexTask.java | 12 ++++++------ .../src/main/java/io/druid/cli/CliHadoopIndexer.java | 11 +++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/indexing-service/src/main/java/io/druid/indexing/common/task/HadoopIndexTask.java b/indexing-service/src/main/java/io/druid/indexing/common/task/HadoopIndexTask.java index 730a4a8f7aa..e687875433b 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/task/HadoopIndexTask.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/task/HadoopIndexTask.java @@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; -import com.google.api.client.util.Sets; +import com.google.api.client.util.Lists; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; @@ -50,7 +50,6 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; import java.util.List; -import java.util.Set; public class HadoopIndexTask extends AbstractTask { @@ -131,7 +130,7 @@ public class HadoopIndexTask extends AbstractTask aetherClient, hadoopCoordinates ); - final Set extensionURLs = Sets.newHashSet(); + final List extensionURLs = Lists.newArrayList(); for (String coordinate : extensionsConfig.getCoordinates()) { final ClassLoader coordinateLoader = Initialization.getClassLoaderForCoordinates( aetherClient, coordinate @@ -139,17 +138,18 @@ public class HadoopIndexTask extends AbstractTask extensionURLs.addAll(Arrays.asList(((URLClassLoader) coordinateLoader).getURLs())); } - final Set nonHadoopURLs = Sets.newHashSet(); + final List nonHadoopURLs = Lists.newArrayList(); nonHadoopURLs.addAll(Arrays.asList(((URLClassLoader) HadoopIndexTask.class.getClassLoader()).getURLs())); - final Set driverURLs = Sets.newHashSet(); + final List driverURLs = Lists.newArrayList(); driverURLs.addAll(nonHadoopURLs); + // put hadoop dependencies last to avoid jets3t & apache.httpcore version conflicts driverURLs.addAll(Arrays.asList(((URLClassLoader) hadoopLoader).getURLs())); final URLClassLoader loader = new URLClassLoader(driverURLs.toArray(new URL[driverURLs.size()]), null); Thread.currentThread().setContextClassLoader(loader); - final Set jobUrls = Sets.newHashSet(); + final List jobUrls = Lists.newArrayList(); jobUrls.addAll(nonHadoopURLs); jobUrls.addAll(extensionURLs); diff --git a/services/src/main/java/io/druid/cli/CliHadoopIndexer.java b/services/src/main/java/io/druid/cli/CliHadoopIndexer.java index fed08b5d1b3..208b8a97e83 100644 --- a/services/src/main/java/io/druid/cli/CliHadoopIndexer.java +++ b/services/src/main/java/io/druid/cli/CliHadoopIndexer.java @@ -19,7 +19,6 @@ package io.druid.cli; -import com.google.api.client.util.Sets; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.inject.Inject; @@ -37,7 +36,6 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; import java.util.List; -import java.util.Set; /** */ @@ -69,7 +67,7 @@ public class CliHadoopIndexer implements Runnable aetherClient, hadoopCoordinates ); - final Set extensionURLs = Sets.newHashSet(); + final List extensionURLs = Lists.newArrayList(); for (String coordinate : extensionsConfig.getCoordinates()) { final ClassLoader coordinateLoader = Initialization.getClassLoaderForCoordinates( aetherClient, coordinate @@ -77,17 +75,18 @@ public class CliHadoopIndexer implements Runnable extensionURLs.addAll(Arrays.asList(((URLClassLoader) coordinateLoader).getURLs())); } - final Set nonHadoopURLs = Sets.newHashSet(); + final List nonHadoopURLs = Lists.newArrayList(); nonHadoopURLs.addAll(Arrays.asList(((URLClassLoader) CliHadoopIndexer.class.getClassLoader()).getURLs())); - final Set driverURLs = Sets.newHashSet(); + final List driverURLs = Lists.newArrayList(); driverURLs.addAll(nonHadoopURLs); + // put hadoop dependencies last to avoid jets3t & apache.httpcore version conflicts driverURLs.addAll(Arrays.asList(((URLClassLoader) hadoopLoader).getURLs())); final URLClassLoader loader = new URLClassLoader(driverURLs.toArray(new URL[driverURLs.size()]), null); Thread.currentThread().setContextClassLoader(loader); - final Set jobUrls = Sets.newHashSet(); + final List jobUrls = Lists.newArrayList(); jobUrls.addAll(nonHadoopURLs); jobUrls.addAll(extensionURLs);