Merge pull request #503 from metamx/pulldeps

PullDependencies changes.
This commit is contained in:
xvrl 2014-04-22 14:40:59 -07:00
commit 4c7399bfbf
2 changed files with 47 additions and 4 deletions

View File

@ -66,7 +66,8 @@ public class HadoopIndexTask extends AbstractTask
extensionsConfig = Initialization.makeStartupInjector().getInstance(ExtensionsConfig.class);
}
private static String defaultHadoopCoordinates = "org.apache.hadoop:hadoop-client:2.3.0";
public static String DEFAULT_HADOOP_COORDINATES = "org.apache.hadoop:hadoop-client:2.3.0";
@JsonIgnore
private final HadoopDruidIndexerSchema schema;
@JsonIgnore
@ -102,7 +103,7 @@ public class HadoopIndexTask extends AbstractTask
this.schema = schema;
this.hadoopDependencyCoordinates = hadoopDependencyCoordinates == null ? Arrays.<String>asList(
hadoopCoordinates == null ? defaultHadoopCoordinates : hadoopCoordinates
hadoopCoordinates == null ? DEFAULT_HADOOP_COORDINATES : hadoopCoordinates
) : hadoopDependencyCoordinates;
}

View File

@ -19,7 +19,17 @@
package io.druid.cli;
import com.google.api.client.util.Lists;
import com.google.common.base.Throwables;
import com.google.inject.Inject;
import io.airlift.command.Command;
import io.airlift.command.Option;
import io.druid.indexing.common.task.HadoopIndexTask;
import io.druid.initialization.Initialization;
import io.druid.server.initialization.ExtensionsConfig;
import io.tesla.aether.internal.DefaultTeslaAether;
import java.util.List;
@Command(
@ -28,8 +38,40 @@ import io.airlift.command.Command;
)
public class PullDependencies implements Runnable
{
@Option(name = "-c",
title = "coordinate",
description = "extra dependencies to pull down (e.g. hadoop coordinates)",
required = false)
public List<String> coordinates;
@Option(name = "--no-default-hadoop",
description = "don't pull down the default HadoopIndexTask dependencies",
required = false)
public boolean noDefaultHadoop;
@Inject
public ExtensionsConfig extensionsConfig = null;
@Override
public void run() {
// dependencies are pulled down as a side-effect of Guice injection
public void run()
{
// Druid dependencies are pulled down as a side-effect of Guice injection. Extra dependencies are pulled down as
// a side-effect of getting class loaders.
final List<String> allCoordinates = Lists.newArrayList();
if (coordinates != null) {
allCoordinates.addAll(coordinates);
}
if (!noDefaultHadoop) {
allCoordinates.add(HadoopIndexTask.DEFAULT_HADOOP_COORDINATES);
}
try {
final DefaultTeslaAether aetherClient = Initialization.getAetherClient(extensionsConfig);
for (final String coordinate : allCoordinates) {
Initialization.getClassLoaderForCoordinates(aetherClient, coordinate);
}
}
catch (Exception e) {
throw Throwables.propagate(e);
}
}
}