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
This commit is contained in:
Shay Banon 2013-09-17 00:33:42 +02:00
parent a6f14eb919
commit ae0489266e
4 changed files with 23 additions and 5 deletions

View File

@ -389,9 +389,7 @@
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
<tests.integration>${tests.integration}</tests.integration>
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
<es.transport.tcp.compress>${env.ES_TEST_COMPRESS}</es.transport.tcp.compress>
<es.action.wait_on_mapping_change>${env.ES_WAIT_ON_MAPPING_CHANGE}
</es.action.wait_on_mapping_change>
<es.node.mode>${es.node.mode}</es.node.mode>
<es.logger.level>${es.logger.level}</es.logger.level>
<java.awt.headless>true</java.awt.headless>
</systemProperties>

View File

@ -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)));
}

View File

@ -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<? extends Module> spawnModules() {
Class<? extends Module> defaultDiscoveryModule;
if (settings.getAsBoolean("node.local", false)) {
if (DiscoveryNode.localNode(settings)) {
defaultDiscoveryModule = LocalDiscoveryModule.class;
} else {
defaultDiscoveryModule = ZenDiscoveryModule.class;

View File

@ -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<? extends Module> spawnModules() {
Class<? extends Module> defaultTransportModule;
if (settings.getAsBoolean("node.local", false)) {
if (DiscoveryNode.localNode(settings)) {
defaultTransportModule = LocalTransportModule.class;
} else {
defaultTransportModule = NettyTransportModule.class;