From 6316718ae0ad2e2b81eb95710f6d4beaa15644c4 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Tue, 11 Aug 2015 16:50:35 +0200 Subject: [PATCH] Flatten SearchService and clean up build-in registration Relates to #12783 --- .../client/transport/TransportClient.java | 9 +- .../functionscore/FunctionScoreModule.java | 63 --- .../ScoreFunctionParserMapper.java | 38 +- .../elasticsearch/search/SearchModule.java | 358 ++++++++++++++++-- .../search/SearchServiceModule.java | 46 --- .../search/TransportSearchModule.java | 41 -- .../aggregations/AggregationModule.java | 156 -------- .../aggregations/AggregatorParsers.java | 2 +- .../TransportAggregationModule.java | 148 -------- .../heuristics/ScriptHeuristic.java | 1 - .../SignificanceHeuristicParserMapper.java | 31 +- .../SignificanceHeuristicStreams.java | 35 +- .../SignificantTermsHeuristicModule.java | 57 --- ...nsportSignificantTermsHeuristicModule.java | 53 --- .../movavg/models/MovAvgModelModule.java | 56 --- .../models/MovAvgModelParserMapper.java | 25 +- .../movavg/models/MovAvgModelStreams.java | 33 +- .../models/TransportMovAvgModelModule.java | 52 --- .../search/fetch/FetchSubPhaseModule.java | 74 ---- .../highlight/FastVectorHighlighter.java | 2 - .../search/highlight/HighlightModule.java | 52 --- .../search/highlight/Highlighters.java | 29 +- .../search/suggest/SuggestModule.java | 58 --- .../search/suggest/Suggesters.java | 28 +- .../index/query/TemplateQueryParserTest.java | 7 +- .../SignificantTermsSignificanceScoreIT.java | 8 +- .../SignificanceHeuristicTests.java | 12 +- .../search/fetch/FetchSubPhasePluginIT.java | 5 +- .../functionscore/FunctionScorePluginIT.java | 6 +- .../highlight/CustomHighlighterPlugin.java | 3 +- .../search/suggest/CustomSuggesterPlugin.java | 5 +- .../test/InternalTestCluster.java | 6 +- .../test/engine/MockEngineFactory.java | 4 + 33 files changed, 523 insertions(+), 980 deletions(-) delete mode 100644 core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/SearchServiceModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/TransportSearchModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificantTermsHeuristicModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/TransportSignificantTermsHeuristicModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/TransportMovAvgModelModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/fetch/FetchSubPhaseModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/highlight/HighlightModule.java delete mode 100644 core/src/main/java/org/elasticsearch/search/suggest/SuggestModule.java diff --git a/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java index c84d3692596..be609e44fa1 100644 --- a/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java +++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java @@ -47,7 +47,7 @@ import org.elasticsearch.monitor.MonitorService; import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.plugins.PluginsModule; import org.elasticsearch.plugins.PluginsService; -import org.elasticsearch.search.TransportSearchModule; +import org.elasticsearch.search.SearchModule; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPoolModule; import org.elasticsearch.transport.TransportModule; @@ -138,8 +138,13 @@ public class TransportClient extends AbstractClient { modules.add(new NetworkModule()); modules.add(new ClusterNameModule(this.settings)); modules.add(new ThreadPoolModule(threadPool)); - modules.add(new TransportSearchModule()); modules.add(new TransportModule(this.settings)); + modules.add(new SearchModule(this.settings) { + @Override + protected void configure() { + // noop + } + }); modules.add(new ActionModule(true)); modules.add(new ClientTransportModule()); modules.add(new CircuitBreakerModule(this.settings)); diff --git a/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreModule.java b/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreModule.java deleted file mode 100644 index c32896ac889..00000000000 --- a/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreModule.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.index.query.functionscore; - -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.multibindings.Multibinder; -import org.elasticsearch.index.query.functionscore.exp.ExponentialDecayFunctionParser; -import org.elasticsearch.index.query.functionscore.factor.FactorParser; -import org.elasticsearch.index.query.functionscore.fieldvaluefactor.FieldValueFactorFunctionParser; -import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionParser; -import org.elasticsearch.index.query.functionscore.lin.LinearDecayFunctionParser; -import org.elasticsearch.index.query.functionscore.random.RandomScoreFunctionParser; -import org.elasticsearch.index.query.functionscore.script.ScriptScoreFunctionParser; - -import java.util.List; - -/** - * - */ -public class FunctionScoreModule extends AbstractModule { - - private List> parsers = Lists.newArrayList(); - - public FunctionScoreModule() { - registerParser(FactorParser.class); - registerParser(ScriptScoreFunctionParser.class); - registerParser(GaussDecayFunctionParser.class); - registerParser(LinearDecayFunctionParser.class); - registerParser(ExponentialDecayFunctionParser.class); - registerParser(RandomScoreFunctionParser.class); - registerParser(FieldValueFactorFunctionParser.class); - } - - public void registerParser(Class parser) { - parsers.add(parser); - } - - @Override - protected void configure() { - Multibinder parserMapBinder = Multibinder.newSetBinder(binder(), ScoreFunctionParser.class); - for (Class clazz : parsers) { - parserMapBinder.addBinding().to(clazz); - } - bind(ScoreFunctionParserMapper.class); - } -} diff --git a/core/src/main/java/org/elasticsearch/index/query/functionscore/ScoreFunctionParserMapper.java b/core/src/main/java/org/elasticsearch/index/query/functionscore/ScoreFunctionParserMapper.java index abe8b5c4e35..4fd5233889a 100644 --- a/core/src/main/java/org/elasticsearch/index/query/functionscore/ScoreFunctionParserMapper.java +++ b/core/src/main/java/org/elasticsearch/index/query/functionscore/ScoreFunctionParserMapper.java @@ -19,28 +19,42 @@ package org.elasticsearch.index.query.functionscore; -import com.google.common.collect.ImmutableMap; - -import org.elasticsearch.common.collect.MapBuilder; +import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.index.query.QueryParsingException; +import org.elasticsearch.index.query.functionscore.exp.ExponentialDecayFunctionParser; +import org.elasticsearch.index.query.functionscore.factor.FactorParser; +import org.elasticsearch.index.query.functionscore.fieldvaluefactor.FieldValueFactorFunctionParser; +import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionParser; +import org.elasticsearch.index.query.functionscore.lin.LinearDecayFunctionParser; +import org.elasticsearch.index.query.functionscore.random.RandomScoreFunctionParser; +import org.elasticsearch.index.query.functionscore.script.ScriptScoreFunctionParser; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.Set; public class ScoreFunctionParserMapper { - protected ImmutableMap functionParsers; + protected Map functionParsers; @Inject public ScoreFunctionParserMapper(Set parsers) { - MapBuilder builder = MapBuilder.newMapBuilder(); + Map map = new HashMap<>(); + // build-in parsers + addParser(new FactorParser(), map); + addParser(new ScriptScoreFunctionParser(), map); + addParser(new GaussDecayFunctionParser(), map); + addParser(new LinearDecayFunctionParser(), map); + addParser(new ExponentialDecayFunctionParser(), map); + addParser(new RandomScoreFunctionParser(), map); + addParser(new FieldValueFactorFunctionParser(), map); for (ScoreFunctionParser scoreFunctionParser : parsers) { - for (String name : scoreFunctionParser.getNames()) { - builder.put(name, scoreFunctionParser); - } + addParser(scoreFunctionParser, map); } - this.functionParsers = builder.immutableMap(); + this.functionParsers = Collections.unmodifiableMap(map); } public ScoreFunctionParser get(QueryParseContext parseContext, String parserName) { @@ -55,4 +69,10 @@ public class ScoreFunctionParserMapper { return functionParsers.get(parserName); } + private void addParser(ScoreFunctionParser scoreFunctionParser, Map map) { + for (String name : scoreFunctionParser.getNames()) { + map.put(name, scoreFunctionParser); + } + } + } diff --git a/core/src/main/java/org/elasticsearch/search/SearchModule.java b/core/src/main/java/org/elasticsearch/search/SearchModule.java index eb2f16cf0cf..b86ebb6c20f 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchModule.java +++ b/core/src/main/java/org/elasticsearch/search/SearchModule.java @@ -19,56 +19,370 @@ package org.elasticsearch.search; -import com.google.common.collect.ImmutableList; - +import com.google.common.collect.Lists; +import org.elasticsearch.common.Classes; import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.inject.SpawnModules; +import org.elasticsearch.common.inject.binder.LinkedBindingBuilder; +import org.elasticsearch.common.inject.multibindings.Multibinder; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.query.functionscore.FunctionScoreModule; +import org.elasticsearch.index.query.functionscore.ScoreFunctionParser; +import org.elasticsearch.index.query.functionscore.ScoreFunctionParserMapper; import org.elasticsearch.index.search.morelikethis.MoreLikeThisFetchService; import org.elasticsearch.search.action.SearchServiceTransportAction; -import org.elasticsearch.search.aggregations.AggregationModule; +import org.elasticsearch.search.aggregations.*; +import org.elasticsearch.search.aggregations.bucket.children.ChildrenParser; +import org.elasticsearch.search.aggregations.bucket.children.InternalChildren; +import org.elasticsearch.search.aggregations.bucket.filter.FilterParser; +import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; +import org.elasticsearch.search.aggregations.bucket.filters.FiltersParser; +import org.elasticsearch.search.aggregations.bucket.filters.InternalFilters; +import org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGridParser; +import org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoHashGrid; +import org.elasticsearch.search.aggregations.bucket.global.GlobalParser; +import org.elasticsearch.search.aggregations.bucket.global.InternalGlobal; +import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramParser; +import org.elasticsearch.search.aggregations.bucket.histogram.HistogramParser; +import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram; +import org.elasticsearch.search.aggregations.bucket.missing.InternalMissing; +import org.elasticsearch.search.aggregations.bucket.missing.MissingParser; +import org.elasticsearch.search.aggregations.bucket.nested.InternalNested; +import org.elasticsearch.search.aggregations.bucket.nested.InternalReverseNested; +import org.elasticsearch.search.aggregations.bucket.nested.NestedParser; +import org.elasticsearch.search.aggregations.bucket.nested.ReverseNestedParser; +import org.elasticsearch.search.aggregations.bucket.range.InternalRange; +import org.elasticsearch.search.aggregations.bucket.range.RangeParser; +import org.elasticsearch.search.aggregations.bucket.range.date.DateRangeParser; +import org.elasticsearch.search.aggregations.bucket.range.date.InternalDateRange; +import org.elasticsearch.search.aggregations.bucket.range.geodistance.GeoDistanceParser; +import org.elasticsearch.search.aggregations.bucket.range.geodistance.InternalGeoDistance; +import org.elasticsearch.search.aggregations.bucket.range.ipv4.InternalIPv4Range; +import org.elasticsearch.search.aggregations.bucket.range.ipv4.IpRangeParser; +import org.elasticsearch.search.aggregations.bucket.sampler.InternalSampler; +import org.elasticsearch.search.aggregations.bucket.sampler.SamplerParser; +import org.elasticsearch.search.aggregations.bucket.sampler.UnmappedSampler; +import org.elasticsearch.search.aggregations.bucket.significant.SignificantLongTerms; +import org.elasticsearch.search.aggregations.bucket.significant.SignificantStringTerms; +import org.elasticsearch.search.aggregations.bucket.significant.SignificantTermsParser; +import org.elasticsearch.search.aggregations.bucket.significant.UnmappedSignificantTerms; +import org.elasticsearch.search.aggregations.bucket.significant.heuristics.*; +import org.elasticsearch.search.aggregations.bucket.terms.*; +import org.elasticsearch.search.aggregations.metrics.avg.AvgParser; +import org.elasticsearch.search.aggregations.metrics.avg.InternalAvg; +import org.elasticsearch.search.aggregations.metrics.cardinality.CardinalityParser; +import org.elasticsearch.search.aggregations.metrics.cardinality.InternalCardinality; +import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBoundsParser; +import org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds; +import org.elasticsearch.search.aggregations.metrics.max.InternalMax; +import org.elasticsearch.search.aggregations.metrics.max.MaxParser; +import org.elasticsearch.search.aggregations.metrics.min.InternalMin; +import org.elasticsearch.search.aggregations.metrics.min.MinParser; +import org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanksParser; +import org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesParser; +import org.elasticsearch.search.aggregations.metrics.percentiles.hdr.InternalHDRPercentileRanks; +import org.elasticsearch.search.aggregations.metrics.percentiles.hdr.InternalHDRPercentiles; +import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.InternalTDigestPercentileRanks; +import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.InternalTDigestPercentiles; +import org.elasticsearch.search.aggregations.metrics.scripted.InternalScriptedMetric; +import org.elasticsearch.search.aggregations.metrics.scripted.ScriptedMetricParser; +import org.elasticsearch.search.aggregations.metrics.stats.InternalStats; +import org.elasticsearch.search.aggregations.metrics.stats.StatsParser; +import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStatsParser; +import org.elasticsearch.search.aggregations.metrics.stats.extended.InternalExtendedStats; +import org.elasticsearch.search.aggregations.metrics.sum.InternalSum; +import org.elasticsearch.search.aggregations.metrics.sum.SumParser; +import org.elasticsearch.search.aggregations.metrics.tophits.InternalTopHits; +import org.elasticsearch.search.aggregations.metrics.tophits.TopHitsParser; +import org.elasticsearch.search.aggregations.metrics.valuecount.InternalValueCount; +import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCountParser; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketParser; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketParser; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketParser; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketParser; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptParser; +import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumParser; +import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativeParser; +import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.derivative.InternalDerivative; +import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorParser; +import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgParser; +import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.*; +import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffParser; +import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffPipelineAggregator; import org.elasticsearch.search.controller.SearchPhaseController; import org.elasticsearch.search.dfs.DfsPhase; import org.elasticsearch.search.fetch.FetchPhase; -import org.elasticsearch.search.fetch.FetchSubPhaseModule; -import org.elasticsearch.search.highlight.HighlightModule; +import org.elasticsearch.search.fetch.FetchSubPhase; +import org.elasticsearch.search.fetch.explain.ExplainFetchSubPhase; +import org.elasticsearch.search.fetch.fielddata.FieldDataFieldsFetchSubPhase; +import org.elasticsearch.search.fetch.innerhits.InnerHitsFetchSubPhase; +import org.elasticsearch.search.fetch.matchedqueries.MatchedQueriesFetchSubPhase; +import org.elasticsearch.search.fetch.script.ScriptFieldsFetchSubPhase; +import org.elasticsearch.search.fetch.source.FetchSourceSubPhase; +import org.elasticsearch.search.fetch.version.VersionFetchSubPhase; +import org.elasticsearch.search.highlight.*; import org.elasticsearch.search.query.QueryPhase; -import org.elasticsearch.search.suggest.SuggestModule; +import org.elasticsearch.search.suggest.*; + +import java.util.List; /** * */ -public class SearchModule extends AbstractModule implements SpawnModules { +public class SearchModule extends AbstractModule { + + public static final String SEARCH_SERVICE_IMPL = "search.service_impl"; private final Settings settings; + private final List> aggParsers = Lists.newArrayList(); + private final List> pipelineAggParsers = Lists.newArrayList(); + private final List> highlighters = Lists.newArrayList(); + private final List> suggesters = Lists.newArrayList(); + private final List> functionScoreParsers = Lists.newArrayList(); + private final List> fetchSubPhases = Lists.newArrayList(); + private final List> heuristicParsers = Lists.newArrayList(); + private final List> modelParsers = Lists.newArrayList(); public SearchModule(Settings settings) { this.settings = settings; } - @Override - public Iterable spawnModules() { - return ImmutableList.of( - new SearchServiceModule(settings), - new TransportSearchModule(), - new HighlightModule(), - new SuggestModule(), - new FunctionScoreModule(), - new AggregationModule(), - new FetchSubPhaseModule()); + // TODO document public API + public void registerStream(SignificanceHeuristicStreams.Stream stream) { + SignificanceHeuristicStreams.registerStream(stream); } + public void registerStream(MovAvgModelStreams.Stream stream) { + MovAvgModelStreams.registerStream(stream); + } + + public void registerHighlighter(Class clazz) { + highlighters.add(clazz); + } + + public void registerSuggester(Class suggester) { + suggesters.add(suggester); + } + + public void registerFunctionScoreParser(Class parser) { + functionScoreParsers.add(parser); + } + + public void registerFetchSubPhase(Class subPhase) { + fetchSubPhases.add(subPhase); + } + + public void registerHeuristicParser(Class parser) { + heuristicParsers.add(parser); + } + + public void registerModelParser(Class parser) { + modelParsers.add(parser); + } + + /** + * Enabling extending the get module by adding a custom aggregation parser. + * + * @param parser The parser for the custom aggregator. + */ + public void registerAggregatorParser(Class parser) { + aggParsers.add(parser); + } + + public void registerPipelineParser(Class parser) { + pipelineAggParsers.add(parser); + } + + @Override protected void configure() { + // configure search private classes... bind(DfsPhase.class).asEagerSingleton(); bind(QueryPhase.class).asEagerSingleton(); bind(SearchPhaseController.class).asEagerSingleton(); - bind(FetchPhase.class).asEagerSingleton(); - bind(SearchServiceTransportAction.class).asEagerSingleton(); bind(MoreLikeThisFetchService.class).asEagerSingleton(); + + // search service -- testing only! + String impl = settings.get(SEARCH_SERVICE_IMPL); + if (impl == null) { + bind(SearchService.class).asEagerSingleton(); + } else { + Class implClass = Classes.loadClass(getClass().getClassLoader(), impl); + bind(SearchService.class).to(implClass).asEagerSingleton(); + } + + // aggs + Multibinder multibinderAggParser = Multibinder.newSetBinder(binder(), Aggregator.Parser.class); + multibinderAggParser.addBinding().to(AvgParser.class); + multibinderAggParser.addBinding().to(SumParser.class); + multibinderAggParser.addBinding().to(MinParser.class); + multibinderAggParser.addBinding().to(MaxParser.class); + multibinderAggParser.addBinding().to(StatsParser.class); + multibinderAggParser.addBinding().to(ExtendedStatsParser.class); + multibinderAggParser.addBinding().to(ValueCountParser.class); + multibinderAggParser.addBinding().to(PercentilesParser.class); + multibinderAggParser.addBinding().to(PercentileRanksParser.class); + multibinderAggParser.addBinding().to(CardinalityParser.class); + multibinderAggParser.addBinding().to(GlobalParser.class); + multibinderAggParser.addBinding().to(MissingParser.class); + multibinderAggParser.addBinding().to(FilterParser.class); + multibinderAggParser.addBinding().to(FiltersParser.class); + multibinderAggParser.addBinding().to(SamplerParser.class); + multibinderAggParser.addBinding().to(TermsParser.class); + multibinderAggParser.addBinding().to(SignificantTermsParser.class); + multibinderAggParser.addBinding().to(RangeParser.class); + multibinderAggParser.addBinding().to(DateRangeParser.class); + multibinderAggParser.addBinding().to(IpRangeParser.class); + multibinderAggParser.addBinding().to(HistogramParser.class); + multibinderAggParser.addBinding().to(DateHistogramParser.class); + multibinderAggParser.addBinding().to(GeoDistanceParser.class); + multibinderAggParser.addBinding().to(GeoHashGridParser.class); + multibinderAggParser.addBinding().to(NestedParser.class); + multibinderAggParser.addBinding().to(ReverseNestedParser.class); + multibinderAggParser.addBinding().to(TopHitsParser.class); + multibinderAggParser.addBinding().to(GeoBoundsParser.class); + multibinderAggParser.addBinding().to(ScriptedMetricParser.class); + multibinderAggParser.addBinding().to(ChildrenParser.class); + for (Class parser : aggParsers) { + multibinderAggParser.addBinding().to(parser); + } + + Multibinder multibinderPipelineAggParser = Multibinder.newSetBinder(binder(), PipelineAggregator.Parser.class); + multibinderPipelineAggParser.addBinding().to(DerivativeParser.class); + multibinderPipelineAggParser.addBinding().to(MaxBucketParser.class); + multibinderPipelineAggParser.addBinding().to(MinBucketParser.class); + multibinderPipelineAggParser.addBinding().to(AvgBucketParser.class); + multibinderPipelineAggParser.addBinding().to(SumBucketParser.class); + multibinderPipelineAggParser.addBinding().to(MovAvgParser.class); + multibinderPipelineAggParser.addBinding().to(CumulativeSumParser.class); + multibinderPipelineAggParser.addBinding().to(BucketScriptParser.class); + multibinderPipelineAggParser.addBinding().to(BucketSelectorParser.class); + multibinderPipelineAggParser.addBinding().to(SerialDiffParser.class); + for (Class parser : pipelineAggParsers) { + multibinderPipelineAggParser.addBinding().to(parser); + } + bind(AggregatorParsers.class).asEagerSingleton(); + bind(AggregationParseElement.class).asEagerSingleton(); + bind(AggregationPhase.class).asEagerSingleton(); + + Multibinder heuristicParserMultibinder = Multibinder.newSetBinder(binder(), SignificanceHeuristicParser.class); + for (Class clazz : heuristicParsers) { + heuristicParserMultibinder.addBinding().to(clazz); + } + bind(SignificanceHeuristicParserMapper.class); + + Multibinder modelParserMultibinder = Multibinder.newSetBinder(binder(), MovAvgModel.AbstractModelParser.class); + for (Class clazz : modelParsers) { + modelParserMultibinder.addBinding().to(clazz); + } + bind(MovAvgModelParserMapper.class); + + // highlighters + Multibinder multibinder = Multibinder.newSetBinder(binder(), Highlighter.class); + for (Class highlighter : highlighters) { + multibinder.addBinding().to(highlighter); + } + bind(Highlighters.class).asEagerSingleton(); + + // suggest + Multibinder suggesterMultibinder = Multibinder.newSetBinder(binder(), Suggester.class); + for (Class clazz : suggesters) { + suggesterMultibinder.addBinding().to(clazz); + } + + bind(SuggestParseElement.class).asEagerSingleton(); + bind(SuggestPhase.class).asEagerSingleton(); + bind(Suggesters.class).asEagerSingleton(); + + // function score + Multibinder parserMapBinder = Multibinder.newSetBinder(binder(), ScoreFunctionParser.class); + for (Class clazz : functionScoreParsers) { + parserMapBinder.addBinding().to(clazz); + } + bind(ScoreFunctionParserMapper.class); + + // fetch sub phase + Multibinder fetchSubPhaseMultibinder = Multibinder.newSetBinder(binder(), FetchSubPhase.class); + fetchSubPhaseMultibinder.addBinding().to(ExplainFetchSubPhase.class); + fetchSubPhaseMultibinder.addBinding().to(FieldDataFieldsFetchSubPhase.class); + fetchSubPhaseMultibinder.addBinding().to(ScriptFieldsFetchSubPhase.class); + fetchSubPhaseMultibinder.addBinding().to(FetchSourceSubPhase.class); + fetchSubPhaseMultibinder.addBinding().to(VersionFetchSubPhase.class); + fetchSubPhaseMultibinder.addBinding().to(MatchedQueriesFetchSubPhase.class); + fetchSubPhaseMultibinder.addBinding().to(HighlightPhase.class); + for (Class clazz : fetchSubPhases) { + fetchSubPhaseMultibinder.addBinding().to(clazz); + } + bind(InnerHitsFetchSubPhase.class).asEagerSingleton(); + } + + static { + // calcs + InternalAvg.registerStreams(); + InternalSum.registerStreams(); + InternalMin.registerStreams(); + InternalMax.registerStreams(); + InternalStats.registerStreams(); + InternalExtendedStats.registerStreams(); + InternalValueCount.registerStreams(); + InternalTDigestPercentiles.registerStreams(); + InternalTDigestPercentileRanks.registerStreams(); + InternalHDRPercentiles.registerStreams(); + InternalHDRPercentileRanks.registerStreams(); + InternalCardinality.registerStreams(); + InternalScriptedMetric.registerStreams(); + + // buckets + InternalGlobal.registerStreams(); + InternalFilter.registerStreams(); + InternalFilters.registerStream(); + InternalSampler.registerStreams(); + UnmappedSampler.registerStreams(); + InternalMissing.registerStreams(); + StringTerms.registerStreams(); + LongTerms.registerStreams(); + SignificantStringTerms.registerStreams(); + SignificantLongTerms.registerStreams(); + UnmappedSignificantTerms.registerStreams(); + InternalGeoHashGrid.registerStreams(); + DoubleTerms.registerStreams(); + UnmappedTerms.registerStreams(); + InternalRange.registerStream(); + InternalDateRange.registerStream(); + InternalIPv4Range.registerStream(); + InternalHistogram.registerStream(); + InternalGeoDistance.registerStream(); + InternalNested.registerStream(); + InternalReverseNested.registerStream(); + InternalTopHits.registerStreams(); + InternalGeoBounds.registerStream(); + InternalChildren.registerStream(); + + // Pipeline Aggregations + DerivativePipelineAggregator.registerStreams(); + InternalDerivative.registerStreams(); + InternalSimpleValue.registerStreams(); + InternalBucketMetricValue.registerStreams(); + MaxBucketPipelineAggregator.registerStreams(); + MinBucketPipelineAggregator.registerStreams(); + AvgBucketPipelineAggregator.registerStreams(); + SumBucketPipelineAggregator.registerStreams(); + MovAvgPipelineAggregator.registerStreams(); + CumulativeSumPipelineAggregator.registerStreams(); + BucketScriptPipelineAggregator.registerStreams(); + BucketSelectorPipelineAggregator.registerStreams(); + SerialDiffPipelineAggregator.registerStreams(); } } diff --git a/core/src/main/java/org/elasticsearch/search/SearchServiceModule.java b/core/src/main/java/org/elasticsearch/search/SearchServiceModule.java deleted file mode 100644 index be2d8796781..00000000000 --- a/core/src/main/java/org/elasticsearch/search/SearchServiceModule.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.search; - -import org.elasticsearch.common.Classes; -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.settings.Settings; - -public class SearchServiceModule extends AbstractModule { - - public static final String IMPL = "search.service_impl"; - - private final Settings settings; - - public SearchServiceModule(Settings settings) { - this.settings = settings; - } - - @Override - protected void configure() { - String impl = settings.get(IMPL); - if (impl == null) { - bind(SearchService.class).asEagerSingleton(); - } else { - Class implClass = Classes.loadClass(getClass().getClassLoader(), impl); - bind(SearchService.class).to(implClass).asEagerSingleton(); - } - } -} diff --git a/core/src/main/java/org/elasticsearch/search/TransportSearchModule.java b/core/src/main/java/org/elasticsearch/search/TransportSearchModule.java deleted file mode 100644 index e6b134e655a..00000000000 --- a/core/src/main/java/org/elasticsearch/search/TransportSearchModule.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.search; - -import com.google.common.collect.ImmutableList; -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.inject.SpawnModules; -import org.elasticsearch.search.aggregations.TransportAggregationModule; - -/** - * - */ -public class TransportSearchModule extends AbstractModule implements SpawnModules { - - @Override - public Iterable spawnModules() { - return ImmutableList.of(new TransportAggregationModule()); - } - - @Override - protected void configure() { - - } -} diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java deleted file mode 100644 index 6f9281d1015..00000000000 --- a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.search.aggregations; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.inject.SpawnModules; -import org.elasticsearch.common.inject.multibindings.Multibinder; -import org.elasticsearch.search.aggregations.bucket.children.ChildrenParser; -import org.elasticsearch.search.aggregations.bucket.filter.FilterParser; -import org.elasticsearch.search.aggregations.bucket.filters.FiltersParser; -import org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGridParser; -import org.elasticsearch.search.aggregations.bucket.global.GlobalParser; -import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramParser; -import org.elasticsearch.search.aggregations.bucket.histogram.HistogramParser; -import org.elasticsearch.search.aggregations.bucket.missing.MissingParser; -import org.elasticsearch.search.aggregations.bucket.nested.NestedParser; -import org.elasticsearch.search.aggregations.bucket.nested.ReverseNestedParser; -import org.elasticsearch.search.aggregations.bucket.range.RangeParser; -import org.elasticsearch.search.aggregations.bucket.range.date.DateRangeParser; -import org.elasticsearch.search.aggregations.bucket.range.geodistance.GeoDistanceParser; -import org.elasticsearch.search.aggregations.bucket.range.ipv4.IpRangeParser; -import org.elasticsearch.search.aggregations.bucket.sampler.SamplerParser; -import org.elasticsearch.search.aggregations.bucket.significant.SignificantTermsParser; -import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificantTermsHeuristicModule; -import org.elasticsearch.search.aggregations.bucket.terms.TermsParser; -import org.elasticsearch.search.aggregations.metrics.avg.AvgParser; -import org.elasticsearch.search.aggregations.metrics.cardinality.CardinalityParser; -import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBoundsParser; -import org.elasticsearch.search.aggregations.metrics.max.MaxParser; -import org.elasticsearch.search.aggregations.metrics.min.MinParser; -import org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanksParser; -import org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesParser; -import org.elasticsearch.search.aggregations.metrics.scripted.ScriptedMetricParser; -import org.elasticsearch.search.aggregations.metrics.stats.StatsParser; -import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStatsParser; -import org.elasticsearch.search.aggregations.metrics.sum.SumParser; -import org.elasticsearch.search.aggregations.metrics.tophits.TopHitsParser; -import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCountParser; -import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketParser; -import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketParser; -import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketParser; -import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketParser; -import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumParser; -import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptParser; -import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativeParser; -import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorParser; -import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgParser; -import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelModule; -import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffParser; - -import java.util.List; - -/** - * The main module for the get (binding all get components together) - */ -public class AggregationModule extends AbstractModule implements SpawnModules { - - private List> aggParsers = Lists.newArrayList(); - private List> pipelineAggParsers = Lists.newArrayList(); - - public AggregationModule() { - aggParsers.add(AvgParser.class); - aggParsers.add(SumParser.class); - aggParsers.add(MinParser.class); - aggParsers.add(MaxParser.class); - aggParsers.add(StatsParser.class); - aggParsers.add(ExtendedStatsParser.class); - aggParsers.add(ValueCountParser.class); - aggParsers.add(PercentilesParser.class); - aggParsers.add(PercentileRanksParser.class); - aggParsers.add(CardinalityParser.class); - - aggParsers.add(GlobalParser.class); - aggParsers.add(MissingParser.class); - aggParsers.add(FilterParser.class); - aggParsers.add(FiltersParser.class); - aggParsers.add(SamplerParser.class); - aggParsers.add(TermsParser.class); - aggParsers.add(SignificantTermsParser.class); - aggParsers.add(RangeParser.class); - aggParsers.add(DateRangeParser.class); - aggParsers.add(IpRangeParser.class); - aggParsers.add(HistogramParser.class); - aggParsers.add(DateHistogramParser.class); - aggParsers.add(GeoDistanceParser.class); - aggParsers.add(GeoHashGridParser.class); - aggParsers.add(NestedParser.class); - aggParsers.add(ReverseNestedParser.class); - aggParsers.add(TopHitsParser.class); - aggParsers.add(GeoBoundsParser.class); - aggParsers.add(ScriptedMetricParser.class); - aggParsers.add(ChildrenParser.class); - - pipelineAggParsers.add(DerivativeParser.class); - pipelineAggParsers.add(MaxBucketParser.class); - pipelineAggParsers.add(MinBucketParser.class); - pipelineAggParsers.add(AvgBucketParser.class); - pipelineAggParsers.add(SumBucketParser.class); - pipelineAggParsers.add(MovAvgParser.class); - pipelineAggParsers.add(CumulativeSumParser.class); - pipelineAggParsers.add(BucketScriptParser.class); - pipelineAggParsers.add(BucketSelectorParser.class); - pipelineAggParsers.add(SerialDiffParser.class); - } - - /** - * Enabling extending the get module by adding a custom aggregation parser. - * - * @param parser The parser for the custom aggregator. - */ - public void addAggregatorParser(Class parser) { - aggParsers.add(parser); - } - - @Override - protected void configure() { - Multibinder multibinderAggParser = Multibinder.newSetBinder(binder(), Aggregator.Parser.class); - for (Class parser : aggParsers) { - multibinderAggParser.addBinding().to(parser); - } - Multibinder multibinderPipelineAggParser = Multibinder.newSetBinder(binder(), PipelineAggregator.Parser.class); - for (Class parser : pipelineAggParsers) { - multibinderPipelineAggParser.addBinding().to(parser); - } - bind(AggregatorParsers.class).asEagerSingleton(); - bind(AggregationParseElement.class).asEagerSingleton(); - bind(AggregationPhase.class).asEagerSingleton(); - } - - @Override - public Iterable spawnModules() { - return ImmutableList.of(new SignificantTermsHeuristicModule(), new MovAvgModelModule()); - } - -} diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/AggregatorParsers.java b/core/src/main/java/org/elasticsearch/search/aggregations/AggregatorParsers.java index 105f46187de..bba7be2ad1f 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/AggregatorParsers.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/AggregatorParsers.java @@ -50,7 +50,7 @@ public class AggregatorParsers { * * @param aggParsers * The available aggregator parsers (dynamically injected by the - * {@link org.elasticsearch.search.aggregations.AggregationModule} + * {@link org.elasticsearch.search.SearchModule} * ). */ @Inject diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java b/core/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java deleted file mode 100644 index 00d2aac533b..00000000000 --- a/core/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.search.aggregations; - -import com.google.common.collect.ImmutableList; - -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.inject.SpawnModules; -import org.elasticsearch.search.aggregations.bucket.children.InternalChildren; -import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; -import org.elasticsearch.search.aggregations.bucket.filters.InternalFilters; -import org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoHashGrid; -import org.elasticsearch.search.aggregations.bucket.global.InternalGlobal; -import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram; -import org.elasticsearch.search.aggregations.bucket.missing.InternalMissing; -import org.elasticsearch.search.aggregations.bucket.nested.InternalNested; -import org.elasticsearch.search.aggregations.bucket.nested.InternalReverseNested; -import org.elasticsearch.search.aggregations.bucket.range.InternalRange; -import org.elasticsearch.search.aggregations.bucket.range.date.InternalDateRange; -import org.elasticsearch.search.aggregations.bucket.range.geodistance.InternalGeoDistance; -import org.elasticsearch.search.aggregations.bucket.range.ipv4.InternalIPv4Range; -import org.elasticsearch.search.aggregations.bucket.sampler.InternalSampler; -import org.elasticsearch.search.aggregations.bucket.sampler.UnmappedSampler; -import org.elasticsearch.search.aggregations.bucket.significant.SignificantLongTerms; -import org.elasticsearch.search.aggregations.bucket.significant.SignificantStringTerms; -import org.elasticsearch.search.aggregations.bucket.significant.UnmappedSignificantTerms; -import org.elasticsearch.search.aggregations.bucket.significant.heuristics.TransportSignificantTermsHeuristicModule; -import org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms; -import org.elasticsearch.search.aggregations.bucket.terms.LongTerms; -import org.elasticsearch.search.aggregations.bucket.terms.StringTerms; -import org.elasticsearch.search.aggregations.bucket.terms.UnmappedTerms; -import org.elasticsearch.search.aggregations.metrics.avg.InternalAvg; -import org.elasticsearch.search.aggregations.metrics.cardinality.InternalCardinality; -import org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds; -import org.elasticsearch.search.aggregations.metrics.max.InternalMax; -import org.elasticsearch.search.aggregations.metrics.min.InternalMin; -import org.elasticsearch.search.aggregations.metrics.percentiles.hdr.InternalHDRPercentileRanks; -import org.elasticsearch.search.aggregations.metrics.percentiles.hdr.InternalHDRPercentiles; -import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.InternalTDigestPercentileRanks; -import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.InternalTDigestPercentiles; -import org.elasticsearch.search.aggregations.metrics.scripted.InternalScriptedMetric; -import org.elasticsearch.search.aggregations.metrics.stats.InternalStats; -import org.elasticsearch.search.aggregations.metrics.stats.extended.InternalExtendedStats; -import org.elasticsearch.search.aggregations.metrics.sum.InternalSum; -import org.elasticsearch.search.aggregations.metrics.tophits.InternalTopHits; -import org.elasticsearch.search.aggregations.metrics.valuecount.InternalValueCount; -import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; -import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue; -import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketPipelineAggregator; -import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator; -import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregator; -import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregator; -import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptPipelineAggregator; -import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumPipelineAggregator; -import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator; -import org.elasticsearch.search.aggregations.pipeline.derivative.InternalDerivative; -import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorPipelineAggregator; -import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregator; -import org.elasticsearch.search.aggregations.pipeline.movavg.models.TransportMovAvgModelModule; -import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffPipelineAggregator; - -/** - * A module that registers all the transport streams for the addAggregation - */ -public class TransportAggregationModule extends AbstractModule implements SpawnModules { - - @Override - protected void configure() { - - // calcs - InternalAvg.registerStreams(); - InternalSum.registerStreams(); - InternalMin.registerStreams(); - InternalMax.registerStreams(); - InternalStats.registerStreams(); - InternalExtendedStats.registerStreams(); - InternalValueCount.registerStreams(); - InternalTDigestPercentiles.registerStreams(); - InternalTDigestPercentileRanks.registerStreams(); - InternalHDRPercentiles.registerStreams(); - InternalHDRPercentileRanks.registerStreams(); - InternalCardinality.registerStreams(); - InternalScriptedMetric.registerStreams(); - - // buckets - InternalGlobal.registerStreams(); - InternalFilter.registerStreams(); - InternalFilters.registerStream(); - InternalSampler.registerStreams(); - UnmappedSampler.registerStreams(); - InternalMissing.registerStreams(); - StringTerms.registerStreams(); - LongTerms.registerStreams(); - SignificantStringTerms.registerStreams(); - SignificantLongTerms.registerStreams(); - UnmappedSignificantTerms.registerStreams(); - InternalGeoHashGrid.registerStreams(); - DoubleTerms.registerStreams(); - UnmappedTerms.registerStreams(); - InternalRange.registerStream(); - InternalDateRange.registerStream(); - InternalIPv4Range.registerStream(); - InternalHistogram.registerStream(); - InternalGeoDistance.registerStream(); - InternalNested.registerStream(); - InternalReverseNested.registerStream(); - InternalTopHits.registerStreams(); - InternalGeoBounds.registerStream(); - InternalChildren.registerStream(); - - // Pipeline Aggregations - DerivativePipelineAggregator.registerStreams(); - InternalDerivative.registerStreams(); - InternalSimpleValue.registerStreams(); - InternalBucketMetricValue.registerStreams(); - MaxBucketPipelineAggregator.registerStreams(); - MinBucketPipelineAggregator.registerStreams(); - AvgBucketPipelineAggregator.registerStreams(); - SumBucketPipelineAggregator.registerStreams(); - MovAvgPipelineAggregator.registerStreams(); - CumulativeSumPipelineAggregator.registerStreams(); - BucketScriptPipelineAggregator.registerStreams(); - BucketSelectorPipelineAggregator.registerStreams(); - SerialDiffPipelineAggregator.registerStreams(); - } - - @Override - public Iterable spawnModules() { - return ImmutableList.of(new TransportSignificantTermsHeuristicModule(), new TransportMovAvgModelModule()); - } -} diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/ScriptHeuristic.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/ScriptHeuristic.java index 59acd2dcd8b..1be9df21a58 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/ScriptHeuristic.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/ScriptHeuristic.java @@ -124,7 +124,6 @@ public class ScriptHeuristic extends SignificanceHeuristic { public static class ScriptHeuristicParser implements SignificanceHeuristicParser { private final ScriptService scriptService; - @Inject public ScriptHeuristicParser(ScriptService scriptService) { this.scriptService = scriptService; } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificanceHeuristicParserMapper.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificanceHeuristicParserMapper.java index 140b1b3f06d..07e74ec6f91 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificanceHeuristicParserMapper.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificanceHeuristicParserMapper.java @@ -20,28 +20,41 @@ package org.elasticsearch.search.aggregations.bucket.significant.heuristics; -import com.google.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.script.ScriptService; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.Set; public class SignificanceHeuristicParserMapper { - protected ImmutableMap significanceHeuristicParsers; + protected final Map significanceHeuristicParsers; @Inject - public SignificanceHeuristicParserMapper(Set parsers) { - MapBuilder builder = MapBuilder.newMapBuilder(); + public SignificanceHeuristicParserMapper(Set parsers, ScriptService scriptService) { + Map map = new HashMap<>(); + add(map, new JLHScore.JLHScoreParser()); + add(map, new PercentageScore.PercentageScoreParser()); + add(map, new MutualInformation.MutualInformationParser()); + add(map, new ChiSquare.ChiSquareParser()); + add(map, new GND.GNDParser()); + add(map, new ScriptHeuristic.ScriptHeuristicParser(scriptService)); for (SignificanceHeuristicParser parser : parsers) { - for (String name : parser.getNames()) { - builder.put(name, parser); - } + add(map, parser); } - significanceHeuristicParsers = builder.immutableMap(); + significanceHeuristicParsers = Collections.unmodifiableMap(map); } public SignificanceHeuristicParser get(String parserName) { return significanceHeuristicParsers.get(parserName); } + + + private void add(Map map, SignificanceHeuristicParser parser) { + for (String type : parser.getNames()) { + map.put(type, parser); + } + } } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificanceHeuristicStreams.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificanceHeuristicStreams.java index e6c088b3f4d..51dd11c5e87 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificanceHeuristicStreams.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificanceHeuristicStreams.java @@ -18,12 +18,12 @@ */ package org.elasticsearch.search.aggregations.bucket.significant.heuristics; -import com.google.common.collect.ImmutableMap; -import org.elasticsearch.Version; -import org.elasticsearch.common.collect.MapBuilder; +import org.elasticsearch.common.collect.CopyOnWriteHashMap; import org.elasticsearch.common.io.stream.StreamInput; - import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; /** * A registry for all significance heuristics. This is needed for reading them from a stream without knowing which @@ -31,7 +31,18 @@ import java.io.IOException; */ public class SignificanceHeuristicStreams { - private static ImmutableMap STREAMS = ImmutableMap.of(); + private static Map STREAMS = Collections.EMPTY_MAP; + + static { + HashMap map = new HashMap<>(); + map.put(JLHScore.STREAM.getName(), JLHScore.STREAM); + map.put(PercentageScore.STREAM.getName(), PercentageScore.STREAM); + map.put(MutualInformation.STREAM.getName(), MutualInformation.STREAM); + map.put(GND.STREAM.getName(), GND.STREAM); + map.put(ChiSquare.STREAM.getName(), ChiSquare.STREAM); + map.put(ScriptHeuristic.STREAM.getName(), ScriptHeuristic.STREAM); + STREAMS = Collections.unmodifiableMap(map); + } public static SignificanceHeuristic read(StreamInput in) throws IOException { return stream(in.readString()).readResult(in); @@ -51,14 +62,12 @@ public class SignificanceHeuristicStreams { * Registers the given stream and associate it with the given types. * * @param stream The stream to register - * @param names The names associated with the streams */ - public static synchronized void registerStream(Stream stream, String... names) { - MapBuilder uStreams = MapBuilder.newMapBuilder(STREAMS); - for (String name : names) { - uStreams.put(name, stream); - } - STREAMS = uStreams.immutableMap(); + public static synchronized void registerStream(Stream stream) { + HashMap map = new HashMap<>(); + map.putAll(STREAMS); + map.put(stream.getName(), stream); + STREAMS = Collections.unmodifiableMap(map); } /** @@ -67,7 +76,7 @@ public class SignificanceHeuristicStreams { * @param name The given name * @return The associated stream */ - public static Stream stream(String name) { + public static synchronized Stream stream(String name) { return STREAMS.get(name); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificantTermsHeuristicModule.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificantTermsHeuristicModule.java deleted file mode 100644 index 45143d73016..00000000000 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/SignificantTermsHeuristicModule.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package org.elasticsearch.search.aggregations.bucket.significant.heuristics; - -import com.google.common.collect.Lists; - -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.multibindings.Multibinder; - -import java.util.List; - - -public class SignificantTermsHeuristicModule extends AbstractModule { - - private List> parsers = Lists.newArrayList(); - - public SignificantTermsHeuristicModule() { - - registerParser(JLHScore.JLHScoreParser.class); - registerParser(PercentageScore.PercentageScoreParser.class); - registerParser(MutualInformation.MutualInformationParser.class); - registerParser(GND.GNDParser.class); - registerParser(ChiSquare.ChiSquareParser.class); - registerParser(ScriptHeuristic.ScriptHeuristicParser.class); - } - - public void registerParser(Class parser) { - parsers.add(parser); - } - - @Override - protected void configure() { - Multibinder parserMapBinder = Multibinder.newSetBinder(binder(), SignificanceHeuristicParser.class); - for (Class clazz : parsers) { - parserMapBinder.addBinding().to(clazz); - } - bind(SignificanceHeuristicParserMapper.class); - } -} diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/TransportSignificantTermsHeuristicModule.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/TransportSignificantTermsHeuristicModule.java deleted file mode 100644 index 1be51f51d66..00000000000 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/TransportSignificantTermsHeuristicModule.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package org.elasticsearch.search.aggregations.bucket.significant.heuristics; - -import com.google.common.collect.Lists; - -import org.elasticsearch.common.inject.AbstractModule; - -import java.util.List; - - -public class TransportSignificantTermsHeuristicModule extends AbstractModule { - - private List streams = Lists.newArrayList(); - - public TransportSignificantTermsHeuristicModule() { - registerStream(JLHScore.STREAM); - registerStream(PercentageScore.STREAM); - registerStream(MutualInformation.STREAM); - registerStream(GND.STREAM); - registerStream(ChiSquare.STREAM); - registerStream(ScriptHeuristic.STREAM); - } - - public void registerStream(SignificanceHeuristicStreams.Stream stream) { - streams.add(stream); - } - - @Override - protected void configure() { - for (SignificanceHeuristicStreams.Stream stream : streams) { - SignificanceHeuristicStreams.registerStream(stream, stream.getName()); - } - } -} diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelModule.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelModule.java deleted file mode 100644 index 6233270edf7..00000000000 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelModule.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package org.elasticsearch.search.aggregations.pipeline.movavg.models; - -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.multibindings.Multibinder; - -import java.util.List; - -/** - * Register the various model parsers - */ -public class MovAvgModelModule extends AbstractModule { - - private List> parsers = Lists.newArrayList(); - - public MovAvgModelModule() { - registerParser(SimpleModel.SimpleModelParser.class); - registerParser(LinearModel.LinearModelParser.class); - registerParser(EwmaModel.SingleExpModelParser.class); - registerParser(HoltLinearModel.DoubleExpModelParser.class); - registerParser(HoltWintersModel.HoltWintersModelParser.class); - } - - public void registerParser(Class parser) { - parsers.add(parser); - } - - @Override - protected void configure() { - Multibinder parserMapBinder = Multibinder.newSetBinder(binder(), MovAvgModel.AbstractModelParser.class); - for (Class clazz : parsers) { - parserMapBinder.addBinding().to(clazz); - } - bind(MovAvgModelParserMapper.class); - } -} diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelParserMapper.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelParserMapper.java index bfd0c15c1c0..6a8c5eaaf57 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelParserMapper.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelParserMapper.java @@ -19,12 +19,12 @@ package org.elasticsearch.search.aggregations.pipeline.movavg.models; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.Set; /** @@ -32,15 +32,20 @@ import java.util.Set; */ public class MovAvgModelParserMapper { - protected ImmutableMap movAvgParsers; + protected Map movAvgParsers; @Inject public MovAvgModelParserMapper(Set parsers) { - MapBuilder builder = MapBuilder.newMapBuilder(); + Map map = new HashMap<>(); + add(map, new SimpleModel.SimpleModelParser()); + add(map, new LinearModel.LinearModelParser()); + add(map, new EwmaModel.SingleExpModelParser()); + add(map, new HoltLinearModel.DoubleExpModelParser()); + add(map, new HoltWintersModel.HoltWintersModelParser()); for (MovAvgModel.AbstractModelParser parser : parsers) { - builder.put(parser.getName(), parser); + add(map, parser); } - movAvgParsers = builder.immutableMap(); + movAvgParsers = Collections.unmodifiableMap(map); } public @Nullable @@ -48,7 +53,11 @@ public class MovAvgModelParserMapper { return movAvgParsers.get(parserName); } - public ImmutableSet getAllNames() { + public Set getAllNames() { return movAvgParsers.keySet(); } + + private void add(Map map, MovAvgModel.AbstractModelParser parser) { + map.put(parser.getName(), parser); + } } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelStreams.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelStreams.java index 0985612eacd..d12b0cdfef4 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelStreams.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelStreams.java @@ -19,11 +19,12 @@ package org.elasticsearch.search.aggregations.pipeline.movavg.models; -import com.google.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.io.stream.StreamInput; import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; /** * A registry for all moving average models. This is needed for reading them from a stream without knowing which @@ -31,7 +32,17 @@ import java.io.IOException; */ public class MovAvgModelStreams { - private static ImmutableMap STREAMS = ImmutableMap.of(); + private static Map STREAMS = Collections.EMPTY_MAP; + + static { + HashMap map = new HashMap<>(); + map.put(SimpleModel.STREAM.getName(), SimpleModel.STREAM); + map.put(LinearModel.STREAM.getName(), LinearModel.STREAM); + map.put(EwmaModel.STREAM.getName(), EwmaModel.STREAM); + map.put(HoltLinearModel.STREAM.getName(), HoltLinearModel.STREAM); + map.put(HoltWintersModel.STREAM.getName(), HoltWintersModel.STREAM); + STREAMS = Collections.unmodifiableMap(map); + } public static MovAvgModel read(StreamInput in) throws IOException { return stream(in.readString()).readResult(in); @@ -40,7 +51,7 @@ public class MovAvgModelStreams { /** * A stream that knows how to read an heuristic from the input. */ - public static interface Stream { + public interface Stream { MovAvgModel readResult(StreamInput in) throws IOException; @@ -51,14 +62,12 @@ public class MovAvgModelStreams { * Registers the given stream and associate it with the given types. * * @param stream The stream to register - * @param names The names associated with the streams */ - public static synchronized void registerStream(Stream stream, String... names) { - MapBuilder uStreams = MapBuilder.newMapBuilder(STREAMS); - for (String name : names) { - uStreams.put(name, stream); - } - STREAMS = uStreams.immutableMap(); + public static synchronized void registerStream(Stream stream) { + HashMap map = new HashMap<>(); + map.putAll(STREAMS); + map.put(stream.getName(), stream); + STREAMS = Collections.unmodifiableMap(map); } /** @@ -67,7 +76,7 @@ public class MovAvgModelStreams { * @param name The given name * @return The associated stream */ - public static Stream stream(String name) { + public static synchronized Stream stream(String name) { return STREAMS.get(name); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/TransportMovAvgModelModule.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/TransportMovAvgModelModule.java deleted file mode 100644 index 7f5dd14005c..00000000000 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/TransportMovAvgModelModule.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.search.aggregations.pipeline.movavg.models; - -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.AbstractModule; - -import java.util.List; - -/** - * Register the transport streams so that models can be serialized/deserialized from the stream - */ -public class TransportMovAvgModelModule extends AbstractModule { - - private List streams = Lists.newArrayList(); - - public TransportMovAvgModelModule() { - registerStream(SimpleModel.STREAM); - registerStream(LinearModel.STREAM); - registerStream(EwmaModel.STREAM); - registerStream(HoltLinearModel.STREAM); - registerStream(HoltWintersModel.STREAM); - } - - public void registerStream(MovAvgModelStreams.Stream stream) { - streams.add(stream); - } - - @Override - protected void configure() { - for (MovAvgModelStreams.Stream stream : streams) { - MovAvgModelStreams.registerStream(stream, stream.getName()); - } - } -} diff --git a/core/src/main/java/org/elasticsearch/search/fetch/FetchSubPhaseModule.java b/core/src/main/java/org/elasticsearch/search/fetch/FetchSubPhaseModule.java deleted file mode 100644 index e01de72b232..00000000000 --- a/core/src/main/java/org/elasticsearch/search/fetch/FetchSubPhaseModule.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.search.fetch; - -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.multibindings.Multibinder; -import org.elasticsearch.search.fetch.explain.ExplainFetchSubPhase; -import org.elasticsearch.search.fetch.fielddata.FieldDataFieldsFetchSubPhase; -import org.elasticsearch.search.fetch.innerhits.InnerHitsFetchSubPhase; -import org.elasticsearch.search.fetch.matchedqueries.MatchedQueriesFetchSubPhase; -import org.elasticsearch.search.fetch.script.ScriptFieldsFetchSubPhase; -import org.elasticsearch.search.fetch.source.FetchSourceSubPhase; -import org.elasticsearch.search.fetch.version.VersionFetchSubPhase; -import org.elasticsearch.search.highlight.HighlightPhase; - -import java.util.List; - -/** - * Module for registering fetch sub phases. Fetch phases are executed when the document is finally - * retrieved from the shard. To implement a new fetch phase one needs to implement the following classes and interfaces - *

- *

    - *
  • {@link FetchSubPhaseParseElement}
  • - *
  • {@link FetchSubPhase}
  • - *
  • {@link FetchSubPhaseContext}
  • - *
- *

- * The FetchSubPhase must then be registered with this module with {@link FetchSubPhaseModule#registerFetchSubPhase(Class)}. - * See {@link FieldDataFieldsFetchSubPhase} for an example. - */ -public class FetchSubPhaseModule extends AbstractModule { - - private List> fetchSubPhases = Lists.newArrayList(); - - public FetchSubPhaseModule() { - registerFetchSubPhase(ExplainFetchSubPhase.class); - registerFetchSubPhase(FieldDataFieldsFetchSubPhase.class); - registerFetchSubPhase(ScriptFieldsFetchSubPhase.class); - registerFetchSubPhase(FetchSourceSubPhase.class); - registerFetchSubPhase(VersionFetchSubPhase.class); - registerFetchSubPhase(MatchedQueriesFetchSubPhase.class); - registerFetchSubPhase(HighlightPhase.class); - } - - public void registerFetchSubPhase(Class subPhase) { - fetchSubPhases.add(subPhase); - } - - @Override - protected void configure() { - Multibinder parserMapBinder = Multibinder.newSetBinder(binder(), FetchSubPhase.class); - for (Class clazz : fetchSubPhases) { - parserMapBinder.addBinding().to(clazz); - } - bind(InnerHitsFetchSubPhase.class).asEagerSingleton(); - } -} diff --git a/core/src/main/java/org/elasticsearch/search/highlight/FastVectorHighlighter.java b/core/src/main/java/org/elasticsearch/search/highlight/FastVectorHighlighter.java index 55ee8f9c21e..67b42a5d866 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/FastVectorHighlighter.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/FastVectorHighlighter.java @@ -22,7 +22,6 @@ import com.google.common.collect.Maps; import org.apache.lucene.search.highlight.Encoder; import org.apache.lucene.search.vectorhighlight.*; import org.apache.lucene.search.vectorhighlight.FieldPhraseList.WeightedPhraseInfo; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.text.StringText; import org.elasticsearch.index.mapper.FieldMapper; @@ -46,7 +45,6 @@ public class FastVectorHighlighter implements Highlighter { private static final String CACHE_KEY = "highlight-fsv"; private final Boolean termVectorMultiValue; - @Inject public FastVectorHighlighter(Settings settings) { this.termVectorMultiValue = settings.getAsBoolean("search.highlight.term_vector_multi_value", true); } diff --git a/core/src/main/java/org/elasticsearch/search/highlight/HighlightModule.java b/core/src/main/java/org/elasticsearch/search/highlight/HighlightModule.java deleted file mode 100644 index 7772fe141aa..00000000000 --- a/core/src/main/java/org/elasticsearch/search/highlight/HighlightModule.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.search.highlight; - -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.multibindings.Multibinder; - -import java.util.List; - -/** - * - */ -public class HighlightModule extends AbstractModule { - - private List> highlighters = Lists.newArrayList(); - - public HighlightModule() { - registerHighlighter(FastVectorHighlighter.class); - registerHighlighter(PlainHighlighter.class); - registerHighlighter(PostingsHighlighter.class); - } - - public void registerHighlighter(Class clazz) { - highlighters.add(clazz); - } - - @Override - protected void configure() { - Multibinder multibinder = Multibinder.newSetBinder(binder(), Highlighter.class); - for (Class highlighter : highlighters) { - multibinder.addBinding().to(highlighter); - } - bind(Highlighters.class).asEagerSingleton(); - } -} diff --git a/core/src/main/java/org/elasticsearch/search/highlight/Highlighters.java b/core/src/main/java/org/elasticsearch/search/highlight/Highlighters.java index 34e165d976e..9f14b0f7ed1 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/Highlighters.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/Highlighters.java @@ -21,28 +21,41 @@ package org.elasticsearch.search.highlight; import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.Settings; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.Set; /** * */ public class Highlighters { - private final ImmutableMap parsers; + + private final Map parsers; @Inject - public Highlighters(Set parsers) { - MapBuilder builder = MapBuilder.newMapBuilder(); - for (Highlighter parser : parsers) { - for (String type : parser.names()) { - builder.put(type, parser); - } + public Highlighters(Settings settings, Set parsers) { + // build in highlighers + Map map = new HashMap<>(); + add(map, new FastVectorHighlighter(settings)); + add(map, new PlainHighlighter()); + add(map, new PostingsHighlighter()); + for (Highlighter highlighter : parsers) { + add(map, highlighter); } - this.parsers = builder.immutableMap(); + this.parsers = Collections.unmodifiableMap(map); } public Highlighter get(String type) { return parsers.get(type); } + private void add(Map map, Highlighter highlighter) { + for (String type : highlighter.names()) { + map.put(type, highlighter); + } + } + } diff --git a/core/src/main/java/org/elasticsearch/search/suggest/SuggestModule.java b/core/src/main/java/org/elasticsearch/search/suggest/SuggestModule.java deleted file mode 100644 index c01ab3a7afa..00000000000 --- a/core/src/main/java/org/elasticsearch/search/suggest/SuggestModule.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.search.suggest; - -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.multibindings.Multibinder; -import org.elasticsearch.search.suggest.completion.CompletionSuggester; -import org.elasticsearch.search.suggest.phrase.PhraseSuggester; -import org.elasticsearch.search.suggest.term.TermSuggester; - -import java.util.List; - -/** - * - */ -public class SuggestModule extends AbstractModule { - - private List> suggesters = Lists.newArrayList(); - - public SuggestModule() { - registerSuggester(PhraseSuggester.class); - registerSuggester(TermSuggester.class); - registerSuggester(CompletionSuggester.class); - } - - public void registerSuggester(Class suggester) { - suggesters.add(suggester); - } - - @Override - protected void configure() { - Multibinder suggesterMultibinder = Multibinder.newSetBinder(binder(), Suggester.class); - for (Class clazz : suggesters) { - suggesterMultibinder.addBinding().to(clazz); - } - - bind(SuggestParseElement.class).asEagerSingleton(); - bind(SuggestPhase.class).asEagerSingleton(); - bind(Suggesters.class).asEagerSingleton(); - } -} diff --git a/core/src/main/java/org/elasticsearch/search/suggest/Suggesters.java b/core/src/main/java/org/elasticsearch/search/suggest/Suggesters.java index 356bf206a62..264720b8b90 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/Suggesters.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/Suggesters.java @@ -21,28 +21,42 @@ package org.elasticsearch.search.suggest; import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.script.ScriptService; +import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicParser; +import org.elasticsearch.search.suggest.completion.CompletionSuggester; +import org.elasticsearch.search.suggest.phrase.PhraseSuggester; +import org.elasticsearch.search.suggest.term.TermSuggester; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.Set; /** * */ public class Suggesters { - private final ImmutableMap parsers; + private final Map parsers; @Inject - public Suggesters(Set suggesters) { - MapBuilder builder = MapBuilder.newMapBuilder(); + public Suggesters(Set suggesters, ScriptService scriptService) { + final Map map = new HashMap<>(); + add(map, new PhraseSuggester(scriptService)); + add(map, new TermSuggester()); + add(map, new CompletionSuggester()); for (Suggester suggester : suggesters) { - for (String type : suggester.names()) { - builder.put(type, suggester); - } + add(map, suggester); } - this.parsers = builder.immutableMap(); + this.parsers = Collections.unmodifiableMap(map); } public Suggester get(String type) { return parsers.get(type); } + private void add(Map map, Suggester suggester) { + for (String type : suggester.names()) { + map.put(type, suggester); + } + } } diff --git a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java index cee5bd70ad9..aab3c6fe1c4 100644 --- a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java +++ b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java @@ -26,6 +26,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; +import org.elasticsearch.common.inject.multibindings.Multibinder; import org.elasticsearch.common.inject.util.Providers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; @@ -37,7 +38,8 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNameModule; import org.elasticsearch.index.analysis.AnalysisModule; import org.elasticsearch.index.cache.IndexCacheModule; -import org.elasticsearch.index.query.functionscore.FunctionScoreModule; +import org.elasticsearch.index.query.functionscore.ScoreFunctionParser; +import org.elasticsearch.index.query.functionscore.ScoreFunctionParserMapper; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.index.similarity.SimilarityModule; import org.elasticsearch.indices.analysis.IndicesAnalysisService; @@ -45,6 +47,7 @@ import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; import org.elasticsearch.indices.query.IndicesQueriesModule; import org.elasticsearch.script.ScriptModule; +import org.elasticsearch.search.SearchModule; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPoolModule; @@ -84,10 +87,10 @@ public class TemplateQueryParserTest extends ESTestCase { new AnalysisModule(settings, new IndicesAnalysisService(settings)), new SimilarityModule(settings), new IndexNameModule(index), - new FunctionScoreModule(), new AbstractModule() { @Override protected void configure() { + Multibinder.newSetBinder(binder(), ScoreFunctionParser.class); bind(ClusterService.class).toProvider(Providers.of((ClusterService) null)); bind(CircuitBreakerService.class).to(NoneCircuitBreakerService.class); } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java index 941fcb36001..f167ce3cbef 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java @@ -35,6 +35,7 @@ import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptModule; import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.ScriptService.ScriptType; +import org.elasticsearch.search.SearchModule; import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; @@ -165,11 +166,8 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase { return "Significance heuristic plugin"; } - public void onModule(SignificantTermsHeuristicModule significanceModule) { - significanceModule.registerParser(SimpleHeuristic.SimpleHeuristicParser.class); - } - - public void onModule(TransportSignificantTermsHeuristicModule significanceModule) { + public void onModule(SearchModule significanceModule) { + significanceModule.registerHeuristicParser(SimpleHeuristic.SimpleHeuristicParser.class); significanceModule.registerStream(SimpleHeuristic.STREAM); } public void onModule(ScriptModule module) { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java index 67c02bcafd8..aea11bab4f9 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java @@ -81,12 +81,6 @@ public class SignificanceHeuristicTests extends ESTestCase { // test that stream output can actually be read - does not replace bwc test @Test public void streamResponse() throws Exception { - SignificanceHeuristicStreams.registerStream(MutualInformation.STREAM, MutualInformation.STREAM.getName()); - SignificanceHeuristicStreams.registerStream(JLHScore.STREAM, JLHScore.STREAM.getName()); - SignificanceHeuristicStreams.registerStream(PercentageScore.STREAM, PercentageScore.STREAM.getName()); - SignificanceHeuristicStreams.registerStream(GND.STREAM, GND.STREAM.getName()); - SignificanceHeuristicStreams.registerStream(ChiSquare.STREAM, ChiSquare.STREAM.getName()); - SignificanceHeuristicStreams.registerStream(ScriptHeuristic.STREAM, ScriptHeuristic.STREAM.getName()); Version version = randomVersion(random()); InternalSignificantTerms[] sigTerms = getRandomSignificantTerms(getRandomSignificanceheuristic()); @@ -143,11 +137,7 @@ public class SignificanceHeuristicTests extends ESTestCase { public void testBuilderAndParser() throws Exception { Set parsers = new HashSet<>(); - parsers.add(new JLHScore.JLHScoreParser()); - parsers.add(new MutualInformation.MutualInformationParser()); - parsers.add(new GND.GNDParser()); - parsers.add(new ChiSquare.ChiSquareParser()); - SignificanceHeuristicParserMapper heuristicParserMapper = new SignificanceHeuristicParserMapper(parsers); + SignificanceHeuristicParserMapper heuristicParserMapper = new SignificanceHeuristicParserMapper(parsers, null); SearchContext searchContext = new SignificantTermsTestSearchContext(); // test jlh with string diff --git a/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java b/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java index c7d10df57f6..daf4d11a080 100644 --- a/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java +++ b/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java @@ -31,6 +31,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.plugins.AbstractPlugin; import org.elasticsearch.search.SearchHitField; +import org.elasticsearch.search.SearchModule; import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.InternalSearchHit; import org.elasticsearch.search.internal.InternalSearchHitField; @@ -110,8 +111,8 @@ public class FetchSubPhasePluginIT extends ESIntegTestCase { return "fetch plugin to test if the plugin mechanism works"; } - public void onModule(FetchSubPhaseModule fetchSubPhaseModule) { - fetchSubPhaseModule.registerFetchSubPhase(TermVectorsFetchSubPhase.class); + public void onModule(SearchModule searchModule) { + searchModule.registerFetchSubPhase(TermVectorsFetchSubPhase.class); } } diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java index e78befd1791..61f50a17a26 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java @@ -28,9 +28,9 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.functionscore.DecayFunction; import org.elasticsearch.index.query.functionscore.DecayFunctionBuilder; import org.elasticsearch.index.query.functionscore.DecayFunctionParser; -import org.elasticsearch.index.query.functionscore.FunctionScoreModule; import org.elasticsearch.plugins.AbstractPlugin; import org.elasticsearch.search.SearchHits; +import org.elasticsearch.search.SearchModule; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.Scope; @@ -107,8 +107,8 @@ public class FunctionScorePluginIT extends ESIntegTestCase { return "Distance score plugin to test pluggable implementation"; } - public void onModule(FunctionScoreModule scoreModule) { - scoreModule.registerParser(FunctionScorePluginIT.CustomDistanceScoreParser.class); + public void onModule(SearchModule scoreModule) { + scoreModule.registerFunctionScoreParser(FunctionScorePluginIT.CustomDistanceScoreParser.class); } } diff --git a/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterPlugin.java b/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterPlugin.java index a3e327b097d..e7c69793c2e 100644 --- a/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterPlugin.java +++ b/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterPlugin.java @@ -20,6 +20,7 @@ package org.elasticsearch.search.highlight; import org.elasticsearch.plugins.AbstractPlugin; +import org.elasticsearch.search.SearchModule; public class CustomHighlighterPlugin extends AbstractPlugin { @@ -33,7 +34,7 @@ public class CustomHighlighterPlugin extends AbstractPlugin { return "Custom highlighter to test pluggable implementation"; } - public void onModule(HighlightModule highlightModule) { + public void onModule(SearchModule highlightModule) { highlightModule.registerHighlighter(CustomHighlighter.class); } } diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterPlugin.java b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterPlugin.java index a54421cb1f8..55dd7bfd722 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterPlugin.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterPlugin.java @@ -19,6 +19,7 @@ package org.elasticsearch.search.suggest; import org.elasticsearch.plugins.AbstractPlugin; +import org.elasticsearch.search.SearchModule; /** * @@ -35,8 +36,8 @@ public class CustomSuggesterPlugin extends AbstractPlugin { return "Custom suggester to test pluggable implementation"; } - public void onModule(SuggestModule suggestModule) { - suggestModule.registerSuggester(CustomSuggester.class); + public void onModule(SearchModule searchModule) { + searchModule.registerSuggester(CustomSuggester.class); } } diff --git a/core/src/test/java/org/elasticsearch/test/InternalTestCluster.java b/core/src/test/java/org/elasticsearch/test/InternalTestCluster.java index eeaa810c7c9..f3f639a4640 100644 --- a/core/src/test/java/org/elasticsearch/test/InternalTestCluster.java +++ b/core/src/test/java/org/elasticsearch/test/InternalTestCluster.java @@ -87,7 +87,6 @@ import org.elasticsearch.index.engine.EngineClosedException; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.IndexShardModule; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.store.IndexStoreModule; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService; @@ -99,15 +98,14 @@ import org.elasticsearch.node.Node; import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.node.service.NodeService; import org.elasticsearch.script.ScriptService; +import org.elasticsearch.search.SearchModule; import org.elasticsearch.search.SearchService; -import org.elasticsearch.search.SearchServiceModule; import org.elasticsearch.test.cache.recycler.MockBigArrays; import org.elasticsearch.test.cache.recycler.MockPageCacheRecycler; import org.elasticsearch.test.disruption.ServiceDisruptionScheme; import org.elasticsearch.test.engine.MockEngineFactory; import org.elasticsearch.test.search.MockSearchService; import org.elasticsearch.test.store.MockFSIndexStore; -import org.elasticsearch.test.store.MockFSIndexStoreModule; import org.elasticsearch.test.transport.AssertingLocalTransport; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.threadpool.ThreadPool; @@ -396,7 +394,7 @@ public final class InternalTestCluster extends TestCluster { builder.put(IndexShardModule.ENGINE_FACTORY, MockEngineFactory.class); builder.put(PageCacheRecyclerModule.CACHE_IMPL, MockPageCacheRecycler.class.getName()); builder.put(BigArraysModule.IMPL, MockBigArrays.class.getName()); - builder.put(SearchServiceModule.IMPL, MockSearchService.class.getName()); + builder.put(SearchModule.SEARCH_SERVICE_IMPL, MockSearchService.class.getName()); } if (isLocalTransportConfigured()) { builder.extendArray("plugin.types", AssertingLocalTransport.Plugin.class.getName()); diff --git a/core/src/test/java/org/elasticsearch/test/engine/MockEngineFactory.java b/core/src/test/java/org/elasticsearch/test/engine/MockEngineFactory.java index 160bf26ce19..602268d037b 100644 --- a/core/src/test/java/org/elasticsearch/test/engine/MockEngineFactory.java +++ b/core/src/test/java/org/elasticsearch/test/engine/MockEngineFactory.java @@ -18,14 +18,18 @@ */ package org.elasticsearch.test.engine; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.engine.EngineConfig; import org.elasticsearch.index.engine.EngineFactory; +import org.elasticsearch.plugins.AbstractPlugin; +import org.elasticsearch.transport.TransportModule; /** * */ public final class MockEngineFactory implements EngineFactory { + @Override public Engine newReadWriteEngine(EngineConfig config, boolean skipTranslogRecovery) { return new MockInternalEngine(config, skipTranslogRecovery);