From 7941f4a47e4670fba74516952916278c0ac68b05 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 16 Apr 2020 15:40:28 +0100 Subject: [PATCH] Add RepositoriesService to createComponents() args (#54814) Today we pass the `RepositoriesService` to the searchable snapshots plugin during the initialization of the `RepositoryModule`, forcing the plugin to be a `RepositoryPlugin` even though it does not implement any repositories. After discussion we decided it best for now to pass this in via `Plugin#createComponents` instead, pending some future work in which plugins can depend on services more dynamically. --- .../analysis/common/CommonAnalysisPlugin.java | 5 +++- .../PredicateTokenScriptFilterTests.java | 2 +- .../ScriptedConditionTokenFilterTests.java | 2 +- .../index/reindex/ReindexPlugin.java | 4 ++- .../ReindexFromRemoteWithAuthTests.java | 5 +++- .../elasticsearch/systemd/SystemdPlugin.java | 5 +++- .../systemd/SystemdPluginTests.java | 10 +++---- .../http/ContextAndHeaderTransportIT.java | 5 +++- .../java/org/elasticsearch/node/Node.java | 5 +++- .../org/elasticsearch/plugins/Plugin.java | 7 ++++- .../plugins/RepositoryPlugin.java | 15 +++-------- .../repositories/RepositoriesModule.java | 2 -- .../action/ingest/AsyncIngestProcessorIT.java | 5 +++- .../elasticsearch/cluster/ClusterStateIT.java | 5 +++- .../cluster/SimpleClusterStateIT.java | 5 +++- .../metadata/TemplateUpgradeServiceIT.java | 7 +++-- .../elasticsearch/index/FinalPipelineIT.java | 5 +++- .../xpack/analytics/AnalyticsPlugin.java | 4 ++- .../xpack/search/AsyncSearch.java | 4 ++- .../java/org/elasticsearch/xpack/ccr/Ccr.java | 4 ++- .../elasticsearch/xpack/core/XPackPlugin.java | 4 ++- .../core/LocalStateCompositeXPackPlugin.java | 8 +++--- .../xpack/enrich/EnrichPlugin.java | 4 ++- .../xpack/eql/plugin/EqlPlugin.java | 3 ++- .../xpack/idp/IdentityProviderPlugin.java | 4 ++- .../xpack/ilm/IndexLifecycle.java | 4 ++- .../xpack/ilm/UpdateSettingsStepTests.java | 5 +++- .../xpack/ml/MachineLearning.java | 4 ++- .../xpack/monitoring/Monitoring.java | 4 ++- .../elasticsearch/xpack/rollup/Rollup.java | 4 ++- .../SearchableSnapshots.java | 26 ++++++++----------- .../xpack/security/Security.java | 4 ++- .../xpack/sql/plugin/SqlPlugin.java | 4 ++- .../xpack/transform/Transform.java | 4 ++- .../coordination/VotingOnlyNodePlugin.java | 4 ++- .../elasticsearch/xpack/watcher/Watcher.java | 4 ++- .../xpack/watcher/WatcherPluginTests.java | 2 +- 37 files changed, 128 insertions(+), 70 deletions(-) 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 05b92ef54d5..e375f3dea07 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 @@ -137,6 +137,7 @@ import org.elasticsearch.indices.analysis.PreBuiltCacheFactory.CachingStrategy; import org.elasticsearch.plugins.AnalysisPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.ScriptPlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ThreadPool; @@ -150,6 +151,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.function.Supplier; import static org.elasticsearch.plugins.AnalysisPlugin.requiresAnalysisSettings; @@ -164,7 +166,8 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { 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 91b33f7553e..4f3bed403d5 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 class PredicateTokenScriptFilterTests extends ESTokenStreamTestCase { }; CommonAnalysisPlugin plugin = new CommonAnalysisPlugin(); - plugin.createComponents(null, null, null, null, scriptService, null, null, null, null, null); + plugin.createComponents(null, null, null, null, scriptService, null, null, null, null, null, null); AnalysisModule module = new AnalysisModule(TestEnvironment.newEnvironment(settings), Collections.singletonList(plugin)); diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterTests.java index 823c30cd30c..2b5be939e12 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterTests.java @@ -71,7 +71,7 @@ public class ScriptedConditionTokenFilterTests extends ESTokenStreamTestCase { }; CommonAnalysisPlugin plugin = new CommonAnalysisPlugin(); - plugin.createComponents(null, null, null, null, scriptService, null, null, null, null, null); + plugin.createComponents(null, null, null, null, scriptService, null, null, null, null, null, null); AnalysisModule module = new AnalysisModule(TestEnvironment.newEnvironment(settings), Collections.singletonList(plugin)); diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexPlugin.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexPlugin.java index c49b2cce922..99ea1334d0e 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexPlugin.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexPlugin.java @@ -36,6 +36,7 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -85,7 +86,8 @@ public class ReindexPlugin extends Plugin implements ActionPlugin { ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { 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 f1d363da5cd..74033cda742 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 @@ -45,6 +45,7 @@ import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.http.HttpInfo; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestHeaderDefinition; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.script.ScriptService; @@ -60,6 +61,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.function.Supplier; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonList; @@ -154,7 +156,8 @@ public class ReindexFromRemoteWithAuthTests extends ESSingleNodeTestCase { ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { 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 1262a36a03a..1a1d334e236 100644 --- a/modules/systemd/src/main/java/org/elasticsearch/systemd/SystemdPlugin.java +++ b/modules/systemd/src/main/java/org/elasticsearch/systemd/SystemdPlugin.java @@ -32,6 +32,7 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.plugins.ClusterPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.Scheduler; import org.elasticsearch.threadpool.ThreadPool; @@ -39,6 +40,7 @@ import org.elasticsearch.watcher.ResourceWatcherService; import java.util.Collection; import java.util.Collections; +import java.util.function.Supplier; public class SystemdPlugin extends Plugin implements ClusterPlugin { @@ -90,7 +92,8 @@ public class SystemdPlugin extends Plugin implements ClusterPlugin { final Environment environment, final NodeEnvironment nodeEnvironment, final NamedWriteableRegistry namedWriteableRegistry, - final IndexNameExpressionResolver expressionResolver) { + final IndexNameExpressionResolver expressionResolver, + final Supplier repositoriesServiceSupplier) { 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 75fa4541670..9c52f9c20bd 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, null); + plugin.createComponents(null, null, threadPool, null, 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, null); + plugin.createComponents(null, null, threadPool, null, 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, null); + plugin.createComponents(null, null, threadPool, null, 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, null); + plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null, null); assertFalse(plugin.isEnabled()); assertNull(plugin.extender); } @@ -181,7 +181,7 @@ public class SystemdPluginTests extends ESTestCase { } }; - plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null); + plugin.createComponents(null, null, threadPool, null, 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 5b3b13022ef..88fc532342f 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 @@ -51,6 +51,7 @@ import org.elasticsearch.index.query.TermsQueryBuilder; import org.elasticsearch.indices.TermsLookup; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestHeaderDefinition; import org.elasticsearch.script.ScriptService; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; @@ -67,6 +68,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.Supplier; import static java.util.Collections.singletonList; import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; @@ -301,7 +303,8 @@ public class ContextAndHeaderTransportIT extends HttpSmokeTestCase { ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver indexNameExpressionResolver) { + IndexNameExpressionResolver indexNameExpressionResolver, + Supplier repositoriesServiceSupplier) { loggingFilter.set(new LoggingFilter(threadPool)); return Collections.emptyList(); } diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index 33952656740..bc7b1b143c0 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -477,10 +477,12 @@ public class Node implements Closeable { systemIndexDescriptors, forbidPrivateIndexSettings); + final SetOnce repositoriesServiceReference = new SetOnce<>(); Collection pluginComponents = pluginsService.filterPlugins(Plugin.class).stream() .flatMap(p -> p.createComponents(client, clusterService, threadPool, resourceWatcherService, scriptService, xContentRegistry, environment, nodeEnvironment, - namedWriteableRegistry, clusterModule.getIndexNameExpressionResolver()).stream()) + namedWriteableRegistry, clusterModule.getIndexNameExpressionResolver(), + repositoriesServiceReference::get).stream()) .collect(Collectors.toList()); ActionModule actionModule = new ActionModule(false, settings, clusterModule.getIndexNameExpressionResolver(), @@ -517,6 +519,7 @@ public class Node implements Closeable { RepositoriesModule repositoriesModule = new RepositoriesModule(this.environment, pluginsService.filterPlugins(RepositoryPlugin.class), transportService, clusterService, threadPool, xContentRegistry); RepositoriesService repositoryService = repositoriesModule.getRepositoryService(); + repositoriesServiceReference.set(repositoryService); SnapshotsService snapshotsService = new SnapshotsService(settings, clusterService, clusterModule.getIndexNameExpressionResolver(), repositoryService, threadPool); SnapshotShardsService snapshotShardsService = new SnapshotShardsService(settings, clusterService, repositoryService, diff --git a/server/src/main/java/org/elasticsearch/plugins/Plugin.java b/server/src/main/java/org/elasticsearch/plugins/Plugin.java index a606613ecdb..51abe3fcb3f 100644 --- a/server/src/main/java/org/elasticsearch/plugins/Plugin.java +++ b/server/src/main/java/org/elasticsearch/plugins/Plugin.java @@ -39,6 +39,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.IndexModule; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; @@ -52,6 +53,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.function.Supplier; import java.util.function.UnaryOperator; /** @@ -116,12 +118,15 @@ public abstract class Plugin implements Closeable { * @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 + * @param repositoriesServiceSupplier A supplier for the service that manages snapshot repositories; will return null when this method + * is called, but will return the repositories service once the node is initialized. */ public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver indexNameExpressionResolver) { + IndexNameExpressionResolver indexNameExpressionResolver, + Supplier repositoriesServiceSupplier) { return Collections.emptyList(); } diff --git a/server/src/main/java/org/elasticsearch/plugins/RepositoryPlugin.java b/server/src/main/java/org/elasticsearch/plugins/RepositoryPlugin.java index 4011834c31c..7891363adb0 100644 --- a/server/src/main/java/org/elasticsearch/plugins/RepositoryPlugin.java +++ b/server/src/main/java/org/elasticsearch/plugins/RepositoryPlugin.java @@ -19,15 +19,14 @@ package org.elasticsearch.plugins; -import java.util.Collections; -import java.util.Map; - import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.env.Environment; -import org.elasticsearch.repositories.RepositoriesModule; import org.elasticsearch.repositories.Repository; +import java.util.Collections; +import java.util.Map; + /** * An extension point for {@link Plugin} implementations to add custom snapshot repositories. */ @@ -60,12 +59,4 @@ public interface RepositoryPlugin { return Collections.emptyMap(); } - /** - * Passes down the current {@link RepositoriesModule} to repository plugins. - * - * @param module the current {@link RepositoriesModule} - */ - default void onRepositoriesModule(RepositoriesModule module) { - // NORELEASE - } } diff --git a/server/src/main/java/org/elasticsearch/repositories/RepositoriesModule.java b/server/src/main/java/org/elasticsearch/repositories/RepositoriesModule.java index 33bc5d42ed2..f87aab460fc 100644 --- a/server/src/main/java/org/elasticsearch/repositories/RepositoriesModule.java +++ b/server/src/main/java/org/elasticsearch/repositories/RepositoriesModule.java @@ -73,8 +73,6 @@ public final class RepositoriesModule { Map internalRepositoryTypes = Collections.unmodifiableMap(internalFactories); repositoriesService = new RepositoriesService(settings, clusterService, transportService, repositoryTypes, internalRepositoryTypes, threadPool); - - repoPlugins.forEach(rp -> rp.onRepositoriesModule(this)); } public RepositoriesService getRepositoryService() { 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 ec0296457aa..197a4ad77bf 100644 --- a/server/src/test/java/org/elasticsearch/action/ingest/AsyncIngestProcessorIT.java +++ b/server/src/test/java/org/elasticsearch/action/ingest/AsyncIngestProcessorIT.java @@ -38,6 +38,7 @@ import org.elasticsearch.ingest.IngestDocument; import org.elasticsearch.ingest.Processor; import org.elasticsearch.plugins.IngestPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.test.ESSingleNodeTestCase; import org.elasticsearch.threadpool.ThreadPool; @@ -48,6 +49,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.function.BiConsumer; +import java.util.function.Supplier; import static org.hamcrest.Matchers.equalTo; @@ -102,7 +104,8 @@ public class AsyncIngestProcessorIT extends ESSingleNodeTestCase { ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { 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 99492f0b5bf..4660639109f 100644 --- a/server/src/test/java/org/elasticsearch/cluster/ClusterStateIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/ClusterStateIT.java @@ -40,6 +40,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.threadpool.ThreadPool; @@ -56,6 +57,7 @@ import java.util.List; import java.util.Optional; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Supplier; import static org.elasticsearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK; import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST; @@ -224,7 +226,8 @@ public class ClusterStateIT extends ESIntegTestCase { final Environment environment, final NodeEnvironment nodeEnvironment, final NamedWriteableRegistry namedWriteableRegistry, - final IndexNameExpressionResolver indexNameExpressionResolver) { + final IndexNameExpressionResolver indexNameExpressionResolver, + final Supplier repositoriesServiceSupplier) { 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 7f3364d99d1..3cced4a7f71 100644 --- a/server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java @@ -49,6 +49,7 @@ import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.plugins.ClusterPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.hamcrest.CollectionAssertions; @@ -62,6 +63,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Supplier; import static org.elasticsearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; @@ -383,7 +385,8 @@ public class SimpleClusterStateIT extends ESIntegTestCase { final Environment environment, final NodeEnvironment nodeEnvironment, final NamedWriteableRegistry namedWriteableRegistry, - final IndexNameExpressionResolver expressionResolver) { + final IndexNameExpressionResolver expressionResolver, + final Supplier repositoriesServiceSupplier) { 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 a734a0fb33b..9322cae9aed 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/TemplateUpgradeServiceIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/TemplateUpgradeServiceIT.java @@ -30,6 +30,7 @@ import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.threadpool.ThreadPool; @@ -40,6 +41,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Supplier; import java.util.function.UnaryOperator; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; @@ -71,12 +73,13 @@ public class TemplateUpgradeServiceIT extends ESIntegTestCase { ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { 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, expressionResolver); + environment, nodeEnvironment, namedWriteableRegistry, expressionResolver, repositoriesServiceSupplier); } @Override diff --git a/server/src/test/java/org/elasticsearch/index/FinalPipelineIT.java b/server/src/test/java/org/elasticsearch/index/FinalPipelineIT.java index 8f0f648b3cb..2e24b49e9f4 100644 --- a/server/src/test/java/org/elasticsearch/index/FinalPipelineIT.java +++ b/server/src/test/java/org/elasticsearch/index/FinalPipelineIT.java @@ -45,6 +45,7 @@ import org.elasticsearch.ingest.PipelineConfiguration; import org.elasticsearch.ingest.Processor; import org.elasticsearch.plugins.IngestPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.script.ScriptService; import org.elasticsearch.test.ESIntegTestCase; @@ -57,6 +58,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.function.Supplier; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -245,7 +247,8 @@ public class FinalPipelineIT extends ESIntegTestCase { final Environment environment, final NodeEnvironment nodeEnvironment, final NamedWriteableRegistry namedWriteableRegistry, - final IndexNameExpressionResolver expressionResolver) { + final IndexNameExpressionResolver expressionResolver, + final Supplier repositoriesServiceSupplier) { return Collections.emptyList(); } diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsPlugin.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsPlugin.java index 6cbf01e4a59..c81a2f1daae 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsPlugin.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsPlugin.java @@ -25,6 +25,7 @@ import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.SearchPlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; @@ -54,6 +55,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.function.Supplier; import static java.util.Collections.singletonList; @@ -137,7 +139,7 @@ public class AnalyticsPlugin extends Plugin implements SearchPlugin, ActionPlugi public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver indexNameExpressionResolver) { + IndexNameExpressionResolver indexNameExpressionResolver, Supplier repositoriesServiceSupplier) { return singletonList(usage); } diff --git a/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/AsyncSearch.java b/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/AsyncSearch.java index 580f7d8a556..6412ea05505 100644 --- a/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/AsyncSearch.java +++ b/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/AsyncSearch.java @@ -23,6 +23,7 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -76,7 +77,8 @@ public final class AsyncSearch extends Plugin implements ActionPlugin { Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver indexNameExpressionResolver) { + IndexNameExpressionResolver indexNameExpressionResolver, + Supplier repositoriesServiceSupplier) { if (DiscoveryNode.isDataNode(environment.settings())) { // only data nodes should be eligible to run the maintenance service. AsyncSearchIndexService indexService = 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 071c4950058..7224ebf3197 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 @@ -40,6 +40,7 @@ import org.elasticsearch.plugins.EnginePlugin; import org.elasticsearch.plugins.PersistentTaskPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.RepositoryPlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.repositories.Repository; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; @@ -176,7 +177,8 @@ public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, E final Environment environment, final NodeEnvironment nodeEnvironment, final NamedWriteableRegistry namedWriteableRegistry, - final IndexNameExpressionResolver expressionResolver) { + final IndexNameExpressionResolver expressionResolver, + final Supplier repositoriesServiceSupplier) { this.client = client; if (enabled == false) { return emptyList(); 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 c316a755414..16522caf612 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 @@ -47,6 +47,7 @@ import org.elasticsearch.persistent.PersistentTaskParams; import org.elasticsearch.plugins.EnginePlugin; import org.elasticsearch.plugins.ExtensiblePlugin; import org.elasticsearch.plugins.RepositoryPlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.repositories.Repository; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; @@ -254,7 +255,8 @@ public class XPackPlugin extends XPackClientPlugin implements ExtensiblePlugin, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { List components = new ArrayList<>(); final SSLService sslService = new SSLService(environment); 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 d2de6b902d7..a423ebc30ca 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 @@ -60,6 +60,7 @@ import org.elasticsearch.plugins.PersistentTaskPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.RepositoryPlugin; import org.elasticsearch.plugins.ScriptPlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.repositories.Repository; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; @@ -152,14 +153,15 @@ public class LocalStateCompositeXPackPlugin extends XPackPlugin implements Scrip ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { List components = new ArrayList<>(); components.addAll(super.createComponents(client, clusterService, threadPool, resourceWatcherService, scriptService, - xContentRegistry, environment, nodeEnvironment, namedWriteableRegistry, expressionResolver)); + xContentRegistry, environment, nodeEnvironment, namedWriteableRegistry, expressionResolver, repositoriesServiceSupplier)); filterPlugins(Plugin.class).stream().forEach(p -> components.addAll(p.createComponents(client, clusterService, threadPool, resourceWatcherService, scriptService, - xContentRegistry, environment, nodeEnvironment, namedWriteableRegistry, expressionResolver)) + xContentRegistry, environment, nodeEnvironment, namedWriteableRegistry, expressionResolver, null)) ); return components; } 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 e6ea0279c2a..110c6304dfc 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 @@ -31,6 +31,7 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.IngestPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.SystemIndexPlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -199,7 +200,8 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier ) { if (enabled == false || transportClientMode) { return emptyList(); 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 c6f86b5105e..495829d15a0 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 @@ -25,6 +25,7 @@ import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -80,7 +81,7 @@ public class EqlPlugin 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, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, Supplier repositoriesServiceSupplier) { return createComponents(client, clusterService.getClusterName().value(), namedWriteableRegistry); } diff --git a/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/IdentityProviderPlugin.java b/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/IdentityProviderPlugin.java index 73f91788469..2e997c8b510 100644 --- a/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/IdentityProviderPlugin.java +++ b/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/IdentityProviderPlugin.java @@ -26,6 +26,7 @@ import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -86,7 +87,8 @@ public class IdentityProviderPlugin extends Plugin implements ActionPlugin { ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver indexNameExpressionResolver) { + IndexNameExpressionResolver indexNameExpressionResolver, + Supplier repositoriesServiceSupplier) { settings = environment.settings(); enabled = ENABLED_SETTING.get(settings); if (enabled == false) { 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 02c2008566d..ce2b58ec548 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 @@ -31,6 +31,7 @@ import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.IndexModule; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -190,7 +191,8 @@ public class IndexLifecycle extends Plugin implements ActionPlugin { ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { 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 39f6642f642..8efb62cb06e 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 @@ -21,6 +21,7 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.IndexModule; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.test.ESSingleNodeTestCase; import org.elasticsearch.threadpool.ThreadPool; @@ -35,6 +36,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.xpack.ilm.UpdateSettingsStepTests.SettingsTestingService.INVALID_VALUE; @@ -61,7 +63,8 @@ public class UpdateSettingsStepTests extends ESSingleNodeTestCase { ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { 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 929bef3d16a..777b2b373ff 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 @@ -50,6 +50,7 @@ import org.elasticsearch.plugins.IngestPlugin; import org.elasticsearch.plugins.PersistentTaskPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.SystemIndexPlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -518,7 +519,8 @@ public class MachineLearning extends Plugin implements SystemIndexPlugin, Analys ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver indexNameExpressionResolver) { + IndexNameExpressionResolver indexNameExpressionResolver, + Supplier repositoriesServiceSupplier) { if (enabled == false || transportClientMode) { // special holder for @link(MachineLearningFeatureSetUsage) which needs access to job manager, empty if ML is disabled return singletonList(new JobManagerHolder()); 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 01518092389..035ac57bacb 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 @@ -27,6 +27,7 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.ReloadablePlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -126,7 +127,8 @@ public class Monitoring extends Plugin implements ActionPlugin, ReloadablePlugin ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { if (enabled == false) { return Collections.emptyList(); } 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 16d9715a928..cb2082306df 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 @@ -27,6 +27,7 @@ import org.elasticsearch.persistent.PersistentTasksExecutor; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.PersistentTaskPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -110,7 +111,8 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { return emptyList(); } diff --git a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshots.java b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshots.java index 9f46911a59b..e23a8e7876a 100644 --- a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshots.java +++ b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshots.java @@ -39,8 +39,6 @@ import org.elasticsearch.plugins.ClusterPlugin; import org.elasticsearch.plugins.EnginePlugin; import org.elasticsearch.plugins.IndexStorePlugin; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.plugins.RepositoryPlugin; -import org.elasticsearch.repositories.RepositoriesModule; import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; @@ -75,7 +73,7 @@ import static org.elasticsearch.index.IndexModule.INDEX_STORE_TYPE_SETTING; /** * Plugin for Searchable Snapshots feature */ -public class SearchableSnapshots extends Plugin implements IndexStorePlugin, RepositoryPlugin, EnginePlugin, ActionPlugin, ClusterPlugin { +public class SearchableSnapshots extends Plugin implements IndexStorePlugin, EnginePlugin, ActionPlugin, ClusterPlugin { private static final boolean SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED; @@ -136,13 +134,11 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Rep public static final String SNAPSHOT_DIRECTORY_FACTORY_KEY = "snapshot"; - private final SetOnce repositoriesService; - private final SetOnce cacheService; + private volatile Supplier repositoriesServiceSupplier; + private final SetOnce cacheService = new SetOnce<>(); private final Settings settings; public SearchableSnapshots(final Settings settings) { - this.repositoriesService = new SetOnce<>(); - this.cacheService = new SetOnce<>(); this.settings = settings; } @@ -182,23 +178,23 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Rep final Environment environment, final NodeEnvironment nodeEnvironment, final NamedWriteableRegistry registry, - final IndexNameExpressionResolver resolver + final IndexNameExpressionResolver resolver, + final Supplier repositoriesServiceSupplier ) { if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) { final CacheService cacheService = new CacheService(settings); this.cacheService.set(cacheService); + this.repositoriesServiceSupplier = repositoriesServiceSupplier; return org.elasticsearch.common.collect.List.of(cacheService); } else { + this.repositoriesServiceSupplier = () -> { + assert false : "searchable snapshots are disabled"; + return null; + }; return org.elasticsearch.common.collect.List.of(); } } - @Override - public void onRepositoriesModule(RepositoriesModule repositoriesModule) { - // TODO NORELEASE should we use some SPI mechanism? The only reason we are a RepositoriesPlugin is because of this :/ - repositoriesService.set(repositoriesModule.getRepositoryService()); - } - @Override public void onIndexModule(IndexModule indexModule) { if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED && isSearchableSnapshotStore(indexModule.getSettings())) { @@ -210,7 +206,7 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Rep public Map getDirectoryFactories() { if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) { return org.elasticsearch.common.collect.Map.of(SNAPSHOT_DIRECTORY_FACTORY_KEY, (indexSettings, shardPath) -> { - final RepositoriesService repositories = repositoriesService.get(); + final RepositoriesService repositories = repositoriesServiceSupplier.get(); assert repositories != null; final CacheService cache = cacheService.get(); assert cache != null; 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 2348e1b4c30..1d7264985c1 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 @@ -58,6 +58,7 @@ import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.plugins.NetworkPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.SystemIndexPlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.rest.RestHeaderDefinition; @@ -380,7 +381,8 @@ public class Security extends Plugin implements SystemIndexPlugin, IngestPlugin, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { try { return createComponents(client, threadPool, clusterService, resourceWatcherService, scriptService, xContentRegistry, environment, expressionResolver); 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 364948dd8d4..ba1d728f608 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 @@ -24,6 +24,7 @@ import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -89,7 +90,8 @@ public class SqlPlugin extends Plugin implements ActionPlugin { ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { 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 87584724572..fcf7b475097 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 @@ -38,6 +38,7 @@ import org.elasticsearch.persistent.PersistentTasksExecutor; import org.elasticsearch.plugins.PersistentTaskPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.SystemIndexPlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptService; @@ -285,7 +286,8 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier ) { if (enabled == false || transportClientMode) { return emptyList(); 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 3faddf7ecf5..0c1e13eb995 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 @@ -29,6 +29,7 @@ import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.DiscoveryPlugin; import org.elasticsearch.plugins.NetworkPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.Transport; @@ -104,7 +105,8 @@ public class VotingOnlyNodePlugin extends Plugin implements DiscoveryPlugin, Net ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { 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 134eec7498e..fe5f0840a1c 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 @@ -48,6 +48,7 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.ReloadablePlugin; import org.elasticsearch.plugins.ScriptPlugin; import org.elasticsearch.plugins.SystemIndexPlugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ScriptContext; @@ -254,7 +255,8 @@ public class Watcher extends Plugin implements SystemIndexPlugin, ScriptPlugin, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, - IndexNameExpressionResolver expressionResolver) { + IndexNameExpressionResolver expressionResolver, + Supplier repositoriesServiceSupplier) { 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 f3882872a31..1c1fb4cd53b 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 @@ -82,7 +82,7 @@ public class WatcherPluginTests extends ESTestCase { watcher.onIndexModule(indexModule); // also no component creation if not enabled - assertThat(watcher.createComponents(null, null, null, null, null, null, null, null, null, null), hasSize(0)); + assertThat(watcher.createComponents(null, null, null, null, null, null, null, null, null, null, null), hasSize(0)); watcher.close(); }