From ac7173c0d48e709e10d1fd6a385414fa83c35ed7 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 20 Aug 2019 18:51:01 +0200 Subject: [PATCH] Renamed CoordinatorProxyAction to EnrichCoordinatorProxyAction and (#45663) fail if query shard context needs current time (certain queries / scripts use this, but in the enrich context this is not used). --- .../java/org/elasticsearch/xpack/enrich/EnrichPlugin.java | 6 +++--- .../elasticsearch/xpack/enrich/ExactMatchProcessor.java | 4 ++-- ...rProxyAction.java => EnrichCoordinatorProxyAction.java} | 6 +++--- .../xpack/enrich/action/EnrichShardMultiSearchAction.java | 7 +++---- .../xpack/enrich/action/CoordinatorTests.java | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) rename x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/{CoordinatorProxyAction.java => EnrichCoordinatorProxyAction.java} (97%) diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java index 1245a6c546c..d0c9054da96 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java @@ -39,7 +39,7 @@ import org.elasticsearch.xpack.core.enrich.action.DeleteEnrichPolicyAction; import org.elasticsearch.xpack.core.enrich.action.ExecuteEnrichPolicyAction; import org.elasticsearch.xpack.core.enrich.action.GetEnrichPolicyAction; import org.elasticsearch.xpack.core.enrich.action.PutEnrichPolicyAction; -import org.elasticsearch.xpack.enrich.action.CoordinatorProxyAction; +import org.elasticsearch.xpack.enrich.action.EnrichCoordinatorProxyAction; import org.elasticsearch.xpack.enrich.action.EnrichShardMultiSearchAction; import org.elasticsearch.xpack.enrich.action.TransportDeleteEnrichPolicyAction; import org.elasticsearch.xpack.enrich.action.TransportExecuteEnrichPolicyAction; @@ -114,7 +114,7 @@ public class EnrichPlugin extends Plugin implements ActionPlugin, IngestPlugin { new ActionHandler<>(DeleteEnrichPolicyAction.INSTANCE, TransportDeleteEnrichPolicyAction.class), new ActionHandler<>(PutEnrichPolicyAction.INSTANCE, TransportPutEnrichPolicyAction.class), new ActionHandler<>(ExecuteEnrichPolicyAction.INSTANCE, TransportExecuteEnrichPolicyAction.class), - new ActionHandler<>(CoordinatorProxyAction.INSTANCE, CoordinatorProxyAction.TransportAction.class), + new ActionHandler<>(EnrichCoordinatorProxyAction.INSTANCE, EnrichCoordinatorProxyAction.TransportAction.class), new ActionHandler<>(EnrichShardMultiSearchAction.INSTANCE, EnrichShardMultiSearchAction.TransportAction.class) ); } @@ -149,7 +149,7 @@ public class EnrichPlugin extends Plugin implements ActionPlugin, IngestPlugin { return Arrays.asList( enrichPolicyLocks, enrichPolicyExecutor, - new CoordinatorProxyAction.Coordinator(client, settings), + new EnrichCoordinatorProxyAction.Coordinator(client, settings), enrichPolicyMaintenanceService ); } diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/ExactMatchProcessor.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/ExactMatchProcessor.java index f8e5241e80f..03a9db6e078 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/ExactMatchProcessor.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/ExactMatchProcessor.java @@ -17,7 +17,7 @@ import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.xpack.core.enrich.EnrichPolicy; import org.elasticsearch.xpack.enrich.EnrichProcessorFactory.EnrichSpecification; -import org.elasticsearch.xpack.enrich.action.CoordinatorProxyAction; +import org.elasticsearch.xpack.enrich.action.EnrichCoordinatorProxyAction; import java.util.List; import java.util.Map; @@ -152,7 +152,7 @@ public final class ExactMatchProcessor extends AbstractEnrichProcessor { private static BiConsumer> createSearchRunner(Client client) { return (req, handler) -> { - client.execute(CoordinatorProxyAction.INSTANCE, req, ActionListener.wrap( + client.execute(EnrichCoordinatorProxyAction.INSTANCE, req, ActionListener.wrap( resp -> { handler.accept(resp, null); }, diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/CoordinatorProxyAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorProxyAction.java similarity index 97% rename from x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/CoordinatorProxyAction.java rename to x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorProxyAction.java index ca98c6c107e..66272e5343a 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/CoordinatorProxyAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorProxyAction.java @@ -41,12 +41,12 @@ import java.util.concurrent.atomic.AtomicInteger; * This is because the enrich processor executes asynchronously and a bulk request could easily overload * the search tp. */ -public class CoordinatorProxyAction extends ActionType { +public class EnrichCoordinatorProxyAction extends ActionType { - public static final CoordinatorProxyAction INSTANCE = new CoordinatorProxyAction(); + public static final EnrichCoordinatorProxyAction INSTANCE = new EnrichCoordinatorProxyAction(); public static final String NAME = "indices:data/read/xpack/enrich/coordinate_lookups"; - private CoordinatorProxyAction() { + private EnrichCoordinatorProxyAction() { super(NAME, SearchResponse::new); } diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichShardMultiSearchAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichShardMultiSearchAction.java index 22e8d3aa264..2259b5b748b 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichShardMultiSearchAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichShardMultiSearchAction.java @@ -79,7 +79,7 @@ import java.util.Set; * handles multi search requests targeting enrich indices more efficiently by executing them in a bulk using the same * searcher and query shard context. * - * This action (plus some coordination logic in {@link CoordinatorProxyAction}) can be removed when msearch can + * This action (plus some coordination logic in {@link EnrichCoordinatorProxyAction}) can be removed when msearch can * execute search requests targeted to the same shard more efficiently in a bulk like style. * * Note that this 'msearch' implementation only supports executing a query, pagination and source filtering. @@ -204,13 +204,12 @@ public class EnrichShardMultiSearchAction extends ActionType nowInMillis, null); + final QueryShardContext context = indexService.newQueryShardContext(shardId.id(), + searcher.getIndexReader(), () -> {throw new UnsupportedOperationException();}, null); final MapperService mapperService = context.getMapperService(); final Text typeText = mapperService.documentMapper().typeText(); diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/CoordinatorTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/CoordinatorTests.java index 46ab7cb251b..1e416ab8002 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/CoordinatorTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/CoordinatorTests.java @@ -37,7 +37,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -import static org.elasticsearch.xpack.enrich.action.CoordinatorProxyAction.Coordinator; +import static org.elasticsearch.xpack.enrich.action.EnrichCoordinatorProxyAction.Coordinator; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.sameInstance;