From ae0489266e79857540816bce0e04401cef107990 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Tue, 17 Sep 2013 00:33:42 +0200 Subject: [PATCH] Add `node.mode` with `local` or `network` Compared to setting node.local to true, would be nicer to support node.mode with values of local or network. Note, node.local is still supported. closes #3713 --- pom.xml | 4 +--- .../cluster/node/DiscoveryNode.java | 18 ++++++++++++++++++ .../discovery/DiscoveryModule.java | 3 ++- .../transport/TransportModule.java | 3 ++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index e65aafc070a..1b1180651ce 100644 --- a/pom.xml +++ b/pom.xml @@ -389,9 +389,7 @@ ${tests.showSuccess} ${tests.integration} ${env.ES_TEST_LOCAL} - ${env.ES_TEST_COMPRESS} - ${env.ES_WAIT_ON_MAPPING_CHANGE} - + ${es.node.mode} ${es.logger.level} true diff --git a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 104f3a314ce..527d7f40c60 100644 --- a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.cluster.node; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -40,6 +41,23 @@ import static org.elasticsearch.common.transport.TransportAddressSerializers.add */ public class DiscoveryNode implements Streamable, Serializable { + public static boolean localNode(Settings settings) { + if (settings.get("node.local") != null) { + return settings.getAsBoolean("node.local", false); + } + if (settings.get("node.mode") != null) { + String nodeMode = settings.get("node.mode"); + if ("local".equals(nodeMode)) { + return true; + } else if ("network".equals(nodeMode)) { + return false; + } else { + throw new ElasticSearchIllegalArgumentException("unsupported node.mode [" + nodeMode + "]"); + } + } + return false; + } + public static boolean nodeRequiresLocalStorage(Settings settings) { return !(settings.getAsBoolean("node.client", false) || (!settings.getAsBoolean("node.data", true) && !settings.getAsBoolean("node.master", true))); } diff --git a/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java b/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java index da6a729f5ac..0719d0e8909 100644 --- a/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java +++ b/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java @@ -20,6 +20,7 @@ package org.elasticsearch.discovery; import com.google.common.collect.ImmutableList; +import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Modules; @@ -42,7 +43,7 @@ public class DiscoveryModule extends AbstractModule implements SpawnModules { @Override public Iterable spawnModules() { Class defaultDiscoveryModule; - if (settings.getAsBoolean("node.local", false)) { + if (DiscoveryNode.localNode(settings)) { defaultDiscoveryModule = LocalDiscoveryModule.class; } else { defaultDiscoveryModule = ZenDiscoveryModule.class; diff --git a/src/main/java/org/elasticsearch/transport/TransportModule.java b/src/main/java/org/elasticsearch/transport/TransportModule.java index cedfe5118dd..dd1a193521c 100644 --- a/src/main/java/org/elasticsearch/transport/TransportModule.java +++ b/src/main/java/org/elasticsearch/transport/TransportModule.java @@ -20,6 +20,7 @@ package org.elasticsearch.transport; import com.google.common.collect.ImmutableList; +import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Modules; @@ -42,7 +43,7 @@ public class TransportModule extends AbstractModule implements SpawnModules { @Override public Iterable spawnModules() { Class defaultTransportModule; - if (settings.getAsBoolean("node.local", false)) { + if (DiscoveryNode.localNode(settings)) { defaultTransportModule = LocalTransportModule.class; } else { defaultTransportModule = NettyTransportModule.class;