From 0573e03aa17f27e84c31844fd2f6171d9c1a3dfa Mon Sep 17 00:00:00 2001 From: Jay Modi Date: Thu, 22 Sep 2016 07:29:07 -0400 Subject: [PATCH] Pass classpath plugins to tribe nodes When testing tribe nodes in an integration test, we should pass the classpath plugins of the node down to the tribe client nodes. Without this the tribe client nodes could be prevented from communicating with the tribes. --- core/src/main/java/org/elasticsearch/node/Node.java | 2 +- .../main/java/org/elasticsearch/tribe/TribeClientNode.java | 6 +++--- .../main/java/org/elasticsearch/tribe/TribeService.java | 7 +++++-- .../test/java/org/elasticsearch/tribe/TribeUnitTests.java | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index 2d529ccfd3b..0fc2d98c1b8 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -315,7 +315,7 @@ public class Node implements Closeable { final ClusterService clusterService = new ClusterService(settings, settingsModule.getClusterSettings(), threadPool); clusterService.add(scriptModule.getScriptService()); resourcesToClose.add(clusterService); - final TribeService tribeService = new TribeService(settings, clusterService, nodeEnvironment.nodeId()); + final TribeService tribeService = new TribeService(settings, clusterService, nodeEnvironment.nodeId(), classpathPlugins); resourcesToClose.add(tribeService); final IngestService ingestService = new IngestService(settings, threadPool, this.environment, scriptModule.getScriptService(), analysisModule.getAnalysisRegistry(), pluginsService.filterPlugins(IngestPlugin.class)); diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeClientNode.java b/core/src/main/java/org/elasticsearch/tribe/TribeClientNode.java index 02957ab99a4..d9520aef768 100644 --- a/core/src/main/java/org/elasticsearch/tribe/TribeClientNode.java +++ b/core/src/main/java/org/elasticsearch/tribe/TribeClientNode.java @@ -24,13 +24,13 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.node.Node; import org.elasticsearch.plugins.Plugin; -import java.util.Collections; +import java.util.Collection; /** * 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), Collections.>emptyList()); + TribeClientNode(Settings settings, Collection> classpathPlugins) { + super(new Environment(settings), classpathPlugins); } } diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeService.java b/core/src/main/java/org/elasticsearch/tribe/TribeService.java index 99f6c696e66..fd697340cd7 100644 --- a/core/src/main/java/org/elasticsearch/tribe/TribeService.java +++ b/core/src/main/java/org/elasticsearch/tribe/TribeService.java @@ -58,10 +58,12 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.node.Node; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.transport.TransportSettings; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; @@ -182,7 +184,8 @@ public class TribeService extends AbstractLifecycleComponent { private final List nodes = new CopyOnWriteArrayList<>(); - public TribeService(Settings settings, ClusterService clusterService, final String tribeNodeId) { + public TribeService(Settings settings, ClusterService clusterService, final String tribeNodeId, + Collection> classpathPlugins) { super(settings); this.clusterService = clusterService; Map nodesSettings = new HashMap<>(settings.getGroups("tribe", true)); @@ -190,7 +193,7 @@ public class TribeService extends AbstractLifecycleComponent { nodesSettings.remove("on_conflict"); // remove prefix settings that don't indicate a client for (Map.Entry entry : nodesSettings.entrySet()) { Settings clientSettings = buildClientSettings(entry.getKey(), tribeNodeId, settings, entry.getValue()); - nodes.add(new TribeClientNode(clientSettings)); + nodes.add(new TribeClientNode(clientSettings, classpathPlugins)); } this.blockIndicesMetadata = BLOCKS_METADATA_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY); diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java index 404d4495894..0171dfb99d1 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java @@ -39,6 +39,7 @@ import org.junit.BeforeClass; import java.io.IOException; import java.nio.file.Path; +import java.util.Collections; import static org.hamcrest.CoreMatchers.either; import static org.hamcrest.CoreMatchers.equalTo; @@ -71,14 +72,14 @@ public class TribeUnitTests extends ESTestCase { .put("cluster.name", "tribe1") .put("node.name", "tribe1_node") .put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong()) - .build()).start(); + .build(), Collections.emptyList()).start(); tribe2 = new TribeClientNode( Settings.builder() .put(baseSettings) .put("cluster.name", "tribe2") .put("node.name", "tribe2_node") .put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong()) - .build()).start(); + .build(), Collections.emptyList()).start(); } @AfterClass