diff --git a/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorNode.java b/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorNode.java index 029188dbbab..4e161967418 100644 --- a/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorNode.java +++ b/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorNode.java @@ -148,6 +148,7 @@ public class IndexerCoordinatorNode extends RegisteringNode private IndexerZkConfig indexerZkConfig; private TaskRunnerFactory taskRunnerFactory = null; private ResourceManagementSchedulerFactory resourceManagementSchedulerFactory = null; + private HttpClient httpClient = null; private TaskActionClientFactory taskActionClientFactory = null; private TaskMasterLifecycle taskMasterLifecycle = null; private Server server = null; @@ -217,6 +218,12 @@ public class IndexerCoordinatorNode extends RegisteringNode return this; } + public IndexerCoordinatorNode setHttpClient(HttpClient httpClient) + { + this.httpClient = httpClient; + return this; + } + public void doInit() throws Exception { scheduledExecutorFactory = ScheduledExecutors.createFactory(lifecycle); @@ -234,6 +241,7 @@ public class IndexerCoordinatorNode extends RegisteringNode ), getJsonMapper() ); + initializeHttpClient(); initializeEmitter(); initializeMonitors(); initializeIndexerCoordinatorConfig(); @@ -410,13 +418,18 @@ public class IndexerCoordinatorNode extends RegisteringNode getJsonMapper().registerSubtypes(StaticS3FirehoseFactory.class); } + private void initializeHttpClient() + { + if (httpClient == null) { + httpClient = HttpClientInit.createClient( + HttpClientConfig.builder().withNumConnections(1).build(), lifecycle + ); + } + } + private void initializeEmitter() { if (emitter == null) { - final HttpClient httpClient = HttpClientInit.createClient( - HttpClientConfig.builder().withNumConnections(1).build(), lifecycle - ); - emitter = new ServiceEmitter( PropUtils.getProperty(props, "druid.service"), PropUtils.getProperty(props, "druid.host"), @@ -546,9 +559,7 @@ public class IndexerCoordinatorNode extends RegisteringNode ) ), configManager.watch(WorkerSetupData.CONFIG_KEY, WorkerSetupData.class), - HttpClientInit.createClient( - HttpClientConfig.builder().withNumConnections(1).build(), lifecycle - ) + httpClient ); return remoteTaskRunner; diff --git a/merger/src/main/java/com/metamx/druid/merger/worker/http/WorkerNode.java b/merger/src/main/java/com/metamx/druid/merger/worker/http/WorkerNode.java index 43e60628379..33720614ff0 100644 --- a/merger/src/main/java/com/metamx/druid/merger/worker/http/WorkerNode.java +++ b/merger/src/main/java/com/metamx/druid/merger/worker/http/WorkerNode.java @@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.inject.Guice; import com.google.inject.Injector; +import com.google.inject.servlet.GuiceFilter; import com.metamx.common.concurrent.ScheduledExecutorFactory; import com.metamx.common.concurrent.ScheduledExecutors; import com.metamx.common.config.Config; @@ -207,6 +208,7 @@ public class WorkerNode extends RegisteringNode root.addServlet(new ServletHolder(new StatusServlet()), "/status"); root.addEventListener(new GuiceServletConfig(injector)); + root.addFilter(GuiceFilter.class, "/mmx/worker/v1/*", 0); } @LifecycleStart