diff --git a/client/src/main/java/com/metamx/druid/guice/QueryToolChestModuleStupidCase.java b/client/src/main/java/com/metamx/druid/guice/QueryToolChestModuleStupidCase.java new file mode 100644 index 00000000000..54a9f46b94c --- /dev/null +++ b/client/src/main/java/com/metamx/druid/guice/QueryToolChestModuleStupidCase.java @@ -0,0 +1,51 @@ +package com.metamx.druid.guice; + +import com.google.common.collect.ImmutableMap; +import com.google.inject.Binder; +import com.google.inject.Module; +import com.google.inject.TypeLiteral; +import com.google.inject.multibindings.MapBinder; +import com.metamx.druid.Query; +import com.metamx.druid.query.QueryToolChest; +import com.metamx.druid.query.group.GroupByQuery; +import com.metamx.druid.query.group.GroupByQueryConfig; +import com.metamx.druid.query.group.GroupByQueryQueryToolChest; +import com.metamx.druid.query.metadata.SegmentMetadataQuery; +import com.metamx.druid.query.metadata.SegmentMetadataQueryQueryToolChest; +import com.metamx.druid.query.search.SearchQuery; +import com.metamx.druid.query.search.SearchQueryQueryToolChest; +import com.metamx.druid.query.timeboundary.TimeBoundaryQuery; +import com.metamx.druid.query.timeboundary.TimeBoundaryQueryQueryToolChest; +import com.metamx.druid.query.timeseries.TimeseriesQuery; +import com.metamx.druid.query.timeseries.TimeseriesQueryQueryToolChest; + +import java.util.Map; + +/** + */ +public class QueryToolChestModuleStupidCase implements Module +{ + final Map, Class> mappings = + ImmutableMap., Class>builder() + .put(TimeseriesQuery.class, TimeseriesQueryQueryToolChest.class) + .put(SearchQuery.class, SearchQueryQueryToolChest.class) + .put(TimeBoundaryQuery.class, TimeBoundaryQueryQueryToolChest.class) + .put(SegmentMetadataQuery.class, SegmentMetadataQueryQueryToolChest.class) + .put(GroupByQuery.class, GroupByQueryQueryToolChest.class) + .build(); + + @Override + public void configure(Binder binder) + { + MapBinder, QueryToolChest> toolChests = MapBinder.newMapBinder( + binder, new TypeLiteral>(){}, new TypeLiteral(){} + ); + + for (Map.Entry, Class> entry : mappings.entrySet()) { + toolChests.addBinding(entry.getKey()).to(entry.getValue()); + binder.bind(entry.getValue()).in(LazySingleton.class); + } + + JsonConfigProvider.bind(binder, "druid.query.groupBy", GroupByQueryConfig.class); + } +} diff --git a/server/src/main/java/com/metamx/druid/guice/QueryRunnerFactoryModule.java b/server/src/main/java/com/metamx/druid/guice/QueryRunnerFactoryModuleStupidCase.java similarity index 96% rename from server/src/main/java/com/metamx/druid/guice/QueryRunnerFactoryModule.java rename to server/src/main/java/com/metamx/druid/guice/QueryRunnerFactoryModuleStupidCase.java index 81078b56595..6e6c015ab38 100644 --- a/server/src/main/java/com/metamx/druid/guice/QueryRunnerFactoryModule.java +++ b/server/src/main/java/com/metamx/druid/guice/QueryRunnerFactoryModuleStupidCase.java @@ -22,7 +22,7 @@ import java.util.Map; /** */ -public class QueryRunnerFactoryModule extends QueryToolChestModule +public class QueryRunnerFactoryModuleStupidCase extends QueryToolChestModuleStupidCase { final Map, Class> mappings = ImmutableMap., Class>builder() diff --git a/services/src/main/java/io/druid/cli/CliBroker.java b/services/src/main/java/io/druid/cli/CliBroker.java index d5e00e4c7ff..53aa0d8554b 100644 --- a/services/src/main/java/io/druid/cli/CliBroker.java +++ b/services/src/main/java/io/druid/cli/CliBroker.java @@ -6,7 +6,7 @@ import com.metamx.druid.curator.CuratorModule; import com.metamx.druid.guice.BrokerModule; import com.metamx.druid.guice.HttpClientModule; import com.metamx.druid.guice.LifecycleModule; -import com.metamx.druid.guice.QueryToolChestModule; +import com.metamx.druid.guice.QueryToolChestModuleStupidCase; import com.metamx.druid.guice.QueryableModule; import com.metamx.druid.guice.ServerModule; import com.metamx.druid.guice.ServerViewModule; @@ -47,7 +47,7 @@ public class CliBroker extends ServerRunnable new JettyServerModule(new QueryJettyServerInitializer()) .addResource(StatusResource.class), new QueryableModule(ClientQuerySegmentWalker.class), - new QueryToolChestModule(), + new QueryToolChestModuleStupidCase(), new ServerViewModule(), new HttpClientModule("druid.broker.http", Client.class), new BrokerModule() diff --git a/services/src/main/java/io/druid/cli/CliHistorical.java b/services/src/main/java/io/druid/cli/CliHistorical.java index 01bb7484198..654f9b7d58e 100644 --- a/services/src/main/java/io/druid/cli/CliHistorical.java +++ b/services/src/main/java/io/druid/cli/CliHistorical.java @@ -8,7 +8,7 @@ import com.metamx.druid.curator.CuratorModule; import com.metamx.druid.guice.HistoricalModule; import com.metamx.druid.guice.HttpClientModule; import com.metamx.druid.guice.LifecycleModule; -import com.metamx.druid.guice.QueryRunnerFactoryModule; +import com.metamx.druid.guice.QueryRunnerFactoryModuleStupidCase; import com.metamx.druid.guice.QueryableModule; import com.metamx.druid.guice.ServerModule; import com.metamx.druid.http.StatusResource; @@ -47,7 +47,7 @@ public class CliHistorical extends ServerRunnable new JettyServerModule(new QueryJettyServerInitializer()) .addResource(StatusResource.class), new QueryableModule(ServerManager.class), - new QueryRunnerFactoryModule(), + new QueryRunnerFactoryModuleStupidCase(), HistoricalModule.class ); }