diff --git a/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java b/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java index cb7b2b4c8d9..1dbe472267a 100644 --- a/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java +++ b/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java @@ -10,10 +10,7 @@ import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.bootstrap.BootstrapInfo; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider; -import org.elasticsearch.common.inject.ConfigurationException; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.Provider; -import org.elasticsearch.common.inject.ProvisionException; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.env.NodeEnvironment; @@ -43,19 +40,17 @@ public class NodeStatsCollector extends AbstractCollector { private final DiscoveryService discoveryService; private final NodeEnvironment nodeEnvironment; - // Use a provider in order to avoid Guice circular injection - // issues because AllocationDecider is not an interface and cannot be proxied - private final Provider diskThresholdDeciderProvider; + private final DiskThresholdDecider diskThresholdDecider; @Inject public NodeStatsCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings, MarvelLicensee marvelLicensee, NodeService nodeService, DiscoveryService discoveryService, NodeEnvironment nodeEnvironment, - Provider diskThresholdDeciderProvider) { + DiskThresholdDecider diskThresholdDecider) { super(settings, NAME, clusterService, marvelSettings, marvelLicensee); this.nodeService = nodeService; this.discoveryService = discoveryService; this.nodeEnvironment = nodeEnvironment; - this.diskThresholdDeciderProvider = diskThresholdDeciderProvider; + this.diskThresholdDecider = diskThresholdDecider; } @Override @@ -69,13 +64,6 @@ public class NodeStatsCollector extends AbstractCollector { NodeStats nodeStats = nodeService.stats(); - DiskThresholdDecider diskThresholdDecider = null; - try { - diskThresholdDecider = diskThresholdDeciderProvider.get(); - } catch (ProvisionException | ConfigurationException e) { - logger.warn("unable to retrieve disk threshold decider information", e); - } - // Here we are calling directly the DiskThresholdDecider to retrieve the high watermark value // It would be nicer to use a settings API like documented in #6732 Double diskThresholdWatermarkHigh = (diskThresholdDecider != null) ? 100.0 - diskThresholdDecider.getFreeDiskThresholdHigh() : -1; diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java index 4036df8c792..582df3572cc 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.marvel.agent.collector.node; import org.elasticsearch.bootstrap.BootstrapInfo; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider; -import org.elasticsearch.common.inject.Provider; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.env.NodeEnvironment; @@ -95,11 +94,6 @@ public class NodeStatsCollectorTests extends AbstractCollectorTestCase { internalCluster().getInstance(NodeService.class, nodeId), internalCluster().getInstance(DiscoveryService.class, nodeId), internalCluster().getInstance(NodeEnvironment.class, nodeId), - new Provider() { - @Override - public DiskThresholdDecider get() { - return internalCluster().getInstance(DiskThresholdDecider.class, nodeId); - } - }); + internalCluster().getInstance(DiskThresholdDecider.class, nodeId)); } }