Browse Source

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.
Jay Modi 9 years ago
parent
commit
0573e03aa1

+ 1 - 1
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);
             final ClusterService clusterService = new ClusterService(settings, settingsModule.getClusterSettings(), threadPool);
             clusterService.add(scriptModule.getScriptService());
             clusterService.add(scriptModule.getScriptService());
             resourcesToClose.add(clusterService);
             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);
             resourcesToClose.add(tribeService);
             final IngestService ingestService = new IngestService(settings, threadPool, this.environment,
             final IngestService ingestService = new IngestService(settings, threadPool, this.environment,
                 scriptModule.getScriptService(), analysisModule.getAnalysisRegistry(), pluginsService.filterPlugins(IngestPlugin.class));
                 scriptModule.getScriptService(), analysisModule.getAnalysisRegistry(), pluginsService.filterPlugins(IngestPlugin.class));

+ 3 - 3
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.node.Node;
 import org.elasticsearch.plugins.Plugin;
 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.
  * An internal node that connects to a remove cluster, as part of a tribe node.
  */
  */
 class TribeClientNode extends Node {
 class TribeClientNode extends Node {
-    TribeClientNode(Settings settings) {
-        super(new Environment(settings), Collections.<Class<? extends Plugin>>emptyList());
+    TribeClientNode(Settings settings, Collection<Class<? extends Plugin>> classpathPlugins) {
+        super(new Environment(settings), classpathPlugins);
     }
     }
 }
 }

+ 5 - 2
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.env.NodeEnvironment;
 import org.elasticsearch.gateway.GatewayService;
 import org.elasticsearch.gateway.GatewayService;
 import org.elasticsearch.node.Node;
 import org.elasticsearch.node.Node;
+import org.elasticsearch.plugins.Plugin;
 import org.elasticsearch.rest.RestStatus;
 import org.elasticsearch.rest.RestStatus;
 import org.elasticsearch.transport.TransportSettings;
 import org.elasticsearch.transport.TransportSettings;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashMap;
@@ -182,7 +184,8 @@ public class TribeService extends AbstractLifecycleComponent {
 
 
     private final List<Node> nodes = new CopyOnWriteArrayList<>();
     private final List<Node> nodes = new CopyOnWriteArrayList<>();
 
 
-    public TribeService(Settings settings, ClusterService clusterService, final String tribeNodeId) {
+    public TribeService(Settings settings, ClusterService clusterService, final String tribeNodeId,
+                        Collection<Class<? extends Plugin>> classpathPlugins) {
         super(settings);
         super(settings);
         this.clusterService = clusterService;
         this.clusterService = clusterService;
         Map<String, Settings> nodesSettings = new HashMap<>(settings.getGroups("tribe", true));
         Map<String, Settings> 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
         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 clientSettings = buildClientSettings(entry.getKey(), tribeNodeId, settings, entry.getValue());
             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);
         this.blockIndicesMetadata = BLOCKS_METADATA_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);

+ 3 - 2
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.io.IOException;
 import java.nio.file.Path;
 import java.nio.file.Path;
+import java.util.Collections;
 
 
 import static org.hamcrest.CoreMatchers.either;
 import static org.hamcrest.CoreMatchers.either;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.equalTo;
@@ -71,14 +72,14 @@ public class TribeUnitTests extends ESTestCase {
                 .put("cluster.name", "tribe1")
                 .put("cluster.name", "tribe1")
                 .put("node.name", "tribe1_node")
                 .put("node.name", "tribe1_node")
                     .put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong())
                     .put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong())
-                .build()).start();
+                .build(), Collections.emptyList()).start();
         tribe2 = new TribeClientNode(
         tribe2 = new TribeClientNode(
             Settings.builder()
             Settings.builder()
                 .put(baseSettings)
                 .put(baseSettings)
                 .put("cluster.name", "tribe2")
                 .put("cluster.name", "tribe2")
                 .put("node.name", "tribe2_node")
                 .put("node.name", "tribe2_node")
                     .put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong())
                     .put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong())
-                .build()).start();
+                .build(), Collections.emptyList()).start();
     }
     }
 
 
     @AfterClass
     @AfterClass