diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java index 5698e3ea2313c..05b92ef54d5b9 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java @@ -114,6 +114,7 @@ import org.apache.lucene.util.SetOnce; import org.elasticsearch.Version; import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.logging.DeprecationLogger; @@ -162,7 +163,8 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { this.scriptService.set(scriptService); return Collections.emptyList(); } diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PredicateTokenScriptFilterTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PredicateTokenScriptFilterTests.java index 84ba5e5d3373c..8ea80eade8cb5 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PredicateTokenScriptFilterTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PredicateTokenScriptFilterTests.java @@ -71,7 +71,7 @@ public FactoryType compile(Script script, ScriptContext FactoryType compile(Script script, ScriptContext getRestHandlers(Settings settings, RestController restC public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { return Collections.singletonList(new ReindexSslConfig(environment.settings(), environment, resourceWatcherService)); } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java index 0457856f0f142..4e4e3218ad262 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java @@ -31,6 +31,7 @@ import org.elasticsearch.action.support.ActionFilterChain; import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; @@ -151,7 +152,8 @@ public static class TestPlugin extends Plugin implements ActionPlugin { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { testFilter.set(new ReindexFromRemoteWithAuthTests.TestFilter(threadPool)); return Collections.emptyList(); } diff --git a/modules/systemd/src/main/java/org/elasticsearch/systemd/SystemdPlugin.java b/modules/systemd/src/main/java/org/elasticsearch/systemd/SystemdPlugin.java index c886a12afe7bf..1262a36a03a4b 100644 --- a/modules/systemd/src/main/java/org/elasticsearch/systemd/SystemdPlugin.java +++ b/modules/systemd/src/main/java/org/elasticsearch/systemd/SystemdPlugin.java @@ -23,6 +23,7 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.Build; import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.unit.TimeValue; @@ -88,7 +89,8 @@ public Collection createComponents( final NamedXContentRegistry xContentRegistry, final Environment environment, final NodeEnvironment nodeEnvironment, - final NamedWriteableRegistry namedWriteableRegistry) { + final NamedWriteableRegistry namedWriteableRegistry, + final IndexNameExpressionResolver expressionResolver) { if (enabled) { /* * Since we have set the service type to notify, by default systemd will wait up to sixty seconds for the process to send the diff --git a/modules/systemd/src/test/java/org/elasticsearch/systemd/SystemdPluginTests.java b/modules/systemd/src/test/java/org/elasticsearch/systemd/SystemdPluginTests.java index 3c0abd218b72b..75fa4541670e2 100644 --- a/modules/systemd/src/test/java/org/elasticsearch/systemd/SystemdPluginTests.java +++ b/modules/systemd/src/test/java/org/elasticsearch/systemd/SystemdPluginTests.java @@ -61,28 +61,28 @@ public class SystemdPluginTests extends ESTestCase { public void testIsEnabled() { final SystemdPlugin plugin = new SystemdPlugin(false, randomPackageBuildType, Boolean.TRUE.toString()); - plugin.createComponents(null, null, threadPool, null, null, null, null, null, null); + plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null); assertTrue(plugin.isEnabled()); assertNotNull(plugin.extender); } public void testIsNotPackageDistribution() { final SystemdPlugin plugin = new SystemdPlugin(false, randomNonPackageBuildType, Boolean.TRUE.toString()); - plugin.createComponents(null, null, threadPool, null, null, null, null, null, null); + plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null); assertFalse(plugin.isEnabled()); assertNull(plugin.extender); } public void testIsImplicitlyNotEnabled() { final SystemdPlugin plugin = new SystemdPlugin(false, randomPackageBuildType, null); - plugin.createComponents(null, null, threadPool, null, null, null, null, null, null); + plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null); assertFalse(plugin.isEnabled()); assertNull(plugin.extender); } public void testIsExplicitlyNotEnabled() { final SystemdPlugin plugin = new SystemdPlugin(false, randomPackageBuildType, Boolean.FALSE.toString()); - plugin.createComponents(null, null, threadPool, null, null, null, null, null, null); + plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null); assertFalse(plugin.isEnabled()); assertNull(plugin.extender); } @@ -181,7 +181,7 @@ int sd_notify(final int unset_environment, final String state) { } }; - plugin.createComponents(null, null, threadPool, null, null, null, null, null, null); + plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null); if (Boolean.TRUE.toString().equals(esSDNotify)) { assertNotNull(plugin.extender); } else { diff --git a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/ContextAndHeaderTransportIT.java b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/ContextAndHeaderTransportIT.java index eeec2c480596c..bab1bed8a3064 100644 --- a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/ContextAndHeaderTransportIT.java +++ b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/ContextAndHeaderTransportIT.java @@ -33,6 +33,7 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; @@ -299,7 +300,8 @@ public static class ActionLoggingPlugin extends Plugin implements ActionPlugin { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver indexNameExpressionResolver) { loggingFilter.set(new LoggingFilter(threadPool)); return Collections.emptyList(); } diff --git a/server/src/main/java/org/elasticsearch/index/IndexModule.java b/server/src/main/java/org/elasticsearch/index/IndexModule.java index 3660d2097c1d8..16b7c069bc5cd 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexModule.java +++ b/server/src/main/java/org/elasticsearch/index/IndexModule.java @@ -30,6 +30,7 @@ import org.apache.lucene.util.SetOnce; import org.elasticsearch.Version; import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.TriFunction; @@ -129,6 +130,7 @@ public final class IndexModule { private final SetOnce> forceQueryCacheProvider = new SetOnce<>(); private final List searchOperationListeners = new ArrayList<>(); private final List indexOperationListeners = new ArrayList<>(); + private final IndexNameExpressionResolver expressionResolver; private final AtomicBoolean frozen = new AtomicBoolean(false); private final BooleanSupplier allowExpensiveQueries; @@ -146,7 +148,8 @@ public IndexModule( final AnalysisRegistry analysisRegistry, final EngineFactory engineFactory, final Map directoryFactories, - final BooleanSupplier allowExpensiveQueries) { + final BooleanSupplier allowExpensiveQueries, + final IndexNameExpressionResolver expressionResolver) { this.indexSettings = indexSettings; this.analysisRegistry = analysisRegistry; this.engineFactory = Objects.requireNonNull(engineFactory); @@ -154,6 +157,7 @@ public IndexModule( this.indexOperationListeners.add(new IndexingSlowLog(indexSettings)); this.directoryFactories = Collections.unmodifiableMap(directoryFactories); this.allowExpensiveQueries = allowExpensiveQueries; + this.expressionResolver = expressionResolver; } /** @@ -427,7 +431,7 @@ public IndexService newIndexService( new SimilarityService(indexSettings, scriptService, similarities), shardStoreDeleter, indexAnalyzers, engineFactory, circuitBreakerService, bigArrays, threadPool, scriptService, clusterService, client, queryCache, directoryFactory, eventListener, readerWrapperFactory, mapperRegistry, indicesFieldDataCache, searchOperationListeners, - indexOperationListeners, namedWriteableRegistry, idFieldDataEnabled, allowExpensiveQueries); + indexOperationListeners, namedWriteableRegistry, idFieldDataEnabled, allowExpensiveQueries, expressionResolver); success = true; return indexService; } finally { diff --git a/server/src/main/java/org/elasticsearch/index/IndexService.java b/server/src/main/java/org/elasticsearch/index/IndexService.java index 9dbccdcda6105..4e324eb84c5bf 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexService.java +++ b/server/src/main/java/org/elasticsearch/index/IndexService.java @@ -31,6 +31,7 @@ import org.elasticsearch.Version; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedFunction; @@ -143,6 +144,7 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust private final ClusterService clusterService; private final Client client; private final CircuitBreakerService circuitBreakerService; + private final IndexNameExpressionResolver expressionResolver; private Supplier indexSortSupplier; public IndexService( @@ -169,7 +171,8 @@ public IndexService( List indexingOperationListeners, NamedWriteableRegistry namedWriteableRegistry, BooleanSupplier idFieldDataEnabled, - BooleanSupplier allowExpensiveQueries) { + BooleanSupplier allowExpensiveQueries, + IndexNameExpressionResolver expressionResolver) { super(indexSettings); this.allowExpensiveQueries = allowExpensiveQueries; this.indexSettings = indexSettings; @@ -177,6 +180,7 @@ public IndexService( this.similarityService = similarityService; this.namedWriteableRegistry = namedWriteableRegistry; this.circuitBreakerService = circuitBreakerService; + this.expressionResolver = expressionResolver; if (needsMapperService(indexSettings, indexCreationContext)) { assert indexAnalyzers != null; this.mapperService = new MapperService(indexSettings, indexAnalyzers, xContentRegistry, similarityService, mapperRegistry, @@ -569,7 +573,8 @@ public IndexSettings getIndexSettings() { * {@link IndexReader}-specific optimizations, such as rewriting containing range queries. */ public QueryShardContext newQueryShardContext(int shardId, IndexSearcher searcher, LongSupplier nowInMillis, String clusterAlias) { - SearchIndexNameMatcher indexNameMatcher = new SearchIndexNameMatcher(index().getName(), clusterAlias, clusterService); + final SearchIndexNameMatcher indexNameMatcher = + new SearchIndexNameMatcher(index().getName(), clusterAlias, clusterService, expressionResolver); return new QueryShardContext( shardId, indexSettings, bigArrays, indexCache.bitsetFilterCache(), indexFieldData::getForField, mapperService(), similarityService(), scriptService, xContentRegistry, namedWriteableRegistry, client, searcher, nowInMillis, clusterAlias, diff --git a/server/src/main/java/org/elasticsearch/index/query/SearchIndexNameMatcher.java b/server/src/main/java/org/elasticsearch/index/query/SearchIndexNameMatcher.java index b2329d1d54c83..e09e861ed7b99 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SearchIndexNameMatcher.java +++ b/server/src/main/java/org/elasticsearch/index/query/SearchIndexNameMatcher.java @@ -46,11 +46,12 @@ public class SearchIndexNameMatcher implements Predicate { */ public SearchIndexNameMatcher(String indexName, String clusterAlias, - ClusterService clusterService) { + ClusterService clusterService, + IndexNameExpressionResolver expressionResolver) { this.indexName = indexName; this.clusterAlias = RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY.equals(clusterAlias) ? null : clusterAlias; this.clusterService = clusterService; - this.expressionResolver = new IndexNameExpressionResolver(); + this.expressionResolver = expressionResolver; } /** diff --git a/server/src/main/java/org/elasticsearch/indices/IndicesService.java b/server/src/main/java/org/elasticsearch/indices/IndicesService.java index 4112e03722624..a5da68a515503 100644 --- a/server/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/server/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -598,7 +598,7 @@ private synchronized IndexService createIndexService(IndexService.IndexCreationC indexCreationContext); final IndexModule indexModule = new IndexModule(idxSettings, analysisRegistry, getEngineFactory(idxSettings), - directoryFactories, () -> allowExpensiveQueries); + directoryFactories, () -> allowExpensiveQueries, indexNameExpressionResolver); for (IndexingOperationListener operationListener : indexingOperationListeners) { indexModule.addIndexOperationListener(operationListener); } @@ -668,7 +668,7 @@ private EngineFactory getEngineFactory(final IndexSettings idxSettings) { public synchronized MapperService createIndexMapperService(IndexMetaData indexMetaData) throws IOException { final IndexSettings idxSettings = new IndexSettings(indexMetaData, this.settings, indexScopedSettings); final IndexModule indexModule = new IndexModule(idxSettings, analysisRegistry, getEngineFactory(idxSettings), - directoryFactories, () -> allowExpensiveQueries); + directoryFactories, () -> allowExpensiveQueries, indexNameExpressionResolver); pluginsService.onIndexModule(indexModule); return indexModule.newIndexMapperService(xContentRegistry, mapperRegistry, scriptService); } diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index ffc46ad685e0f..61089cea1ef71 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -470,7 +470,7 @@ protected Node( Collection pluginComponents = pluginsService.filterPlugins(Plugin.class).stream() .flatMap(p -> p.createComponents(client, clusterService, threadPool, resourceWatcherService, scriptModule.getScriptService(), xContentRegistry, environment, nodeEnvironment, - namedWriteableRegistry).stream()) + namedWriteableRegistry, clusterModule.getIndexNameExpressionResolver()).stream()) .collect(Collectors.toList()); ActionModule actionModule = new ActionModule(false, settings, clusterModule.getIndexNameExpressionResolver(), @@ -538,7 +538,8 @@ protected Node( final List> tasksExecutors = pluginsService .filterPlugins(PersistentTaskPlugin.class).stream() - .map(p -> p.getPersistentTasksExecutor(clusterService, threadPool, client, settingsModule)) + .map(p -> p.getPersistentTasksExecutor(clusterService, threadPool, client, settingsModule, + clusterModule.getIndexNameExpressionResolver())) .flatMap(List::stream) .collect(toList()); diff --git a/server/src/main/java/org/elasticsearch/plugins/PersistentTaskPlugin.java b/server/src/main/java/org/elasticsearch/plugins/PersistentTaskPlugin.java index 7c383f752071a..f8618f3f562e7 100644 --- a/server/src/main/java/org/elasticsearch/plugins/PersistentTaskPlugin.java +++ b/server/src/main/java/org/elasticsearch/plugins/PersistentTaskPlugin.java @@ -19,6 +19,7 @@ package org.elasticsearch.plugins; import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.persistent.PersistentTasksExecutor; @@ -38,7 +39,8 @@ public interface PersistentTaskPlugin { default List> getPersistentTasksExecutor(ClusterService clusterService, ThreadPool threadPool, Client client, - SettingsModule settingsModule) { + SettingsModule settingsModule, + IndexNameExpressionResolver expressionResolver) { return Collections.emptyList(); } diff --git a/server/src/main/java/org/elasticsearch/plugins/Plugin.java b/server/src/main/java/org/elasticsearch/plugins/Plugin.java index a1d98365273f6..64583d0d6a3e9 100644 --- a/server/src/main/java/org/elasticsearch/plugins/Plugin.java +++ b/server/src/main/java/org/elasticsearch/plugins/Plugin.java @@ -22,6 +22,7 @@ import org.elasticsearch.bootstrap.BootstrapCheck; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNodeRole; @@ -114,11 +115,13 @@ public Collection> getGuiceServiceClasses() * @param environment the environment for path and setting configurations * @param nodeEnvironment the node environment used coordinate access to the data paths * @param namedWriteableRegistry the registry for {@link NamedWriteable} object parsing + * @param indexNameExpressionResolver A service that resolves expression to index and alias names */ public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver indexNameExpressionResolver) { return Collections.emptyList(); } diff --git a/server/src/test/java/org/elasticsearch/action/ingest/AsyncIngestProcessorIT.java b/server/src/test/java/org/elasticsearch/action/ingest/AsyncIngestProcessorIT.java index 1d398738db171..ec0296457aaf8 100644 --- a/server/src/test/java/org/elasticsearch/action/ingest/AsyncIngestProcessorIT.java +++ b/server/src/test/java/org/elasticsearch/action/ingest/AsyncIngestProcessorIT.java @@ -24,6 +24,7 @@ import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; @@ -100,7 +101,8 @@ public static class TestPlugin extends Plugin implements IngestPlugin { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { this.threadPool = threadPool; return Collections.emptyList(); } diff --git a/server/src/test/java/org/elasticsearch/cluster/ClusterStateIT.java b/server/src/test/java/org/elasticsearch/cluster/ClusterStateIT.java index fc917d60deede..0f09a58368e20 100644 --- a/server/src/test/java/org/elasticsearch/cluster/ClusterStateIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/ClusterStateIT.java @@ -23,6 +23,7 @@ import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.IndexGraveyard; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedFunction; @@ -214,15 +215,16 @@ public List getNamedXContent() { @Override public Collection createComponents( - final Client client, - final ClusterService clusterService, - final ThreadPool threadPool, - final ResourceWatcherService resourceWatcherService, - final ScriptService scriptService, - final NamedXContentRegistry xContentRegistry, - final Environment environment, - final NodeEnvironment nodeEnvironment, - final NamedWriteableRegistry namedWriteableRegistry) { + final Client client, + final ClusterService clusterService, + final ThreadPool threadPool, + final ResourceWatcherService resourceWatcherService, + final ScriptService scriptService, + final NamedXContentRegistry xContentRegistry, + final Environment environment, + final NodeEnvironment nodeEnvironment, + final NamedWriteableRegistry namedWriteableRegistry, + final IndexNameExpressionResolver indexNameExpressionResolver) { clusterService.addListener(event -> { final ClusterState state = event.state(); if (state.getBlocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK)) { diff --git a/server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java b/server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java index c4fa46a0a1960..ca4b071fc6d9a 100644 --- a/server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java @@ -26,6 +26,7 @@ import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingTable; @@ -381,7 +382,8 @@ public Collection createComponents( final NamedXContentRegistry xContentRegistry, final Environment environment, final NodeEnvironment nodeEnvironment, - final NamedWriteableRegistry namedWriteableRegistry) { + final NamedWriteableRegistry namedWriteableRegistry, + final IndexNameExpressionResolver expressionResolver) { clusterService.addListener(event -> { final ClusterState state = event.state(); if (state.getBlocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK)) { diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/TemplateUpgradeServiceIT.java b/server/src/test/java/org/elasticsearch/cluster/metadata/TemplateUpgradeServiceIT.java index c2ed291801ce6..a335568e72815 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/TemplateUpgradeServiceIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/TemplateUpgradeServiceIT.java @@ -70,12 +70,13 @@ public TestPlugin(Settings settings) { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { clusterService.getClusterSettings().addSettingsUpdateConsumer(UPDATE_TEMPLATE_DUMMY_SETTING, integer -> { logger.debug("the template dummy setting was updated to {}", integer); }); return super.createComponents(client, clusterService, threadPool, resourceWatcherService, scriptService, xContentRegistry, - environment, nodeEnvironment, namedWriteableRegistry); + environment, nodeEnvironment, namedWriteableRegistry, expressionResolver); } @Override diff --git a/server/src/test/java/org/elasticsearch/index/FinalPipelineIT.java b/server/src/test/java/org/elasticsearch/index/FinalPipelineIT.java index 9e13a17b03d9d..8f0f648b3cb0d 100644 --- a/server/src/test/java/org/elasticsearch/index/FinalPipelineIT.java +++ b/server/src/test/java/org/elasticsearch/index/FinalPipelineIT.java @@ -29,6 +29,7 @@ import org.elasticsearch.action.ingest.PutPipelineRequest; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; @@ -243,7 +244,8 @@ public Collection createComponents( final NamedXContentRegistry xContentRegistry, final Environment environment, final NodeEnvironment nodeEnvironment, - final NamedWriteableRegistry namedWriteableRegistry) { + final NamedWriteableRegistry namedWriteableRegistry, + final IndexNameExpressionResolver expressionResolver) { return Collections.emptyList(); } diff --git a/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java b/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java index 2bb5702ff2e9e..a4161c6bc9f26 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java @@ -34,6 +34,7 @@ import org.apache.lucene.util.SetOnce.AlreadySetException; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.breaker.CircuitBreaker; @@ -167,7 +168,7 @@ private IndexService newIndexService(IndexModule module) throws IOException { public void testWrapperIsBound() throws IOException { final MockEngineFactory engineFactory = new MockEngineFactory(AssertingDirectoryReader.class); IndexModule module = new IndexModule( - indexSettings, emptyAnalysisRegistry, engineFactory, Collections.emptyMap(), () -> true); + indexSettings, emptyAnalysisRegistry, engineFactory, Collections.emptyMap(), () -> true, new IndexNameExpressionResolver()); module.setReaderWrapper(s -> new Wrapper()); IndexService indexService = newIndexService(module); @@ -187,8 +188,8 @@ public void testRegisterIndexStore() throws IOException { final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings); final Map indexStoreFactories = singletonMap( "foo_store", new FooFunction()); - final IndexModule module = new IndexModule( - indexSettings, emptyAnalysisRegistry, new InternalEngineFactory(), indexStoreFactories, () -> true); + final IndexModule module = new IndexModule(indexSettings, emptyAnalysisRegistry, new InternalEngineFactory(), indexStoreFactories, + () -> true, new IndexNameExpressionResolver()); final IndexService indexService = newIndexService(module); assertThat(indexService.getDirectoryFactory(), instanceOf(FooFunction.class)); @@ -485,8 +486,8 @@ public void testMmapNotAllowed() { } private static IndexModule createIndexModule(IndexSettings indexSettings, AnalysisRegistry emptyAnalysisRegistry) { - return new IndexModule( - indexSettings, emptyAnalysisRegistry, new InternalEngineFactory(), Collections.emptyMap(), () -> true); + return new IndexModule(indexSettings, emptyAnalysisRegistry, new InternalEngineFactory(), Collections.emptyMap(), () -> true, + new IndexNameExpressionResolver()); } class CustomQueryCache implements QueryCache { diff --git a/server/src/test/java/org/elasticsearch/index/query/SearchIndexNameMatcherTests.java b/server/src/test/java/org/elasticsearch/index/query/SearchIndexNameMatcherTests.java index a796586bcf564..208990deaaa89 100644 --- a/server/src/test/java/org/elasticsearch/index/query/SearchIndexNameMatcherTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/SearchIndexNameMatcherTests.java @@ -24,6 +24,7 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.AliasMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; @@ -48,8 +49,8 @@ public void setUpMatchers() { ClusterService clusterService = mock(ClusterService.class); when(clusterService.state()).thenReturn(state); - matcher = new SearchIndexNameMatcher("index1", "", clusterService); - remoteMatcher = new SearchIndexNameMatcher("index1", "cluster", clusterService); + matcher = new SearchIndexNameMatcher("index1", "", clusterService, new IndexNameExpressionResolver()); + remoteMatcher = new SearchIndexNameMatcher("index1", "cluster", clusterService, new IndexNameExpressionResolver()); } private static IndexMetaData.Builder indexBuilder(String index) { diff --git a/server/src/test/java/org/elasticsearch/persistent/TestPersistentTasksPlugin.java b/server/src/test/java/org/elasticsearch/persistent/TestPersistentTasksPlugin.java index 0e02a2c52c13c..1612f389ebd4c 100644 --- a/server/src/test/java/org/elasticsearch/persistent/TestPersistentTasksPlugin.java +++ b/server/src/test/java/org/elasticsearch/persistent/TestPersistentTasksPlugin.java @@ -36,6 +36,7 @@ import org.elasticsearch.client.Client; import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.ParseField; @@ -94,7 +95,8 @@ public class TestPersistentTasksPlugin extends Plugin implements ActionPlugin, P public List> getPersistentTasksExecutor(ClusterService clusterService, ThreadPool threadPool, Client client, - SettingsModule settingsModule) { + SettingsModule settingsModule, + IndexNameExpressionResolver expressionResolver) { return Collections.singletonList(new TestPersistentTasksExecutor(clusterService)); } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java index 9ead0127c9294..be6a691feef6d 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java @@ -175,7 +175,8 @@ public Collection createComponents( final NamedXContentRegistry xContentRegistry, final Environment environment, final NodeEnvironment nodeEnvironment, - final NamedWriteableRegistry namedWriteableRegistry) { + final NamedWriteableRegistry namedWriteableRegistry, + final IndexNameExpressionResolver expressionResolver) { this.client = client; if (enabled == false) { return emptyList(); @@ -204,7 +205,8 @@ public Collection createComponents( public List> getPersistentTasksExecutor(ClusterService clusterService, ThreadPool threadPool, Client client, - SettingsModule settingsModule) { + SettingsModule settingsModule, + IndexNameExpressionResolver expressionResolver) { return Collections.singletonList(new ShardFollowTasksExecutor(client, threadPool, clusterService, settingsModule)); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java index b549e8b0a9a94..5b56e16db70de 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java @@ -253,7 +253,8 @@ public Collection createGuiceModules() { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { List components = new ArrayList<>(); final SSLService sslService = new SSLService(environment); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java index 8e284cd6d51ae..70619c56fe556 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java @@ -118,7 +118,8 @@ public static String configIndexName() { * Creates the .ml-state-000001 index (if necessary) * Creates the .ml-state-write alias for the .ml-state-000001 index (if necessary) */ - public static void createStateIndexAndAliasIfNecessary(Client client, ClusterState state, final ActionListener finalListener) { + public static void createStateIndexAndAliasIfNecessary(Client client, ClusterState state, IndexNameExpressionResolver resolver, + final ActionListener finalListener) { if (state.getMetaData().getAliasAndIndexLookup().containsKey(jobStateIndexWriteAlias())) { finalListener.onResponse(false); @@ -143,8 +144,7 @@ public static void createStateIndexAndAliasIfNecessary(Client client, ClusterSta finalListener::onFailure ); - IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(); - String[] stateIndices = indexNameExpressionResolver.concreteIndexNames(state, + String[] stateIndices = resolver.concreteIndexNames(state, IndicesOptions.lenientExpandOpen(), jobStateIndexPattern()); if (stateIndices.length > 0) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java index e3da8a652c8fd..9d77d521fbb47 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java @@ -151,14 +151,15 @@ public Collection createGuiceModules() { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { List components = new ArrayList<>(); components.addAll(super.createComponents(client, clusterService, threadPool, resourceWatcherService, scriptService, - xContentRegistry, environment, nodeEnvironment, namedWriteableRegistry)); + xContentRegistry, environment, nodeEnvironment, namedWriteableRegistry, expressionResolver)); filterPlugins(Plugin.class).stream().forEach(p -> components.addAll(p.createComponents(client, clusterService, threadPool, resourceWatcherService, scriptService, - xContentRegistry, environment, nodeEnvironment, namedWriteableRegistry)) + xContentRegistry, environment, nodeEnvironment, namedWriteableRegistry, expressionResolver)) ); return components; } @@ -409,9 +410,10 @@ public BiConsumer getJoinValidator() { public List> getPersistentTasksExecutor(ClusterService clusterService, ThreadPool threadPool, Client client, - SettingsModule settingsModule) { + SettingsModule settingsModule, + IndexNameExpressionResolver expressionResolver) { return filterPlugins(PersistentTaskPlugin.class).stream() - .map(p -> p.getPersistentTasksExecutor(clusterService, threadPool, client, settingsModule)) + .map(p -> p.getPersistentTasksExecutor(clusterService, threadPool, client, settingsModule, expressionResolver)) .flatMap(List::stream) .collect(toList()); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndexTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndexTests.java index 4bdcc2346061a..ce5b038728651 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndexTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndexTests.java @@ -24,6 +24,7 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.AliasMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.settings.Settings; @@ -102,7 +103,7 @@ public void verifyNoMoreInteractionsWithMocks() { public void testCreateStateIndexAndAliasIfNecessary_CleanState() { ClusterState clusterState = createClusterState(Collections.emptyMap()); - AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, finalListener); + AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, new IndexNameExpressionResolver(), finalListener); InOrder inOrder = inOrder(indicesAdminClient, finalListener); inOrder.verify(indicesAdminClient).prepareCreate(INITIAL_ML_STATE); @@ -116,7 +117,7 @@ public void testCreateStateIndexAndAliasIfNecessary_CleanState() { private void assertNoClientInteractionsWhenWriteAliasAlreadyExists(String indexName) { ClusterState clusterState = createClusterState(Collections.singletonMap(indexName, createIndexMetaDataWithAlias(indexName))); - AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, finalListener); + AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, new IndexNameExpressionResolver(), finalListener); verify(finalListener).onResponse(false); } @@ -141,7 +142,7 @@ private void assertMlStateWriteAliasAddedToMostRecentMlStateIndex(List e ClusterState clusterState = createClusterState( existingIndexNames.stream().collect(toMap(Function.identity(), AnomalyDetectorsIndexTests::createIndexMetaData))); - AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, finalListener); + AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, new IndexNameExpressionResolver(), finalListener); InOrder inOrder = inOrder(indicesAdminClient, finalListener); inOrder.verify(indicesAdminClient).prepareAliases(); 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 f67351f436ad8..7d9bf0df83794 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 @@ -198,7 +198,8 @@ public Collection createComponents( NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, - NamedWriteableRegistry namedWriteableRegistry + NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver ) { if (enabled == false || transportClientMode) { return emptyList(); diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/TransportExecuteEnrichPolicyAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/TransportExecuteEnrichPolicyAction.java index 131a579b99332..9f73df564f54e 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/TransportExecuteEnrichPolicyAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/TransportExecuteEnrichPolicyAction.java @@ -61,7 +61,7 @@ public TransportExecuteEnrichPolicyAction( client, transportService.getTaskManager(), threadPool, - new IndexNameExpressionResolver(), + indexNameExpressionResolver, enrichPolicyLocks, System::currentTimeMillis ); diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java index c6434ab4acf61..19396f2230263 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java @@ -72,7 +72,8 @@ public class EqlPlugin extends Plugin implements ActionPlugin { @Override public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, - Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { return createComponents(client, clusterService.getClusterName().value(), namedWriteableRegistry); } diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java index ca92b70644c47..1acbdbd307d93 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java @@ -188,7 +188,8 @@ public List> getSettings() { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { if (transportClientMode) { return Collections.emptyList(); } diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/UpdateSettingsStepTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/UpdateSettingsStepTests.java index be6ecb7075c68..31e5bb67cb13b 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/UpdateSettingsStepTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/UpdateSettingsStepTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateObserver; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; @@ -59,7 +60,8 @@ public void onIndexModule(IndexModule module) { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { return Collections.singletonList(service); } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java index 051d4bfaf70ba..76dd03effeac0 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java @@ -511,7 +511,8 @@ protected Clock getClock() { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver indexNameExpressionResolver) { if (enabled == false || transportClientMode) { // special holder for @link(MachineLearningFeatureSetUsage) which needs access to job manager, empty if ML is disabled return Collections.singletonList(new JobManagerHolder()); @@ -525,7 +526,7 @@ public Collection createComponents(Client client, ClusterService cluster this.dataFrameAnalyticsAuditor.set(dataFrameAnalyticsAuditor); OriginSettingClient originSettingClient = new OriginSettingClient(client, ClientHelper.ML_ORIGIN); ResultsPersisterService resultsPersisterService = new ResultsPersisterService(originSettingClient, clusterService, settings); - JobResultsProvider jobResultsProvider = new JobResultsProvider(client, settings); + JobResultsProvider jobResultsProvider = new JobResultsProvider(client, settings, indexNameExpressionResolver); JobResultsPersister jobResultsPersister = new JobResultsPersister(originSettingClient, resultsPersisterService, anomalyDetectionAuditor); JobDataCountsPersister jobDataCountsPersister = new JobDataCountsPersister(client, @@ -600,7 +601,7 @@ public Collection createComponents(Client client, ClusterService cluster threadPool.executor(MachineLearning.UTILITY_THREAD_POOL_NAME)); AutodetectProcessManager autodetectProcessManager = new AutodetectProcessManager(env, settings, client, threadPool, xContentRegistry, anomalyDetectionAuditor, clusterService, jobManager, jobResultsProvider, jobResultsPersister, - jobDataCountsPersister, autodetectProcessFactory, normalizerFactory, nativeStorageProvider); + jobDataCountsPersister, autodetectProcessFactory, normalizerFactory, nativeStorageProvider, indexNameExpressionResolver); this.autodetectProcessManager.set(autodetectProcessManager); DatafeedJobBuilder datafeedJobBuilder = new DatafeedJobBuilder( @@ -635,8 +636,8 @@ public Collection createComponents(Client client, ClusterService cluster threadPool.generic(), threadPool.executor(MachineLearning.JOB_COMMS_THREAD_POOL_NAME), memoryEstimationProcessFactory); DataFrameAnalyticsConfigProvider dataFrameAnalyticsConfigProvider = new DataFrameAnalyticsConfigProvider(client, xContentRegistry); assert client instanceof NodeClient; - DataFrameAnalyticsManager dataFrameAnalyticsManager = new DataFrameAnalyticsManager( - (NodeClient) client, dataFrameAnalyticsConfigProvider, analyticsProcessManager, dataFrameAnalyticsAuditor); + DataFrameAnalyticsManager dataFrameAnalyticsManager = new DataFrameAnalyticsManager((NodeClient) client, + dataFrameAnalyticsConfigProvider, analyticsProcessManager, dataFrameAnalyticsAuditor, indexNameExpressionResolver); this.dataFrameAnalyticsManager.set(dataFrameAnalyticsManager); // Components shared by anomaly detection and data frame analytics @@ -646,7 +647,7 @@ public Collection createComponents(Client client, ClusterService cluster MlLifeCycleService mlLifeCycleService = new MlLifeCycleService(environment, clusterService, datafeedManager, autodetectProcessManager, memoryTracker); MlAssignmentNotifier mlAssignmentNotifier = new MlAssignmentNotifier(anomalyDetectionAuditor, dataFrameAnalyticsAuditor, threadPool, - new MlConfigMigrator(settings, client, clusterService), clusterService); + new MlConfigMigrator(settings, client, clusterService, indexNameExpressionResolver), clusterService); // this object registers as a license state listener, and is never removed, so there's no need to retain another reference to it final InvalidLicenseEnforcer enforcer = @@ -682,20 +683,22 @@ public Collection createComponents(Client client, ClusterService cluster ); } + @Override public List> getPersistentTasksExecutor(ClusterService clusterService, ThreadPool threadPool, Client client, - SettingsModule settingsModule) { + SettingsModule settingsModule, + IndexNameExpressionResolver expressionResolver) { if (enabled == false || transportClientMode) { return emptyList(); } return Arrays.asList( new TransportOpenJobAction.OpenJobPersistentTasksExecutor(settings, clusterService, autodetectProcessManager.get(), - memoryTracker.get(), client), - new TransportStartDatafeedAction.StartDatafeedPersistentTasksExecutor(datafeedManager.get()), + memoryTracker.get(), client, expressionResolver), + new TransportStartDatafeedAction.StartDatafeedPersistentTasksExecutor(datafeedManager.get(), expressionResolver), new TransportStartDataFrameAnalyticsAction.TaskExecutor(settings, client, clusterService, dataFrameAnalyticsManager.get(), - dataFrameAnalyticsAuditor.get(), memoryTracker.get()) + dataFrameAnalyticsAuditor.get(), memoryTracker.get(), expressionResolver) ); } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlConfigMigrator.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlConfigMigrator.java index b2bcb43689be9..1c95d8fa07c0e 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlConfigMigrator.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlConfigMigrator.java @@ -23,6 +23,7 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateUpdateTask; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; @@ -109,14 +110,17 @@ public class MlConfigMigrator { private final Client client; private final ClusterService clusterService; + private final IndexNameExpressionResolver expressionResolver; private final MlConfigMigrationEligibilityCheck migrationEligibilityCheck; private final AtomicBoolean migrationInProgress; private final AtomicBoolean tookConfigSnapshot; - public MlConfigMigrator(Settings settings, Client client, ClusterService clusterService) { + public MlConfigMigrator(Settings settings, Client client, ClusterService clusterService, + IndexNameExpressionResolver expressionResolver) { this.client = Objects.requireNonNull(client); this.clusterService = Objects.requireNonNull(clusterService); + this.expressionResolver = Objects.requireNonNull(expressionResolver); this.migrationEligibilityCheck = new MlConfigMigrationEligibilityCheck(settings, clusterService); this.migrationInProgress = new AtomicBoolean(false); this.tookConfigSnapshot = new AtomicBoolean(false); @@ -462,7 +466,7 @@ public void snapshotMlMeta(MlMetadata mlMetadata, ActionListener listen return; } - AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterService.state(), ActionListener.wrap( + AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterService.state(), expressionResolver, ActionListener.wrap( r -> { executeAsyncWithOrigin(client.threadPool().getThreadContext(), ML_ORIGIN, indexRequest, ActionListener.wrap( diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java index 16bc970d4a53f..a968d296118ea 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java @@ -139,9 +139,9 @@ static String[] indicesOfInterest(String resultsIndex) { AnomalyDetectorsIndex.configIndexName()}; } - static List verifyIndicesPrimaryShardsAreActive(String resultsWriteIndex, ClusterState clusterState) { - IndexNameExpressionResolver resolver = new IndexNameExpressionResolver(); - String[] indices = resolver.concreteIndexNames(clusterState, IndicesOptions.lenientExpandOpen(), + static List verifyIndicesPrimaryShardsAreActive(String resultsWriteIndex, ClusterState clusterState, + IndexNameExpressionResolver expressionResolver) { + String[] indices = expressionResolver.concreteIndexNames(clusterState, IndicesOptions.lenientExpandOpen(), indicesOfInterest(resultsWriteIndex)); List unavailableIndices = new ArrayList<>(indices.length); for (String index : indices) { @@ -345,6 +345,7 @@ public static class OpenJobPersistentTasksExecutor extends PersistentTasksExecut private final AutodetectProcessManager autodetectProcessManager; private final MlMemoryTracker memoryTracker; private final Client client; + private final IndexNameExpressionResolver expressionResolver; private volatile int maxConcurrentJobAllocations; private volatile int maxMachineMemoryPercent; @@ -354,11 +355,12 @@ public static class OpenJobPersistentTasksExecutor extends PersistentTasksExecut public OpenJobPersistentTasksExecutor(Settings settings, ClusterService clusterService, AutodetectProcessManager autodetectProcessManager, MlMemoryTracker memoryTracker, - Client client) { + Client client, IndexNameExpressionResolver expressionResolver) { super(MlTasks.JOB_TASK_NAME, MachineLearning.UTILITY_THREAD_POOL_NAME); this.autodetectProcessManager = Objects.requireNonNull(autodetectProcessManager); this.memoryTracker = Objects.requireNonNull(memoryTracker); this.client = Objects.requireNonNull(client); + this.expressionResolver = Objects.requireNonNull(expressionResolver); this.maxConcurrentJobAllocations = MachineLearning.CONCURRENT_JOB_ALLOCATIONS.get(settings); this.maxMachineMemoryPercent = MachineLearning.MAX_MACHINE_MEMORY_PERCENT.get(settings); this.maxLazyMLNodes = MachineLearning.MAX_LAZY_ML_NODES.get(settings); @@ -389,7 +391,7 @@ public PersistentTasksCustomMetaData.Assignment getAssignment(OpenJobAction.JobP String jobId = params.getJobId(); String resultsWriteAlias = AnomalyDetectorsIndex.resultsWriteAlias(jobId); - List unavailableIndices = verifyIndicesPrimaryShardsAreActive(resultsWriteAlias, clusterState); + List unavailableIndices = verifyIndicesPrimaryShardsAreActive(resultsWriteAlias, clusterState, expressionResolver); if (unavailableIndices.size() != 0) { String reason = "Not opening job [" + jobId + "], because not all primary shards are active for the following indices [" + String.join(",", unavailableIndices) + "]"; diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportRevertModelSnapshotAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportRevertModelSnapshotAction.java index 51130a3d94f4d..605f1dae9c648 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportRevertModelSnapshotAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportRevertModelSnapshotAction.java @@ -117,7 +117,7 @@ protected void masterOperation(RevertModelSnapshotAction.Request request, Cluste ); // 1. Verify/Create the state index and its alias exists - AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, state, createStateIndexListener); + AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, state, indexNameExpressionResolver, createStateIndexListener); } private void getModelSnapshot(RevertModelSnapshotAction.Request request, JobResultsProvider provider, Consumer handler, diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDataFrameAnalyticsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDataFrameAnalyticsAction.java index 1558720064609..fd1db1cc04e46 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDataFrameAnalyticsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDataFrameAnalyticsAction.java @@ -503,8 +503,9 @@ public void onFailure(Exception e) { ); } - static List verifyIndicesPrimaryShardsAreActive(ClusterState clusterState, String... indexNames) { - IndexNameExpressionResolver resolver = new IndexNameExpressionResolver(); + static List verifyIndicesPrimaryShardsAreActive(ClusterState clusterState, + IndexNameExpressionResolver resolver, + String... indexNames) { String[] concreteIndices = resolver.concreteIndexNames(clusterState, IndicesOptions.lenientExpandOpen(), indexNames); List unavailableIndices = new ArrayList<>(concreteIndices.length); for (String index : concreteIndices) { @@ -523,6 +524,7 @@ public static class TaskExecutor extends PersistentTasksExecutor unavailableIndices = verifyIndicesPrimaryShardsAreActive(clusterState, AnomalyDetectorsIndex.configIndexName()); + List unavailableIndices = + verifyIndicesPrimaryShardsAreActive(clusterState, resolver, AnomalyDetectorsIndex.configIndexName()); if (unavailableIndices.size() != 0) { String reason = "Not opening data frame analytics job [" + id + "], because not all primary shards are active for the following indices [" + String.join(",", unavailableIndices) + "]"; diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java index 7335c4b63d2e6..4e1da422d7c29 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java @@ -367,10 +367,10 @@ public static class StartDatafeedPersistentTasksExecutor extends PersistentTasks private final DatafeedManager datafeedManager; private final IndexNameExpressionResolver resolver; - public StartDatafeedPersistentTasksExecutor(DatafeedManager datafeedManager) { + public StartDatafeedPersistentTasksExecutor(DatafeedManager datafeedManager, IndexNameExpressionResolver resolver) { super(MlTasks.DATAFEED_TASK_NAME, MachineLearning.UTILITY_THREAD_POOL_NAME); this.datafeedManager = datafeedManager; - this.resolver = new IndexNameExpressionResolver(); + this.resolver = resolver; } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java index e48485f6218c6..8b150f4fbbabc 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.support.ContextPreservingActionListener; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.reindex.BulkByScrollResponse; @@ -58,13 +59,16 @@ public class DataFrameAnalyticsManager { private final DataFrameAnalyticsConfigProvider configProvider; private final AnalyticsProcessManager processManager; private final DataFrameAnalyticsAuditor auditor; + private final IndexNameExpressionResolver expressionResolver; public DataFrameAnalyticsManager(NodeClient client, DataFrameAnalyticsConfigProvider configProvider, - AnalyticsProcessManager processManager, DataFrameAnalyticsAuditor auditor) { + AnalyticsProcessManager processManager, DataFrameAnalyticsAuditor auditor, + IndexNameExpressionResolver expressionResolver) { this.client = Objects.requireNonNull(client); this.configProvider = Objects.requireNonNull(configProvider); this.processManager = Objects.requireNonNull(processManager); this.auditor = Objects.requireNonNull(auditor); + this.expressionResolver = Objects.requireNonNull(expressionResolver); } public void execute(DataFrameAnalyticsTask task, DataFrameAnalyticsState currentState, ClusterState clusterState) { @@ -104,7 +108,7 @@ public void execute(DataFrameAnalyticsTask task, DataFrameAnalyticsState current ); // Make sure the state index and alias exist - AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, stateAliasListener); + AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, expressionResolver, stateAliasListener); } private void executeStartingJob(DataFrameAnalyticsTask task, DataFrameAnalyticsConfig config) { diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProvider.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProvider.java index 979b145c4eb93..012f2492ad5ce 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProvider.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProvider.java @@ -145,10 +145,12 @@ public class JobResultsProvider { private final Client client; private final Settings settings; + private final IndexNameExpressionResolver resolver; - public JobResultsProvider(Client client, Settings settings) { + public JobResultsProvider(Client client, Settings settings, IndexNameExpressionResolver resolver) { this.client = Objects.requireNonNull(client); this.settings = settings; + this.resolver = resolver; } /** @@ -265,7 +267,6 @@ public void createJobResultIndex(Job job, ClusterState state, final ActionListen // Our read/write aliases should point to the concrete index // If the initial index is NOT an alias, either it is already a concrete index, or it does not exist yet if (state.getMetaData().hasAlias(tempIndexName)) { - IndexNameExpressionResolver resolver = new IndexNameExpressionResolver(); String[] concreteIndices = resolver.concreteIndexNames(state, IndicesOptions.lenientExpandOpen(), tempIndexName); // SHOULD NOT be closed as in typical call flow checkForLeftOverDocuments already verified this diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java index 9eef65bcbbe35..4845b67bae3f2 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java @@ -14,6 +14,7 @@ import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateListener; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.common.collect.Tuple; @@ -98,6 +99,7 @@ public class AutodetectProcessManager implements ClusterStateListener { private final JobResultsProvider jobResultsProvider; private final AutodetectProcessFactory autodetectProcessFactory; private final NormalizerFactory normalizerFactory; + private final IndexNameExpressionResolver expressionResolver; private final JobResultsPersister jobResultsPersister; private final JobDataCountsPersister jobDataCountsPersister; @@ -117,7 +119,8 @@ public AutodetectProcessManager(Environment environment, Settings settings, Clie NamedXContentRegistry xContentRegistry, AnomalyDetectionAuditor auditor, ClusterService clusterService, JobManager jobManager, JobResultsProvider jobResultsProvider, JobResultsPersister jobResultsPersister, JobDataCountsPersister jobDataCountsPersister, AutodetectProcessFactory autodetectProcessFactory, - NormalizerFactory normalizerFactory, NativeStorageProvider nativeStorageProvider) { + NormalizerFactory normalizerFactory, NativeStorageProvider nativeStorageProvider, + IndexNameExpressionResolver expressionResolver) { this.environment = environment; this.client = client; this.threadPool = threadPool; @@ -125,6 +128,7 @@ public AutodetectProcessManager(Environment environment, Settings settings, Clie this.maxAllowedRunningJobs = MachineLearning.MAX_OPEN_JOBS_PER_NODE.get(settings); this.autodetectProcessFactory = autodetectProcessFactory; this.normalizerFactory = normalizerFactory; + this.expressionResolver = expressionResolver; this.jobManager = jobManager; this.jobResultsProvider = jobResultsProvider; this.jobResultsPersister = jobResultsPersister; @@ -435,7 +439,7 @@ protected void doRun() { // Make sure the state index and alias exist ActionListener resultsMappingUpdateHandler = ActionListener.wrap( - ack -> AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, stateAliasHandler), + ack -> AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, expressionResolver, stateAliasHandler), e -> closeHandler.accept(e, true) ); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportOpenJobActionTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportOpenJobActionTests.java index 949684227082c..c96d161d2e66c 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportOpenJobActionTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportOpenJobActionTests.java @@ -91,6 +91,7 @@ public void testValidate_givenValidJob() { } public void testVerifyIndicesPrimaryShardsAreActive() { + final IndexNameExpressionResolver resolver = new IndexNameExpressionResolver(); MetaData.Builder metaData = MetaData.builder(); RoutingTable.Builder routingTable = RoutingTable.builder(); addIndices(metaData, routingTable); @@ -100,7 +101,7 @@ public void testVerifyIndicesPrimaryShardsAreActive() { csBuilder.metaData(metaData); ClusterState cs = csBuilder.build(); - assertEquals(0, TransportOpenJobAction.verifyIndicesPrimaryShardsAreActive(".ml-anomalies-shared", cs).size()); + assertEquals(0, TransportOpenJobAction.verifyIndicesPrimaryShardsAreActive(".ml-anomalies-shared", cs, resolver).size()); metaData = new MetaData.Builder(cs.metaData()); routingTable = new RoutingTable.Builder(cs.routingTable()); @@ -121,7 +122,8 @@ public void testVerifyIndicesPrimaryShardsAreActive() { csBuilder.routingTable(routingTable.build()); csBuilder.metaData(metaData); - List result = TransportOpenJobAction.verifyIndicesPrimaryShardsAreActive(".ml-anomalies-shared", csBuilder.build()); + List result = + TransportOpenJobAction.verifyIndicesPrimaryShardsAreActive(".ml-anomalies-shared", csBuilder.build(), resolver); assertEquals(1, result.size()); assertEquals(indexToRemove, result.get(0)); } @@ -153,7 +155,8 @@ public void testGetAssignment_GivenJobThatRequiresMigration() { when(clusterService.getClusterSettings()).thenReturn(clusterSettings); TransportOpenJobAction.OpenJobPersistentTasksExecutor executor = new TransportOpenJobAction.OpenJobPersistentTasksExecutor( - Settings.EMPTY, clusterService, mock(AutodetectProcessManager.class), mock(MlMemoryTracker.class), mock(Client.class)); + Settings.EMPTY, clusterService, mock(AutodetectProcessManager.class), mock(MlMemoryTracker.class), mock(Client.class), + new IndexNameExpressionResolver()); OpenJobAction.JobParams params = new OpenJobAction.JobParams("missing_job_field"); assertEquals(TransportOpenJobAction.AWAITING_MIGRATION, executor.getAssignment(params, mock(ClusterState.class))); @@ -178,7 +181,8 @@ public void testGetAssignment_GivenUnavailableIndicesWithLazyNode() { csBuilder.routingTable(routingTable.build()); TransportOpenJobAction.OpenJobPersistentTasksExecutor executor = new TransportOpenJobAction.OpenJobPersistentTasksExecutor( - settings, clusterService, mock(AutodetectProcessManager.class), mock(MlMemoryTracker.class), mock(Client.class)); + settings, clusterService, mock(AutodetectProcessManager.class), mock(MlMemoryTracker.class), mock(Client.class), + new IndexNameExpressionResolver()); OpenJobAction.JobParams params = new OpenJobAction.JobParams("unavailable_index_with_lazy_node"); params.setJob(mock(Job.class)); @@ -204,7 +208,8 @@ public void testGetAssignment_GivenLazyJobAndNoGlobalLazyNodes() { csBuilder.routingTable(routingTable.build()); TransportOpenJobAction.OpenJobPersistentTasksExecutor executor = new TransportOpenJobAction.OpenJobPersistentTasksExecutor( - settings, clusterService, mock(AutodetectProcessManager.class), mock(MlMemoryTracker.class), mock(Client.class)); + settings, clusterService, mock(AutodetectProcessManager.class), mock(MlMemoryTracker.class), mock(Client.class), + new IndexNameExpressionResolver()); Job job = mock(Job.class); when(job.allowLazyOpen()).thenReturn(true); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportStartDataFrameAnalyticsActionTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportStartDataFrameAnalyticsActionTests.java index b190835202b23..2dbdb3a8bb715 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportStartDataFrameAnalyticsActionTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportStartDataFrameAnalyticsActionTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.IndexRoutingTable; import org.elasticsearch.cluster.routing.IndexShardRoutingTable; @@ -58,7 +59,9 @@ public void testVerifyIndicesPrimaryShardsAreActive() { csBuilder.metaData(metaData); ClusterState cs = csBuilder.build(); - assertThat(TransportStartDataFrameAnalyticsAction.verifyIndicesPrimaryShardsAreActive(cs, indexName), empty()); + assertThat( + TransportStartDataFrameAnalyticsAction.verifyIndicesPrimaryShardsAreActive(cs, new IndexNameExpressionResolver(), indexName), + empty()); metaData = new MetaData.Builder(cs.metaData()); routingTable = new RoutingTable.Builder(cs.routingTable()); @@ -76,7 +79,8 @@ public void testVerifyIndicesPrimaryShardsAreActive() { csBuilder.routingTable(routingTable.build()); csBuilder.metaData(metaData); - List result = TransportStartDataFrameAnalyticsAction.verifyIndicesPrimaryShardsAreActive(csBuilder.build(), indexName); + List result = TransportStartDataFrameAnalyticsAction.verifyIndicesPrimaryShardsAreActive(csBuilder.build(), + new IndexNameExpressionResolver(), indexName); assertThat(result, contains(indexName)); } } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java index 0bd08bb360394..9c1c0f8aa2f4c 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java @@ -7,6 +7,7 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.client.OriginSettingClient; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.routing.OperationRouting; import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; @@ -101,7 +102,7 @@ public void createComponents() throws Exception { Settings.Builder builder = Settings.builder() .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueSeconds(1)); AnomalyDetectionAuditor auditor = new AnomalyDetectionAuditor(client(), "test_node"); - jobResultsProvider = new JobResultsProvider(client(), builder.build()); + jobResultsProvider = new JobResultsProvider(client(), builder.build(), new IndexNameExpressionResolver()); renormalizer = mock(Renormalizer.class); process = mock(AutodetectProcess.class); capturedUpdateModelSnapshotOnJobRequests = new ArrayList<>(); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java index 6ae60f714be74..d6725832f688e 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.ml.integration; import org.elasticsearch.client.OriginSettingClient; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.routing.OperationRouting; import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; import org.elasticsearch.cluster.service.ClusterApplierService; @@ -60,7 +61,7 @@ public void createComponents() { OriginSettingClient originSettingClient = new OriginSettingClient(client(), ClientHelper.ML_ORIGIN); ResultsPersisterService resultsPersisterService = new ResultsPersisterService(originSettingClient, clusterService, settings); - jobResultsProvider = new JobResultsProvider(client(), settings); + jobResultsProvider = new JobResultsProvider(client(), settings, new IndexNameExpressionResolver()); jobResultsPersister = new JobResultsPersister( originSettingClient, resultsPersisterService, new AnomalyDetectionAuditor(client(), "test_node")); } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java index 3fa6a8721bd5d..b16ad8456c064 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java @@ -19,6 +19,7 @@ import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.client.OriginSettingClient; import org.elasticsearch.cluster.metadata.AliasMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.cluster.routing.OperationRouting; import org.elasticsearch.cluster.routing.UnassignedInfo; @@ -107,7 +108,7 @@ public class JobResultsProviderIT extends MlSingleNodeTestCase { public void createComponents() throws Exception { Settings.Builder builder = Settings.builder() .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueSeconds(1)); - jobProvider = new JobResultsProvider(client(), builder.build()); + jobProvider = new JobResultsProvider(client(), builder.build(), new IndexNameExpressionResolver()); ThreadPool tp = mock(ThreadPool.class); ClusterSettings clusterSettings = new ClusterSettings(builder.build(), new HashSet<>(Arrays.asList(InferenceProcessor.MAX_INFERENCE_PROCESSORS, diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlConfigMigratorIT.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlConfigMigratorIT.java index 69b82ef984671..e96c3e696b3af 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlConfigMigratorIT.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlConfigMigratorIT.java @@ -18,6 +18,7 @@ import org.elasticsearch.cluster.ClusterStateUpdateTask; import org.elasticsearch.cluster.metadata.AliasOrIndex; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.IndexRoutingTable; import org.elasticsearch.cluster.routing.IndexShardRoutingTable; @@ -72,6 +73,7 @@ public class MlConfigMigratorIT extends MlSingleNodeTestCase { + private final IndexNameExpressionResolver expressionResolver = new IndexNameExpressionResolver(); private ClusterService clusterService; @Before @@ -103,7 +105,7 @@ public void testWriteConfigToIndex() throws InterruptedException { // put a job representing a previously migrated job blockingCall(actionListener -> jobConfigProvider.putJob(migratedJob, actionListener), indexResponseHolder, exceptionHolder); - MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService); + MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService, expressionResolver); AtomicReference> failedIdsHolder = new AtomicReference<>(); Job foo = buildJobBuilder("foo").build(); @@ -166,7 +168,7 @@ public void testMigrateConfigs() throws InterruptedException, IOException { AtomicReference responseHolder = new AtomicReference<>(); // do the migration - MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService); + MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService, expressionResolver); // the first time this is called mlmetadata will be snap-shotted blockingCall(actionListener -> mlConfigMigrator.migrateConfigs(clusterState, actionListener), responseHolder, exceptionHolder); @@ -218,7 +220,7 @@ public void testExistingSnapshotDoesNotBlockMigration() throws InterruptedExcept // index a doc with the same Id as the config snapshot PlainActionFuture future = PlainActionFuture.newFuture(); - AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client(), clusterService.state(), future); + AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client(), clusterService.state(), expressionResolver, future); future.actionGet(); IndexRequest indexRequest = new IndexRequest(AnomalyDetectorsIndex.jobStateIndexWriteAlias()).id("ml-config") @@ -238,7 +240,7 @@ public void testExistingSnapshotDoesNotBlockMigration() throws InterruptedExcept AtomicReference responseHolder = new AtomicReference<>(); // do the migration - MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService); + MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService, expressionResolver); // writing the snapshot should fail because the doc already exists // in which case the migration should continue blockingCall(actionListener -> mlConfigMigrator.migrateConfigs(clusterState, actionListener), @@ -293,7 +295,7 @@ public void testMigrateConfigs_GivenLargeNumberOfJobsAndDatafeeds() throws Inter AtomicReference responseHolder = new AtomicReference<>(); // do the migration - MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService); + MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService, expressionResolver); blockingCall(actionListener -> mlConfigMigrator.migrateConfigs(clusterState, actionListener), responseHolder, exceptionHolder); @@ -331,7 +333,7 @@ public void testMigrateConfigs_GivenNoJobsOrDatafeeds() throws InterruptedExcept AtomicReference responseHolder = new AtomicReference<>(); // do the migration - MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService); + MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService, expressionResolver); blockingCall(actionListener -> mlConfigMigrator.migrateConfigs(clusterState, actionListener), responseHolder, exceptionHolder); @@ -364,7 +366,7 @@ public void testMigrateConfigsWithoutTasks_GivenMigrationIsDisabled() throws Int AtomicReference responseHolder = new AtomicReference<>(); // do the migration - MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(settings, client(), clusterService); + MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(settings, client(), clusterService, expressionResolver); blockingCall(actionListener -> mlConfigMigrator.migrateConfigs(clusterState, actionListener), responseHolder, exceptionHolder); @@ -436,7 +438,7 @@ public void testConfigIndexIsCreated() throws Exception { AtomicReference exceptionHolder = new AtomicReference<>(); AtomicReference responseHolder = new AtomicReference<>(); - MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService); + MlConfigMigrator mlConfigMigrator = new MlConfigMigrator(nodeSettings(), client(), clusterService, expressionResolver); // if the cluster state has a job config and the index does not // exist it should be created diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProviderTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProviderTests.java index c2619f56e5187..86f21d2c56f45 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProviderTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProviderTests.java @@ -19,6 +19,7 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.document.DocumentField; @@ -893,7 +894,7 @@ public void testCreateTermFieldsMapping() throws IOException { } private JobResultsProvider createProvider(Client client) { - return new JobResultsProvider(client, Settings.EMPTY); + return new JobResultsProvider(client, Settings.EMPTY, new IndexNameExpressionResolver()); } private static SearchResponse createSearchResponse(List> source) throws IOException { diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java index 09a92e57d0432..92e18a6e6430f 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.AliasOrIndex; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedConsumer; @@ -689,7 +690,8 @@ private AutodetectProcessManager createSpyManager(Settings settings) { private AutodetectProcessManager createManager(Settings settings) { return new AutodetectProcessManager(environment, settings, client, threadPool, new NamedXContentRegistry(Collections.emptyList()), auditor, clusterService, jobManager, jobResultsProvider, - jobResultsPersister, jobDataCountsPersister, autodetectFactory, normalizerFactory, nativeStorageProvider); + jobResultsPersister, jobDataCountsPersister, autodetectFactory, normalizerFactory, nativeStorageProvider, + new IndexNameExpressionResolver()); } private AutodetectProcessManager createSpyManagerAndCallProcessData(String jobId) { AutodetectProcessManager manager = createSpyManager(); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java index f5f777bc668a4..068dd2a1be9bd 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java @@ -125,7 +125,8 @@ public Collection createGuiceModules() { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { if (enabled == false) { return Collections.emptyList(); } @@ -141,7 +142,8 @@ public Collection createComponents(Client client, ClusterService cluster Set collectors = new HashSet<>(); collectors.add(new IndexStatsCollector(clusterService, getLicenseState(), client)); - collectors.add(new ClusterStatsCollector(settings, clusterService, getLicenseState(), client, getLicenseService())); + collectors.add( + new ClusterStatsCollector(settings, clusterService, getLicenseState(), client, getLicenseService(), expressionResolver)); collectors.add(new ShardsCollector(clusterService, getLicenseState())); collectors.add(new NodeStatsCollector(clusterService, getLicenseState(), client)); collectors.add(new IndexRecoveryCollector(clusterService, getLicenseState(), client)); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java index 704fbea489140..1beb7fc78ef24 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java @@ -64,16 +64,8 @@ public ClusterStatsCollector(final Settings settings, final ClusterService clusterService, final XPackLicenseState licenseState, final Client client, - final LicenseService licenseService) { - this(settings, clusterService, licenseState, client, licenseService, new IndexNameExpressionResolver()); - } - - ClusterStatsCollector(final Settings settings, - final ClusterService clusterService, - final XPackLicenseState licenseState, - final Client client, - final LicenseService licenseService, - final IndexNameExpressionResolver indexNameExpressionResolver) { + final LicenseService licenseService, + final IndexNameExpressionResolver indexNameExpressionResolver) { super(ClusterStatsMonitoringDoc.TYPE, clusterService, CLUSTER_STATS_TIMEOUT, licenseState); this.settings = settings; this.client = client; diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java index cbaa7172be998..e88d80c520da8 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java @@ -67,14 +67,16 @@ public void setUp() throws Exception { public void testShouldCollectReturnsFalseIfNotMaster() { final ClusterStatsCollector collector = - new ClusterStatsCollector(Settings.EMPTY, clusterService, licenseState, client, licenseService); + new ClusterStatsCollector(Settings.EMPTY, clusterService, licenseState, client, licenseService, + new IndexNameExpressionResolver()); assertThat(collector.shouldCollect(false), is(false)); } public void testShouldCollectReturnsTrue() { final ClusterStatsCollector collector = - new ClusterStatsCollector(Settings.EMPTY, clusterService, licenseState, client, licenseService); + new ClusterStatsCollector(Settings.EMPTY, clusterService, licenseState, client, licenseService, + new IndexNameExpressionResolver()); assertThat(collector.shouldCollect(true), is(true)); } diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java index 101b82f592d72..16d9715a928a6 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java @@ -109,7 +109,8 @@ public Rollup(Settings settings) { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { return emptyList(); } @@ -181,7 +182,8 @@ public List> getExecutorBuilders(Settings settings) { public List> getPersistentTasksExecutor(ClusterService clusterService, ThreadPool threadPool, Client client, - SettingsModule settingsModule) { + SettingsModule settingsModule, + IndexNameExpressionResolver expressionResolver) { if (enabled == false || transportClientMode ) { return emptyList(); } diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupIndexCapsAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupIndexCapsAction.java index 7c8df1fbb47d0..7a8afcb914559 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupIndexCapsAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupIndexCapsAction.java @@ -31,19 +31,20 @@ public class TransportGetRollupIndexCapsAction extends HandledTransportAction { private final ClusterService clusterService; + private final IndexNameExpressionResolver resolver; @Inject public TransportGetRollupIndexCapsAction(TransportService transportService, ClusterService clusterService, - ActionFilters actionFilters) { + ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { super(GetRollupIndexCapsAction.NAME, transportService, actionFilters, GetRollupIndexCapsAction.Request::new); this.clusterService = clusterService; + this.resolver = indexNameExpressionResolver; } @Override protected void doExecute(Task task, GetRollupIndexCapsAction.Request request, ActionListener listener) { - IndexNameExpressionResolver resolver = new IndexNameExpressionResolver(); String[] indices = resolver.concreteIndexNames(clusterService.state(), request.indicesOptions(), request.indices()); Map allCaps = getCapsByRollupIndex(Arrays.asList(indices), diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportRollupSearchAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportRollupSearchAction.java index 2a1308353d6ad..f7964dc9e45e5 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportRollupSearchAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportRollupSearchAction.java @@ -78,18 +78,20 @@ public class TransportRollupSearchAction extends TransportAction listener) { - IndexNameExpressionResolver resolver = new IndexNameExpressionResolver(); String[] indices = resolver.concreteIndexNames(clusterService.state(), request.indicesOptions(), request.indices()); RollupSearchContext rollupSearchContext = separateIndices(indices, clusterService.state().getMetaData().indices()); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java index e97b547d393f9..cc748ce5af151 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java @@ -384,9 +384,11 @@ protected Clock getClock() { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { try { - return createComponents(client, threadPool, clusterService, resourceWatcherService, scriptService, xContentRegistry); + return createComponents(client, threadPool, clusterService, resourceWatcherService, scriptService, xContentRegistry, + expressionResolver); } catch (final Exception e) { throw new IllegalStateException("security initialization failed", e); } @@ -395,7 +397,8 @@ public Collection createComponents(Client client, ClusterService cluster // pkg private for testing - tests want to pass in their set of extensions hence we are not using the extension service directly Collection createComponents(Client client, ThreadPool threadPool, ClusterService clusterService, ResourceWatcherService resourceWatcherService, ScriptService scriptService, - NamedXContentRegistry xContentRegistry) throws Exception { + NamedXContentRegistry xContentRegistry, + IndexNameExpressionResolver expressionResolver) throws Exception { if (enabled == false) { return Collections.emptyList(); } @@ -505,7 +508,7 @@ Collection createComponents(Client client, ThreadPool threadPool, Cluste final AuthorizationService authzService = new AuthorizationService(settings, allRolesStore, clusterService, auditTrailService, failureHandler, threadPool, anonymousUser, getAuthorizationEngine(), requestInterceptors, - getLicenseState()); + getLicenseState(), expressionResolver); components.add(nativeRolesStore); // used by roles actions components.add(reservedRolesStore); // used by roles actions diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java index a9a971a091422..40f5e4f711ada 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java @@ -23,6 +23,7 @@ import org.elasticsearch.action.support.GroupedActionListener; import org.elasticsearch.action.support.replication.TransportReplicationAction.ConcreteShardRequest; import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Nullable; @@ -115,10 +116,11 @@ public class AuthorizationService { public AuthorizationService(Settings settings, CompositeRolesStore rolesStore, ClusterService clusterService, AuditTrailService auditTrail, AuthenticationFailureHandler authcFailureHandler, ThreadPool threadPool, AnonymousUser anonymousUser, @Nullable AuthorizationEngine authorizationEngine, - Set requestInterceptors, XPackLicenseState licenseState) { + Set requestInterceptors, XPackLicenseState licenseState, + IndexNameExpressionResolver resolver) { this.clusterService = clusterService; this.auditTrail = auditTrail; - this.indicesAndAliasesResolver = new IndicesAndAliasesResolver(settings, clusterService); + this.indicesAndAliasesResolver = new IndicesAndAliasesResolver(settings, clusterService, resolver); this.authcFailureHandler = authcFailureHandler; this.threadContext = threadPool.getThreadContext(); this.anonymousUser = anonymousUser; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java index b8e994ccf9c78..42e547cdfa05c 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java @@ -55,8 +55,8 @@ class IndicesAndAliasesResolver { private final IndexNameExpressionResolver nameExpressionResolver; private final RemoteClusterResolver remoteClusterResolver; - IndicesAndAliasesResolver(Settings settings, ClusterService clusterService) { - this.nameExpressionResolver = new IndexNameExpressionResolver(); + IndicesAndAliasesResolver(Settings settings, ClusterService clusterService, IndexNameExpressionResolver resolver) { + this.nameExpressionResolver = resolver; this.remoteClusterResolver = new RemoteClusterResolver(settings, clusterService.getClusterSettings()); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java index 6b3ef36bc4bf9..9b35764032c8c 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; @@ -133,7 +134,7 @@ protected SSLService getSslService() { when(client.threadPool()).thenReturn(threadPool); when(client.settings()).thenReturn(settings); return security.createComponents(client, threadPool, clusterService, mock(ResourceWatcherService.class), mock(ScriptService.class), - xContentRegistry()); + xContentRegistry(), new IndexNameExpressionResolver()); } private static T findComponent(Class type, Collection components) { diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index 2d0b5a391e0a1..ba0150c7fd4e6 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -74,6 +74,7 @@ import org.elasticsearch.cluster.metadata.AliasMetaData; import org.elasticsearch.cluster.metadata.AliasOrIndex; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterService; @@ -240,7 +241,7 @@ public void setup() { roleMap.put(ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName(), ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR); authorizationService = new AuthorizationService(settings, rolesStore, clusterService, auditTrail, new DefaultAuthenticationFailureHandler(Collections.emptyMap()), threadPool, new AnonymousUser(settings), null, - Collections.emptySet(), new XPackLicenseState(settings)); + Collections.emptySet(), new XPackLicenseState(settings), new IndexNameExpressionResolver()); } private void authorize(Authentication authentication, String action, TransportRequest request) { @@ -681,7 +682,7 @@ public void testDenialForAnonymousUser() throws IOException { final AnonymousUser anonymousUser = new AnonymousUser(settings); authorizationService = new AuthorizationService(settings, rolesStore, clusterService, auditTrail, new DefaultAuthenticationFailureHandler(Collections.emptyMap()), threadPool, anonymousUser, null, Collections.emptySet(), - new XPackLicenseState(settings)); + new XPackLicenseState(settings), new IndexNameExpressionResolver()); RoleDescriptor role = new RoleDescriptor("a_all", null, new IndicesPrivileges[] { IndicesPrivileges.builder().indices("a").privileges("all").build() }, null); @@ -709,7 +710,7 @@ public void testDenialForAnonymousUserAuthorizationExceptionDisabled() throws IO final Authentication authentication = createAuthentication(new AnonymousUser(settings)); authorizationService = new AuthorizationService(settings, rolesStore, clusterService, auditTrail, new DefaultAuthenticationFailureHandler(Collections.emptyMap()), threadPool, new AnonymousUser(settings), null, - Collections.emptySet(), new XPackLicenseState(settings)); + Collections.emptySet(), new XPackLicenseState(settings), new IndexNameExpressionResolver()); RoleDescriptor role = new RoleDescriptor("a_all", null, new IndicesPrivileges[]{IndicesPrivileges.builder().indices("a").privileges("all").build()}, null); @@ -1451,7 +1452,7 @@ public void getUserPrivileges(Authentication authentication, AuthorizationInfo a when(licenseState.isAuthorizationEngineAllowed()).thenReturn(true); authorizationService = new AuthorizationService(Settings.EMPTY, rolesStore, clusterService, auditTrail, new DefaultAuthenticationFailureHandler(Collections.emptyMap()), threadPool, new AnonymousUser(Settings.EMPTY), - engine, Collections.emptySet(), licenseState); + engine, Collections.emptySet(), licenseState, new IndexNameExpressionResolver()); Authentication authentication; try (ThreadContext.StoredContext ignore = threadContext.stashContext()) { authentication = createAuthentication(new User("test user", "a_all")); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java index 5c6a67583da1e..2242a232e8c10 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java @@ -199,7 +199,7 @@ public void setup() { ClusterService clusterService = mock(ClusterService.class); when(clusterService.getClusterSettings()).thenReturn(new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)); - defaultIndicesResolver = new IndicesAndAliasesResolver(settings, clusterService); + defaultIndicesResolver = new IndicesAndAliasesResolver(settings, clusterService, new IndexNameExpressionResolver()); } public void testDashIndicesAreAllowedInShardLevelRequests() { diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java index f9e043af9ee7d..364948dd8d40b 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java @@ -88,7 +88,8 @@ public SqlPlugin(Settings settings) { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { return createComponents(client, clusterService.getClusterName().value(), namedWriteableRegistry); } diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java index 4889aec19a9cf..3ead6504d7daf 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java @@ -246,7 +246,8 @@ public Collection createComponents( NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, - NamedWriteableRegistry namedWriteableRegistry + NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver ) { if (enabled == false || transportClientMode) { return emptyList(); @@ -293,7 +294,8 @@ public List> getPersistentTasksExecutor( ClusterService clusterService, ThreadPool threadPool, Client client, - SettingsModule settingsModule + SettingsModule settingsModule, + IndexNameExpressionResolver expressionResolver ) { if (enabled == false || transportClientMode) { return emptyList(); @@ -302,9 +304,8 @@ public List> getPersistentTasksExecutor( // the transform services should have been created assert transformServices.get() != null; - return Collections.singletonList( - new TransformPersistentTasksExecutor(client, transformServices.get(), threadPool, clusterService, settingsModule.getSettings()) - ); + return Collections.singletonList(new TransformPersistentTasksExecutor(client, transformServices.get(), threadPool, clusterService, + settingsModule.getSettings(), expressionResolver)); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/TransformPersistentTasksExecutor.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/TransformPersistentTasksExecutor.java index 93c4e733b0256..1bc71ecb63499 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/TransformPersistentTasksExecutor.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/TransformPersistentTasksExecutor.java @@ -62,6 +62,7 @@ public class TransformPersistentTasksExecutor extends PersistentTasksExecutor unavailableIndices = verifyIndicesPrimaryShardsAreActive(clusterState); + List unavailableIndices = verifyIndicesPrimaryShardsAreActive(clusterState, resolver); if (unavailableIndices.size() != 0) { String reason = "Not starting transform [" + params.getId() @@ -113,8 +116,7 @@ public PersistentTasksCustomMetaData.Assignment getAssignment(TransformTaskParam return discoveryNode == null ? NO_NODE_FOUND : new PersistentTasksCustomMetaData.Assignment(discoveryNode.getId(), ""); } - static List verifyIndicesPrimaryShardsAreActive(ClusterState clusterState) { - IndexNameExpressionResolver resolver = new IndexNameExpressionResolver(); + static List verifyIndicesPrimaryShardsAreActive(ClusterState clusterState, IndexNameExpressionResolver resolver) { String[] indices = resolver.concreteIndexNames( clusterState, IndicesOptions.lenientExpandOpen(), diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/TransformPersistentTasksExecutorTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/TransformPersistentTasksExecutorTests.java index 9435a3a7d4fd2..99d8d4347db75 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/TransformPersistentTasksExecutorTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/TransformPersistentTasksExecutorTests.java @@ -11,6 +11,7 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeRole; @@ -148,7 +149,8 @@ public void testNodeVersionAssignment() { transformServices, mock(ThreadPool.class), clusterService, - Settings.EMPTY + Settings.EMPTY, + new IndexNameExpressionResolver() ); assertThat( @@ -234,7 +236,8 @@ public void testDoNotSelectOldNodes() { transformServices, mock(ThreadPool.class), clusterService, - Settings.EMPTY + Settings.EMPTY, + new IndexNameExpressionResolver() ); // old-data-node-1 prevents assignment @@ -279,7 +282,8 @@ public void testVerifyIndicesPrimaryShardsAreActive() { csBuilder.metaData(metaData); ClusterState cs = csBuilder.build(); - assertEquals(0, TransformPersistentTasksExecutor.verifyIndicesPrimaryShardsAreActive(cs).size()); + assertEquals(0, + TransformPersistentTasksExecutor.verifyIndicesPrimaryShardsAreActive(cs, new IndexNameExpressionResolver()).size()); metaData = new MetaData.Builder(cs.metaData()); routingTable = new RoutingTable.Builder(cs.routingTable()); @@ -303,7 +307,8 @@ public void testVerifyIndicesPrimaryShardsAreActive() { csBuilder.routingTable(routingTable.build()); csBuilder.metaData(metaData); - List result = TransformPersistentTasksExecutor.verifyIndicesPrimaryShardsAreActive(csBuilder.build()); + List result = + TransformPersistentTasksExecutor.verifyIndicesPrimaryShardsAreActive(csBuilder.build(), new IndexNameExpressionResolver()); assertEquals(1, result.size()); assertEquals(indexToRemove, result.get(0)); } diff --git a/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePlugin.java b/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePlugin.java index 7fefc0fcfed56..98aa4eefdbcc0 100644 --- a/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePlugin.java +++ b/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePlugin.java @@ -10,6 +10,7 @@ import org.elasticsearch.client.Client; import org.elasticsearch.cluster.coordination.CoordinationMetaData.VotingConfiguration; import org.elasticsearch.cluster.coordination.CoordinationState.VoteCollection; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeRole; import org.elasticsearch.cluster.service.ClusterService; @@ -102,7 +103,8 @@ public Set getRoles() { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { this.threadPool.set(threadPool); return Collections.emptyList(); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index 2d11fa0e6474c..d927e63ba2c08 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -253,7 +253,8 @@ public Watcher(final Settings settings) { public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, - NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver expressionResolver) { if (enabled == false) { return Collections.emptyList(); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java index 5141854f9155e..f3882872a31c5 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.watcher; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.index.IndexModule; @@ -76,12 +77,12 @@ public void testWatcherDisabledTests() throws Exception { AnalysisRegistry registry = new AnalysisRegistry(TestEnvironment.newEnvironment(settings), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap()); IndexModule indexModule = new IndexModule(indexSettings, registry, new InternalEngineFactory(), Collections.emptyMap(), - () -> true); + () -> true, new IndexNameExpressionResolver()); // this will trip an assertion if the watcher indexing operation listener is null (which it is) but we try to add it watcher.onIndexModule(indexModule); // also no component creation if not enabled - assertThat(watcher.createComponents(null, null, null, null, null, null, null, null, null), hasSize(0)); + assertThat(watcher.createComponents(null, null, null, null, null, null, null, null, null, null), hasSize(0)); watcher.close(); }