From 8bcfce2e2647d908633249506604dffb7bba6ed3 Mon Sep 17 00:00:00 2001 From: kimchy Date: Sat, 16 Jul 2011 03:35:39 +0300 Subject: [PATCH] Allow to configure node name using `node.name` (on top of current `name`), closes #1126. --- .../org/elasticsearch/cluster/node/DiscoveryNode.java | 1 + .../node/internal/InternalSettingsPerparer.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 6a2c2dbd735..b4508febf43 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -48,6 +48,7 @@ public class DiscoveryNode implements Streamable, Serializable { public static Map buildCommonNodesAttributes(Settings settings) { Map attributes = Maps.newHashMap(settings.getByPrefix("node.").getAsMap()); + attributes.remove("name"); // name is extracted in other places if (attributes.containsKey("client")) { if (attributes.get("client").equals("false")) { attributes.remove("client"); // this is the default diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java b/modules/elasticsearch/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java index 6916e797576..50194a4a913 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java @@ -84,8 +84,12 @@ public class InternalSettingsPerparer { // generate the name if (settingsBuilder.get("name") == null) { String name = System.getProperty("name"); - if (name == null || name.isEmpty()) - name = Names.randomNodeName(environment.resolveConfig("names.txt")); + if (name == null || name.isEmpty()) { + name = settingsBuilder.get("node.name"); + if (name == null || name.isEmpty()) { + name = Names.randomNodeName(environment.resolveConfig("names.txt")); + } + } if (name != null) { settingsBuilder.put("name", name);