Adapt to node.client setting removal

We would previosly check if a node was a client node, we can now check it by just verifying that it is not a transport client through client_type setting.

Original commit: elastic/x-pack-elasticsearch@bddd44866e
This commit is contained in:
javanna 2016-03-04 14:16:31 +01:00 committed by Luca Cavanna
parent c1c78911b9
commit 30a7ff1daa
4 changed files with 10 additions and 22 deletions

View File

@ -8,7 +8,6 @@ package org.elasticsearch.license.plugin;
import org.elasticsearch.action.ActionModule; import org.elasticsearch.action.ActionModule;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Module;
@ -44,13 +43,8 @@ public class Licensing {
@Inject @Inject
public Licensing(Settings settings) { public Licensing(Settings settings) {
if (DiscoveryNode.clientNode(settings)) { this.transportClient = "transport".equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey()));
// Enable plugin only on node clients isEnabled = transportClient == false;
this.isEnabled = "node".equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey()));
} else {
this.isEnabled = true;
}
transportClient = "transport".equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey()));
} }
public void onModule(NetworkModule module) { public void onModule(NetworkModule module) {

View File

@ -6,7 +6,6 @@
package org.elasticsearch.license.plugin.consumer; package org.elasticsearch.license.plugin.consumer;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -21,12 +20,7 @@ public abstract class TestConsumerPluginBase extends Plugin {
private final boolean isEnabled; private final boolean isEnabled;
public TestConsumerPluginBase(Settings settings) { public TestConsumerPluginBase(Settings settings) {
if (DiscoveryNode.clientNode(settings)) { this.isEnabled = "transport".equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey())) == false;
// Enable plugin only on node clients
this.isEnabled = "node".equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey()));
} else {
this.isEnabled = true;
}
} }
@Override @Override

View File

@ -10,6 +10,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.marvel.MarvelSettings; import org.elasticsearch.marvel.MarvelSettings;
import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.marvel.test.MarvelIntegTestCase;
import org.elasticsearch.node.Node;
import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms; import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
@ -63,7 +64,8 @@ public class MultiNodesStatsTests extends MarvelIntegTestCase {
n = randomIntBetween(1, 2); n = randomIntBetween(1, 2);
logger.debug("--> starting {} client only nodes", n); logger.debug("--> starting {} client only nodes", n);
InternalTestCluster.Async<List<String>> clientNodes = internalCluster().startNodesAsync(n, InternalTestCluster.Async<List<String>> clientNodes = internalCluster().startNodesAsync(n,
settingsBuilder().put("node.client", true).build()); settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), false)
.put(Node.NODE_INGEST_SETTING.getKey(), false).build());
clientNodes.get(); clientNodes.get();
nodes += n; nodes += n;

View File

@ -18,7 +18,6 @@ import org.elasticsearch.node.Node;
import org.elasticsearch.shield.authc.esusers.ESUsersRealm; import org.elasticsearch.shield.authc.esusers.ESUsersRealm;
import org.elasticsearch.shield.crypto.InternalCryptoService; import org.elasticsearch.shield.crypto.InternalCryptoService;
import org.elasticsearch.test.ShieldIntegTestCase; import org.elasticsearch.test.ShieldIntegTestCase;
import org.elasticsearch.test.ShieldSettingsSource;
import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.Transport;
import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackPlugin;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -27,7 +26,7 @@ import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Arrays; import java.util.Collections;
import static java.util.Collections.singletonMap; import static java.util.Collections.singletonMap;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
@ -103,9 +102,8 @@ public class ServerTransportFilterIntegrationTests extends ShieldIntegTestCase {
.put("path.home", createTempDir()) .put("path.home", createTempDir())
.put(NetworkModule.HTTP_ENABLED.getKey(), false) .put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put(InternalCryptoService.FILE_SETTING, systemKeyFile) .put(InternalCryptoService.FILE_SETTING, systemKeyFile)
.put("node.client", true)
.build(); .build();
try (Node node = new MockNode(nodeSettings, Version.CURRENT, Arrays.asList(XPackPlugin.class))) { try (Node node = new MockNode(nodeSettings, Version.CURRENT, Collections.singletonList(XPackPlugin.class))) {
node.start(); node.start();
assertGreenClusterState(node.client()); assertGreenClusterState(node.client());
} }
@ -136,9 +134,9 @@ public class ServerTransportFilterIntegrationTests extends ShieldIntegTestCase {
.put(InternalCryptoService.FILE_SETTING, systemKeyFile) .put(InternalCryptoService.FILE_SETTING, systemKeyFile)
.put("discovery.initial_state_timeout", "2s") .put("discovery.initial_state_timeout", "2s")
.put("path.home", createTempDir()) .put("path.home", createTempDir())
.put("node.client", true) .put(Node.NODE_MASTER_SETTING.getKey(), false)
.build(); .build();
try (Node node = new MockNode(nodeSettings, Version.CURRENT, Arrays.asList(XPackPlugin.class))) { try (Node node = new MockNode(nodeSettings, Version.CURRENT, Collections.singletonList(XPackPlugin.class))) {
node.start(); node.start();
// assert that node is not connected by waiting for the timeout // assert that node is not connected by waiting for the timeout