Allow to configure node name using `node.name` (on top of current `name`), closes #1126.

This commit is contained in:
kimchy 2011-07-16 03:35:39 +03:00
parent 64054d4057
commit 8bcfce2e26
2 changed files with 7 additions and 2 deletions

View File

@ -48,6 +48,7 @@ public class DiscoveryNode implements Streamable, Serializable {
public static Map<String, String> buildCommonNodesAttributes(Settings settings) {
Map<String, String> 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

View File

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