From 2e6c25493738e45daf4b71fc852a6c3d62cd73f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Wed, 3 Dec 2014 15:09:31 -0800 Subject: [PATCH] metadata injection not needed for indexing service --- .../io/druid/indexer/HadoopDruidIndexerJob.java | 6 ++++++ .../indexing/common/task/HadoopIndexTask.java | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerJob.java b/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerJob.java index 32cd0f4d3f1..decf9d943bf 100644 --- a/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerJob.java +++ b/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerJob.java @@ -19,6 +19,7 @@ package io.druid.indexer; +import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.inject.Inject; import com.metamx.common.logger.Logger; @@ -45,6 +46,11 @@ public class HadoopDruidIndexerJob implements Jobby config.verify(); this.config = config; + Preconditions.checkArgument( + !config.isUpdaterJobSpecSet() || handler != null, + "MetadataStorageUpdaterJobHandler must not be null if ioConfig.metadataUpdateSpec is specified in " + ); + if (config.isUpdaterJobSpecSet()) { metadataStorageUpdaterJob = new MetadataStorageUpdaterJob( config, 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 2b032f47730..f195872dc55 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 @@ -290,10 +290,16 @@ public class HadoopIndexTask extends AbstractTask .withTuningConfig(theSchema.getTuningConfig().withVersion(version)) ); - HadoopDruidIndexerJob job = new HadoopDruidIndexerJob( - config, - injector.getInstance(MetadataStorageUpdaterJobHandler.class) - ); + // MetadataStorageUpdaterJobHandler is only needed when running standalone without indexing service + // In that case the whatever runs the Hadoop Index Task must ensure MetadataStorageUpdaterJobHandler + // can be injected based on the configuration given in config.getSchema().getIOConfig().getMetadataUpdateSpec() + final MetadataStorageUpdaterJobHandler maybeHandler; + if (config.isUpdaterJobSpecSet()) { + maybeHandler = injector.getInstance(MetadataStorageUpdaterJobHandler.class); + } else { + maybeHandler = null; + } + HadoopDruidIndexerJob job = new HadoopDruidIndexerJob(config, maybeHandler); log.info("Starting a hadoop index generator job..."); if (job.run()) {