diff --git a/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java b/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java index e562345062e..8a0838e522f 100644 --- a/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java +++ b/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java @@ -6,6 +6,7 @@ package org.elasticsearch.license.plugin; import org.elasticsearch.action.ActionModule; +import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.collect.ImmutableSet; @@ -32,7 +33,7 @@ import java.util.Collection; public class LicensePlugin extends AbstractPlugin { - private final boolean isClient; + private final boolean isEnabled; static { MetaData.registerFactory(LicensesMetaData.TYPE, LicensesMetaData.FACTORY); @@ -40,7 +41,12 @@ public class LicensePlugin extends AbstractPlugin { @Inject public LicensePlugin(Settings settings) { - this.isClient = DiscoveryNode.clientNode(settings); + if (DiscoveryNode.clientNode(settings)) { + // Enable plugin only on node clients + this.isEnabled = "node".equals(settings.get(Client.CLIENT_TYPE_SETTING)); + } else { + this.isEnabled = true; + } } @Override @@ -69,7 +75,7 @@ public class LicensePlugin extends AbstractPlugin { @Override public Collection> services() { Collection> services = Lists.newArrayList(); - if (!isClient) { + if (isEnabled) { services.add(LicensesService.class); } return services; @@ -78,9 +84,9 @@ public class LicensePlugin extends AbstractPlugin { @Override public Collection> modules() { - if (isClient) { - return ImmutableSet.of(); + if (isEnabled) { + return ImmutableSet.>of(LicenseModule.class); } - return ImmutableSet.>of(LicenseModule.class); + return ImmutableSet.of(); } } diff --git a/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java b/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java index 02e0d0784ef..496d6fe79a2 100644 --- a/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java +++ b/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java @@ -321,9 +321,9 @@ public class LicensesService extends AbstractLifecycleComponent protected void doStart() throws ElasticsearchException { //Change to debug logger.info("Started LicensesService"); - if (DiscoveryNode.dataNode(settings) || DiscoveryNode.masterNode(settings)) { +// if (DiscoveryNode.dataNode(settings) || DiscoveryNode.masterNode(settings)) { clusterService.add(this); - } +// } } @Override diff --git a/src/test/java/org/elasticsearch/license/plugin/TestConsumerPlugin.java b/src/test/java/org/elasticsearch/license/plugin/TestConsumerPlugin.java index 344937850df..be1c3e49a86 100644 --- a/src/test/java/org/elasticsearch/license/plugin/TestConsumerPlugin.java +++ b/src/test/java/org/elasticsearch/license/plugin/TestConsumerPlugin.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.license.plugin; +import org.elasticsearch.client.Client; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.component.LifecycleComponent; @@ -16,14 +17,16 @@ import java.util.Collection; public class TestConsumerPlugin extends AbstractPlugin { - private final boolean isClient; - - private final Settings settings; + private final boolean isEnabled; @Inject public TestConsumerPlugin(Settings settings) { - this.settings = settings; - this.isClient = DiscoveryNode.clientNode(settings); + if (DiscoveryNode.clientNode(settings)) { + // Enable plugin only on node clients + this.isEnabled = "node".equals(settings.get(Client.CLIENT_TYPE_SETTING)); + } else { + this.isEnabled = true; + } } @Override @@ -40,7 +43,7 @@ public class TestConsumerPlugin extends AbstractPlugin { @Override public Collection> services() { Collection> services = Lists.newArrayList(); - if (!isClient) { + if (isEnabled) { services.add(TestPluginService.class); } return services;