From 3ddbd77090e1d09c45a7fd3c1aae06a5b9338f8b Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Wed, 24 Feb 2016 14:10:56 -0800 Subject: [PATCH] Remove DiscoveryService and reduce guice to just Discovery elastic/elasticsearch#1571 DiscoveryService was a bridge into the discovery universe. This is unneeded and we can just access discovery directly or do things in a different way. This is a complement to elastic/elasticsearchelastic/elasticsearch#16821 Closes elastic/elasticsearch#1571 Original commit: elastic/x-pack-elasticsearch@496f0c4081e0fbcc070a046a61891ca9760faee3 --- .../marvel/agent/collector/AbstractCollector.java | 10 +++------- .../agent/collector/cluster/ClusterStateCollector.java | 7 +++---- .../agent/collector/cluster/ClusterStatsCollector.java | 7 +++---- .../collector/indices/IndexRecoveryCollector.java | 7 +++---- .../agent/collector/indices/IndexStatsCollector.java | 7 +++---- .../agent/collector/indices/IndicesStatsCollector.java | 7 +++---- .../agent/collector/node/NodeStatsCollector.java | 7 +++---- .../marvel/agent/collector/shards/ShardsCollector.java | 7 +++---- .../collector/cluster/ClusterStateCollectorTests.java | 4 +--- .../collector/cluster/ClusterStatsCollectorTests.java | 4 +--- .../collector/indices/IndexRecoveryCollectorTests.java | 4 +--- .../collector/indices/IndexStatsCollectorTests.java | 4 +--- .../collector/indices/IndicesStatsCollectorTests.java | 4 +--- .../agent/collector/node/NodeStatsCollectorTests.java | 6 ++---- .../agent/collector/shards/ShardsCollectorTests.java | 4 +--- .../elasticsearch/shield/ShieldLifecycleService.java | 6 +++++- .../java/org/elasticsearch/shield/ShieldModule.java | 1 - .../elasticsearch/shield/ShieldTemplateService.java | 2 -- 18 files changed, 37 insertions(+), 61 deletions(-) diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/AbstractCollector.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/AbstractCollector.java index a23ce6347ff..31c7b2fc44d 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/AbstractCollector.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/AbstractCollector.java @@ -5,18 +5,16 @@ */ package org.elasticsearch.marvel.agent.collector; - import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.exporter.IndexNameResolver; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; import org.elasticsearch.marvel.agent.exporter.MarvelTemplateUtils; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import java.util.Collection; @@ -27,18 +25,16 @@ public abstract class AbstractCollector extends AbstractLifecycleComponent private final String name; protected final ClusterService clusterService; - protected final DiscoveryService discoveryService; protected final MarvelSettings marvelSettings; protected final MarvelLicensee licensee; protected final IndexNameResolver dataIndexNameResolver; @Inject - public AbstractCollector(Settings settings, String name, ClusterService clusterService, DiscoveryService discoveryService, + public AbstractCollector(Settings settings, String name, ClusterService clusterService, MarvelSettings marvelSettings, MarvelLicensee licensee) { super(settings); this.name = name; this.clusterService = clusterService; - this.discoveryService = discoveryService; this.marvelSettings = marvelSettings; this.licensee = licensee; this.dataIndexNameResolver = new DataIndexNameResolver(MarvelTemplateUtils.TEMPLATE_VERSION); @@ -121,7 +117,7 @@ public abstract class AbstractCollector extends AbstractLifecycleComponent } protected DiscoveryNode localNode() { - return discoveryService.localNode(); + return clusterService.localNode(); } /** diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollector.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollector.java index 9fabf639b29..cbba4f28ebc 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollector.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollector.java @@ -13,10 +13,9 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollector; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import org.elasticsearch.shield.InternalClient; @@ -40,9 +39,9 @@ public class ClusterStateCollector extends AbstractCollector private final Client client; @Inject - public IndexStatsCollector(Settings settings, ClusterService clusterService, DiscoveryService discoveryService, + public IndexStatsCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings, MarvelLicensee marvelLicensee, InternalClient client) { - super(settings, NAME, clusterService, discoveryService, marvelSettings, marvelLicensee); + super(settings, NAME, clusterService, marvelSettings, marvelLicensee); this.client = client; } diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollector.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollector.java index 421ce18b162..2275c6d6821 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollector.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollector.java @@ -12,11 +12,10 @@ import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.index.IndexNotFoundException; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollector; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import org.elasticsearch.shield.InternalClient; import org.elasticsearch.shield.Shield; @@ -38,9 +37,9 @@ public class IndicesStatsCollector extends AbstractCollector { @Inject public NodeStatsCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings, - MarvelLicensee marvelLicensee, InternalClient client, DiscoveryService discoveryService, + MarvelLicensee marvelLicensee, InternalClient client, NodeEnvironment nodeEnvironment, DiskThresholdDecider diskThresholdDecider) { - super(settings, NAME, clusterService, discoveryService, marvelSettings, marvelLicensee); + super(settings, NAME, clusterService, marvelSettings, marvelLicensee); this.client = client; this.nodeEnvironment = nodeEnvironment; this.diskThresholdDecider = diskThresholdDecider; diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollector.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollector.java index 577ca55e682..670cc9c69b9 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollector.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollector.java @@ -13,10 +13,9 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollector; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import java.util.ArrayList; @@ -37,9 +36,9 @@ public class ShardsCollector extends AbstractCollector { public static final String TYPE = "shards"; @Inject - public ShardsCollector(Settings settings, ClusterService clusterService, DiscoveryService discoveryService, + public ShardsCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings, MarvelLicensee marvelLicensee) { - super(settings, NAME, clusterService, discoveryService, marvelSettings, marvelLicensee); + super(settings, NAME, clusterService, marvelSettings, marvelLicensee); } @Override diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java index 40fd3730ce4..7e8ab56eb77 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java @@ -9,11 +9,10 @@ import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; import org.elasticsearch.marvel.agent.exporter.MarvelTemplateUtils; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import java.util.ArrayList; @@ -151,7 +150,6 @@ public class ClusterStateCollectorTests extends AbstractCollectorTestCase { assertNotNull(nodeId); return new ClusterStateCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(DiscoveryService.class, nodeId), internalCluster().getInstance(MarvelSettings.class, nodeId), internalCluster().getInstance(MarvelLicensee.class, nodeId), securedClient(nodeId)); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java index 7095a9e19d2..f8784b089f0 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java @@ -9,12 +9,11 @@ import org.apache.lucene.util.LuceneTestCase.BadApple; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.license.plugin.core.LicensesManagerService; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollector; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import java.util.Collection; @@ -128,7 +127,6 @@ public class ClusterStatsCollectorTests extends AbstractCollectorTestCase { assertNotNull(nodeId); return new ClusterStatsCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(DiscoveryService.class, nodeId), internalCluster().getInstance(MarvelSettings.class, nodeId), internalCluster().getInstance(MarvelLicensee.class, nodeId), securedClient(nodeId), diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java index e27622045f7..86b2ef3c656 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java @@ -10,12 +10,11 @@ import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.indices.recovery.RecoveryState; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; @@ -206,7 +205,6 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase { } return new IndexRecoveryCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(DiscoveryService.class, nodeId), internalCluster().getInstance(MarvelSettings.class, nodeId), internalCluster().getInstance(MarvelLicensee.class, nodeId), securedClient(nodeId)); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexStatsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexStatsCollectorTests.java index a428432d9d4..c908e758861 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexStatsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexStatsCollectorTests.java @@ -9,11 +9,10 @@ import org.elasticsearch.action.admin.indices.stats.IndexStats; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.index.IndexNotFoundException; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; @@ -239,7 +238,6 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase { assertNotNull(nodeId); return new IndexStatsCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(DiscoveryService.class, nodeId), internalCluster().getInstance(MarvelSettings.class, nodeId), internalCluster().getInstance(MarvelLicensee.class, nodeId), securedClient(nodeId)); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollectorTests.java index 82afc7f2ed2..a6f8b3df234 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollectorTests.java @@ -11,11 +11,10 @@ import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.index.IndexNotFoundException; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; @@ -209,7 +208,6 @@ public class IndicesStatsCollectorTests extends AbstractCollectorTestCase { } return new IndicesStatsCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(DiscoveryService.class, nodeId), internalCluster().getInstance(MarvelSettings.class, nodeId), internalCluster().getInstance(MarvelLicensee.class, nodeId), securedClient(nodeId)); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java index 8bb3a763387..d39605b39e8 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java @@ -9,11 +9,10 @@ import org.elasticsearch.bootstrap.BootstrapInfo; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.env.NodeEnvironment; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import org.elasticsearch.shield.InternalClient; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; @@ -50,7 +49,7 @@ public class NodeStatsCollectorTests extends AbstractCollectorTestCase { assertThat(nodeStatsMarvelDoc.getSourceNode(), notNullValue()); assertThat(nodeStatsMarvelDoc.getNodeId(), - equalTo(internalCluster().getInstance(DiscoveryService.class, node).localNode().id())); + equalTo(internalCluster().getInstance(ClusterService.class, node).localNode().id())); assertThat(nodeStatsMarvelDoc.isNodeMaster(), equalTo(node.equals(internalCluster().getMasterName()))); assertThat(nodeStatsMarvelDoc.isMlockall(), equalTo(BootstrapInfo.isMemoryLocked())); assertNotNull(nodeStatsMarvelDoc.isDiskThresholdDeciderEnabled()); @@ -96,7 +95,6 @@ public class NodeStatsCollectorTests extends AbstractCollectorTestCase { internalCluster().getInstance(MarvelSettings.class, nodeId), internalCluster().getInstance(MarvelLicensee.class, nodeId), internalCluster().getInstance(InternalClient.class, nodeId), - internalCluster().getInstance(DiscoveryService.class, nodeId), internalCluster().getInstance(NodeEnvironment.class, nodeId), internalCluster().getInstance(DiskThresholdDecider.class, nodeId)); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java index 03034d198a2..a117103a53c 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java @@ -9,10 +9,9 @@ import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.DiscoveryService; +import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; -import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.license.MarvelLicensee; import java.util.Collection; @@ -201,7 +200,6 @@ public class ShardsCollectorTests extends AbstractCollectorTestCase { assertNotNull(nodeId); return new ShardsCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(DiscoveryService.class, nodeId), internalCluster().getInstance(MarvelSettings.class, nodeId), internalCluster().getInstance(MarvelLicensee.class, nodeId)); } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldLifecycleService.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldLifecycleService.java index 914438e8a36..fe8f1fa9f12 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldLifecycleService.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldLifecycleService.java @@ -11,6 +11,7 @@ import org.elasticsearch.cluster.ClusterStateListener; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.component.LifecycleListener; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.Provider; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.shield.audit.AuditTrailModule; @@ -41,16 +42,19 @@ public class ShieldLifecycleService extends AbstractComponent implements Cluster @Inject public ShieldLifecycleService(Settings settings, ClusterService clusterService, ThreadPool threadPool, IndexAuditTrail indexAuditTrail, ESNativeUsersStore esUserStore, - ESNativeRolesStore esRolesStore) { + ESNativeRolesStore esRolesStore, Provider clientProvider) { super(settings); this.settings = settings; this.threadPool = threadPool; this.indexAuditTrail = indexAuditTrail; this.esUserStore = esUserStore; this.esRolesStore = esRolesStore; + // TODO: define a common interface for these and delegate from one place. esUserStore store is it's on cluster + // state listener , but is also activated from this clusterChanged method clusterService.add(this); clusterService.add(esUserStore); clusterService.add(esRolesStore); + clusterService.add(new ShieldTemplateService(settings, clusterService, clientProvider, threadPool)); clusterService.addLifecycleListener(new LifecycleListener() { @Override diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldModule.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldModule.java index f8ba964a3e4..d82cf10cffc 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldModule.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldModule.java @@ -23,7 +23,6 @@ public class ShieldModule extends AbstractShieldModule { bind(SecurityContext.Secure.class).asEagerSingleton(); bind(SecurityContext.class).to(SecurityContext.Secure.class); bind(ShieldLifecycleService.class).asEagerSingleton(); - bind(ShieldTemplateService.class).asEagerSingleton(); bind(InternalClient.Secure.class).asEagerSingleton(); bind(InternalClient.class).to(InternalClient.Secure.class); } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldTemplateService.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldTemplateService.java index 21b36e1c2d7..130b874f7e2 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldTemplateService.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldTemplateService.java @@ -16,7 +16,6 @@ import org.elasticsearch.cluster.ClusterStateListener; import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; import org.elasticsearch.cluster.routing.IndexRoutingTable; import org.elasticsearch.common.component.AbstractComponent; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Provider; import org.elasticsearch.common.io.Streams; import org.elasticsearch.common.settings.Settings; @@ -41,7 +40,6 @@ public class ShieldTemplateService extends AbstractComponent implements ClusterS private final Provider clientProvider; private final AtomicBoolean templateCreationPending = new AtomicBoolean(false); - @Inject public ShieldTemplateService(Settings settings, ClusterService clusterService, Provider clientProvider, ThreadPool threadPool) { super(settings);