diff --git a/src/main/java/org/elasticsearch/index/IndexModule.java b/src/main/java/org/elasticsearch/index/IndexModule.java index ea22d837b46..0052628c035 100644 --- a/src/main/java/org/elasticsearch/index/IndexModule.java +++ b/src/main/java/org/elasticsearch/index/IndexModule.java @@ -20,17 +20,27 @@ package org.elasticsearch.index; import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.service.IndexService; import org.elasticsearch.index.service.InternalIndexService; +import org.elasticsearch.jmx.JmxService; /** * */ public class IndexModule extends AbstractModule { + private final Settings settings; + + public IndexModule(Settings settings) { + this.settings = settings; + } + @Override protected void configure() { bind(IndexService.class).to(InternalIndexService.class).asEagerSingleton(); - bind(IndexServiceManagement.class).asEagerSingleton(); + if (JmxService.shouldExport(settings)) { + bind(IndexServiceManagement.class).asEagerSingleton(); + } } } diff --git a/src/main/java/org/elasticsearch/index/service/InternalIndexService.java b/src/main/java/org/elasticsearch/index/service/InternalIndexService.java index 0b11b974350..7fcac7d983b 100644 --- a/src/main/java/org/elasticsearch/index/service/InternalIndexService.java +++ b/src/main/java/org/elasticsearch/index/service/InternalIndexService.java @@ -295,7 +295,7 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde ModulesBuilder modules = new ModulesBuilder(); modules.add(new ShardsPluginsModule(indexSettings, pluginsService)); - modules.add(new IndexShardModule(shardId)); + modules.add(new IndexShardModule(indexSettings, shardId)); modules.add(new ShardIndexingModule()); modules.add(new ShardSearchModule()); modules.add(new ShardGetModule()); diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java b/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java index b39a7760d99..e4a055d6fd3 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java @@ -20,17 +20,22 @@ package org.elasticsearch.index.shard; import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.jmx.JmxService; /** * */ public class IndexShardModule extends AbstractModule { + private final Settings settings; + private final ShardId shardId; - public IndexShardModule(ShardId shardId) { + public IndexShardModule(Settings settings, ShardId shardId) { + this.settings = settings; this.shardId = shardId; } @@ -38,6 +43,8 @@ public class IndexShardModule extends AbstractModule { protected void configure() { bind(ShardId.class).toInstance(shardId); bind(IndexShard.class).to(InternalIndexShard.class).asEagerSingleton(); - bind(IndexShardManagement.class).asEagerSingleton(); + if (JmxService.shouldExport(settings)) { + bind(IndexShardManagement.class).asEagerSingleton(); + } } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/store/StoreModule.java b/src/main/java/org/elasticsearch/index/store/StoreModule.java index ea995b74bbb..1c7865e94e4 100644 --- a/src/main/java/org/elasticsearch/index/store/StoreModule.java +++ b/src/main/java/org/elasticsearch/index/store/StoreModule.java @@ -21,6 +21,7 @@ package org.elasticsearch.index.store; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.jmx.JmxService; /** * @@ -39,7 +40,9 @@ public class StoreModule extends AbstractModule { @Override protected void configure() { bind(DirectoryService.class).to(indexStore.shardDirectory()).asEagerSingleton(); - bind(StoreManagement.class).asEagerSingleton(); bind(Store.class).asEagerSingleton(); + if (JmxService.shouldExport(settings)) { + bind(StoreManagement.class).asEagerSingleton(); + } } } diff --git a/src/main/java/org/elasticsearch/indices/InternalIndicesService.java b/src/main/java/org/elasticsearch/indices/InternalIndicesService.java index d15762f79b2..f026b7f9ff3 100644 --- a/src/main/java/org/elasticsearch/indices/InternalIndicesService.java +++ b/src/main/java/org/elasticsearch/indices/InternalIndicesService.java @@ -279,7 +279,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent