Merge pull request #15300 from rjernst/tribe_cleanup

Fix tribe node to load config file for internal client nodes
This commit is contained in:
Ryan Ernst 2015-12-08 08:07:26 -08:00
commit 6f996e9e26
5 changed files with 49 additions and 13 deletions

View File

@ -128,14 +128,13 @@ public class Node implements Releasable {
* @param preparedSettings Base settings to configure the node with * @param preparedSettings Base settings to configure the node with
*/ */
public Node(Settings preparedSettings) { public Node(Settings preparedSettings) {
this(preparedSettings, Version.CURRENT, Collections.<Class<? extends Plugin>>emptyList()); this(InternalSettingsPreparer.prepareEnvironment(preparedSettings, null), Version.CURRENT, Collections.<Class<? extends Plugin>>emptyList());
} }
Node(Settings preparedSettings, Version version, Collection<Class<? extends Plugin>> classpathPlugins) { protected Node(Environment tmpEnv, Version version, Collection<Class<? extends Plugin>> classpathPlugins) {
final Settings pSettings = settingsBuilder().put(preparedSettings) Settings tmpSettings = settingsBuilder().put(tmpEnv.settings())
.put(Client.CLIENT_TYPE_SETTING, CLIENT_TYPE).build(); .put(Client.CLIENT_TYPE_SETTING, CLIENT_TYPE).build();
Environment tmpEnv = InternalSettingsPreparer.prepareEnvironment(pSettings, null); tmpSettings = TribeService.processSettings(tmpSettings);
Settings tmpSettings = TribeService.processSettings(tmpEnv.settings());
ESLogger logger = Loggers.getLogger(Node.class, tmpSettings.get("name")); ESLogger logger = Loggers.getLogger(Node.class, tmpSettings.get("name"));
logger.info("version[{}], pid[{}], build[{}/{}]", version, JvmInfo.jvmInfo().pid(), Build.CURRENT.shortHash(), Build.CURRENT.date()); logger.info("version[{}], pid[{}], build[{}/{}]", version, JvmInfo.jvmInfo().pid(), Build.CURRENT.shortHash(), Build.CURRENT.date());

View File

@ -0,0 +1,37 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.tribe;
import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.node.Node;
import org.elasticsearch.plugins.Plugin;
import java.util.Collections;
/**
* An internal node that connects to a remove cluster, as part of a tribe node.
*/
class TribeClientNode extends Node {
TribeClientNode(Settings settings) {
super(new Environment(settings), Version.CURRENT, Collections.<Class<? extends Plugin>>emptyList());
}
}

View File

@ -132,14 +132,14 @@ public class TribeService extends AbstractLifecycleComponent<TribeService> {
nodesSettings.remove("on_conflict"); // remove prefix settings that don't indicate a client nodesSettings.remove("on_conflict"); // remove prefix settings that don't indicate a client
for (Map.Entry<String, Settings> entry : nodesSettings.entrySet()) { for (Map.Entry<String, Settings> entry : nodesSettings.entrySet()) {
Settings.Builder sb = Settings.builder().put(entry.getValue()); Settings.Builder sb = Settings.builder().put(entry.getValue());
sb.put("node.name", settings.get("name") + "/" + entry.getKey()); sb.put("name", settings.get("name") + "/" + entry.getKey());
sb.put("path.home", settings.get("path.home")); // pass through ES home dir sb.put("path.home", settings.get("path.home")); // pass through ES home dir
sb.put(TRIBE_NAME, entry.getKey()); sb.put(TRIBE_NAME, entry.getKey());
sb.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true);
if (sb.get("http.enabled") == null) { if (sb.get("http.enabled") == null) {
sb.put("http.enabled", false); sb.put("http.enabled", false);
} }
nodes.add(NodeBuilder.nodeBuilder().settings(sb).client(true).build()); sb.put("node.client", true);
nodes.add(new TribeClientNode(sb.build()));
} }
String[] blockIndicesWrite = Strings.EMPTY_ARRAY; String[] blockIndicesWrite = Strings.EMPTY_ARRAY;

View File

@ -54,13 +54,12 @@ public class TribeUnitTests extends ESTestCase {
@BeforeClass @BeforeClass
public static void createTribes() { public static void createTribes() {
Settings baseSettings = Settings.builder() Settings baseSettings = Settings.builder()
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true)
.put("http.enabled", false) .put("http.enabled", false)
.put("node.mode", NODE_MODE) .put("node.mode", NODE_MODE)
.put("path.home", createTempDir()).build(); .put("path.home", createTempDir()).build();
tribe1 = NodeBuilder.nodeBuilder().settings(Settings.builder().put(baseSettings).put("cluster.name", "tribe1").put("node.name", "tribe1_node")).node(); tribe1 = new TribeClientNode(Settings.builder().put(baseSettings).put("cluster.name", "tribe1").put("name", "tribe1_node").build()).start();
tribe2 = NodeBuilder.nodeBuilder().settings(Settings.builder().put(baseSettings).put("cluster.name", "tribe2").put("node.name", "tribe2_node")).node(); tribe2 = new TribeClientNode(Settings.builder().put(baseSettings).put("cluster.name", "tribe2").put("name", "tribe2_node").build()).start();
} }
@AfterClass @AfterClass

View File

@ -21,6 +21,7 @@ package org.elasticsearch.node;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import java.util.Collection; import java.util.Collection;
@ -39,7 +40,7 @@ public class MockNode extends Node {
private Collection<Class<? extends Plugin>> plugins; private Collection<Class<? extends Plugin>> plugins;
public MockNode(Settings settings, Version version, Collection<Class<? extends Plugin>> classpathPlugins) { public MockNode(Settings settings, Version version, Collection<Class<? extends Plugin>> classpathPlugins) {
super(settings, version, classpathPlugins); super(InternalSettingsPreparer.prepareEnvironment(settings, null), version, classpathPlugins);
this.version = version; this.version = version;
this.plugins = classpathPlugins; this.plugins = classpathPlugins;
} }