Merge pull request #704 from metamx/hadoop-cli-coordinates

CliHadoopIndexer: Modify maven arguments to be consistent with pull-deps.
This commit is contained in:
xvrl 2014-08-26 13:42:01 -07:00
commit 6c26c828de
2 changed files with 18 additions and 9 deletions

View File

@ -46,20 +46,21 @@ import java.util.List;
public class CliHadoopIndexer implements Runnable
{
private static String defaultHadoopCoordinates = "org.apache.hadoop:hadoop-client:2.3.0";
private static final String DEFAULT_HADOOP_COORDINATES = "org.apache.hadoop:hadoop-client:2.3.0";
private static final Logger log = new Logger(CliHadoopIndexer.class);
@Arguments(description = "A JSON object or the path to a file that contains a JSON object", required = true)
private String argumentSpec;
@Option(name = "hadoop",
description = "The maven coordinates to the version of hadoop to run with. Defaults to org.apache.hadoop:hadoop-client:2.3.0")
private String hadoopCoordinates = defaultHadoopCoordinates;
@Option(name = {"-c", "--coordinate", "hadoopDependencies"},
description = "extra dependencies to pull down (e.g. non-default hadoop coordinates or extra hadoop jars)")
private List<String> coordinates;
@Option(name = "hadoopDependencies",
description = "The maven coordinates to the version of hadoop and all dependencies to run with. Defaults to using org.apache.hadoop:hadoop-client:2.3.0")
private List<String> hadoopDependencyCoordinates = Arrays.<String>asList(defaultHadoopCoordinates);
@Option(name = "--no-default-hadoop",
description = "don't pull down the default hadoop version (currently " + DEFAULT_HADOOP_COORDINATES + ")",
required = false)
public boolean noDefaultHadoop;
@Inject
private ExtensionsConfig extensionsConfig = null;
@ -69,6 +70,14 @@ public class CliHadoopIndexer implements Runnable
public void run()
{
try {
final List<String> allCoordinates = Lists.newArrayList();
if (coordinates != null) {
allCoordinates.addAll(coordinates);
}
if (!noDefaultHadoop) {
allCoordinates.add(DEFAULT_HADOOP_COORDINATES);
}
final DefaultTeslaAether aetherClient = Initialization.getAetherClient(extensionsConfig);
final List<URL> extensionURLs = Lists.newArrayList();
@ -85,7 +94,7 @@ public class CliHadoopIndexer implements Runnable
final List<URL> driverURLs = Lists.newArrayList();
driverURLs.addAll(nonHadoopURLs);
// put hadoop dependencies last to avoid jets3t & apache.httpcore version conflicts
for (String coordinate : hadoopDependencyCoordinates) {
for (String coordinate : allCoordinates) {
final ClassLoader hadoopLoader = Initialization.getClassLoaderForCoordinates(
aetherClient, coordinate
);

View File

@ -39,7 +39,7 @@ import java.util.List;
)
public class PullDependencies implements Runnable
{
@Option(name = "-c",
@Option(name = {"-c", "--coordinate"},
title = "coordinate",
description = "extra dependencies to pull down (e.g. hadoop coordinates)",
required = false)