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:
parent
a6f14eb919
commit
ae0489266e
4
pom.xml
4
pom.xml
|
@ -389,9 +389,7 @@
|
||||||
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
|
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
|
||||||
<tests.integration>${tests.integration}</tests.integration>
|
<tests.integration>${tests.integration}</tests.integration>
|
||||||
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
|
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
|
||||||
<es.transport.tcp.compress>${env.ES_TEST_COMPRESS}</es.transport.tcp.compress>
|
<es.node.mode>${es.node.mode}</es.node.mode>
|
||||||
<es.action.wait_on_mapping_change>${env.ES_WAIT_ON_MAPPING_CHANGE}
|
|
||||||
</es.action.wait_on_mapping_change>
|
|
||||||
<es.logger.level>${es.logger.level}</es.logger.level>
|
<es.logger.level>${es.logger.level}</es.logger.level>
|
||||||
<java.awt.headless>true</java.awt.headless>
|
<java.awt.headless>true</java.awt.headless>
|
||||||
</systemProperties>
|
</systemProperties>
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.cluster.node;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
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 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) {
|
public static boolean nodeRequiresLocalStorage(Settings settings) {
|
||||||
return !(settings.getAsBoolean("node.client", false) || (!settings.getAsBoolean("node.data", true) && !settings.getAsBoolean("node.master", true)));
|
return !(settings.getAsBoolean("node.client", false) || (!settings.getAsBoolean("node.data", true) && !settings.getAsBoolean("node.master", true)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.discovery;
|
package org.elasticsearch.discovery;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.inject.Module;
|
import org.elasticsearch.common.inject.Module;
|
||||||
import org.elasticsearch.common.inject.Modules;
|
import org.elasticsearch.common.inject.Modules;
|
||||||
|
@ -42,7 +43,7 @@ public class DiscoveryModule extends AbstractModule implements SpawnModules {
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends Module> spawnModules() {
|
public Iterable<? extends Module> spawnModules() {
|
||||||
Class<? extends Module> defaultDiscoveryModule;
|
Class<? extends Module> defaultDiscoveryModule;
|
||||||
if (settings.getAsBoolean("node.local", false)) {
|
if (DiscoveryNode.localNode(settings)) {
|
||||||
defaultDiscoveryModule = LocalDiscoveryModule.class;
|
defaultDiscoveryModule = LocalDiscoveryModule.class;
|
||||||
} else {
|
} else {
|
||||||
defaultDiscoveryModule = ZenDiscoveryModule.class;
|
defaultDiscoveryModule = ZenDiscoveryModule.class;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.transport;
|
package org.elasticsearch.transport;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.inject.Module;
|
import org.elasticsearch.common.inject.Module;
|
||||||
import org.elasticsearch.common.inject.Modules;
|
import org.elasticsearch.common.inject.Modules;
|
||||||
|
@ -42,7 +43,7 @@ public class TransportModule extends AbstractModule implements SpawnModules {
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends Module> spawnModules() {
|
public Iterable<? extends Module> spawnModules() {
|
||||||
Class<? extends Module> defaultTransportModule;
|
Class<? extends Module> defaultTransportModule;
|
||||||
if (settings.getAsBoolean("node.local", false)) {
|
if (DiscoveryNode.localNode(settings)) {
|
||||||
defaultTransportModule = LocalTransportModule.class;
|
defaultTransportModule = LocalTransportModule.class;
|
||||||
} else {
|
} else {
|
||||||
defaultTransportModule = NettyTransportModule.class;
|
defaultTransportModule = NettyTransportModule.class;
|
||||||
|
|
Loading…
Reference in New Issue