You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by rs...@apache.org on 2018/03/16 17:57:43 UTC
[kafka] branch trunk updated: MINOR: Trogdor should not assume an
agent co-located with the controller (#4712)
This is an automated email from the ASF dual-hosted git repository.
rsivaram pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 9e0e6e4 MINOR: Trogdor should not assume an agent co-located with the controller (#4712)
9e0e6e4 is described below
commit 9e0e6e43a787092ff908cb17da37ab5dea03978b
Author: Colin Patrick McCabe <co...@cmccabe.xyz>
AuthorDate: Fri Mar 16 10:57:38 2018 -0700
MINOR: Trogdor should not assume an agent co-located with the controller (#4712)
---
checkstyle/suppressions.xml | 2 +-
.../org/apache/kafka/trogdor/common/Topology.java | 2 +-
.../kafka/trogdor/common/MiniTrogdorCluster.java | 12 ++--
.../apache/kafka/trogdor/common/TopologyTest.java | 65 ++++++++++++++++++++++
4 files changed, 75 insertions(+), 6 deletions(-)
diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml
index 45ee4e6..62fe4ed 100644
--- a/checkstyle/suppressions.xml
+++ b/checkstyle/suppressions.xml
@@ -57,7 +57,7 @@
files="AbstractRequest.java|KerberosLogin.java|WorkerSinkTaskTest.java|TransactionManagerTest.java"/>
<suppress checks="NPathComplexity"
- files="(BufferPool|MetricName|Node|ConfigDef|SslTransportLayer|MetadataResponse|KerberosLogin|Selector|Sender|Serdes|Agent|Values|PluginUtils).java"/>
+ files="(BufferPool|MetricName|Node|ConfigDef|SslTransportLayer|MetadataResponse|KerberosLogin|Selector|Sender|Serdes|Agent|Values|PluginUtils|MiniTrogdorCluster).java"/>
<!-- clients tests -->
<suppress checks="ClassDataAbstractionCoupling"
diff --git a/tools/src/main/java/org/apache/kafka/trogdor/common/Topology.java b/tools/src/main/java/org/apache/kafka/trogdor/common/Topology.java
index d48bbde..576932e 100644
--- a/tools/src/main/java/org/apache/kafka/trogdor/common/Topology.java
+++ b/tools/src/main/java/org/apache/kafka/trogdor/common/Topology.java
@@ -33,7 +33,7 @@ public interface Topology {
public static Set<String> agentNodeNames(Topology topology) {
Set<String> set = new HashSet<>();
for (Map.Entry<String, Node> entry : topology.nodes().entrySet()) {
- if (Node.Util.getTrogdorAgentPort(entry.getValue()) > 0) {
+ if (entry.getValue().getConfig(Platform.Config.TROGDOR_AGENT_PORT) != null) {
set.add(entry.getKey());
}
}
diff --git a/tools/src/test/java/org/apache/kafka/trogdor/common/MiniTrogdorCluster.java b/tools/src/test/java/org/apache/kafka/trogdor/common/MiniTrogdorCluster.java
index ea55f2a..07f02c5 100644
--- a/tools/src/test/java/org/apache/kafka/trogdor/common/MiniTrogdorCluster.java
+++ b/tools/src/test/java/org/apache/kafka/trogdor/common/MiniTrogdorCluster.java
@@ -152,10 +152,14 @@ public class MiniTrogdorCluster implements AutoCloseable {
for (Map.Entry<String, NodeData> entry : nodes.entrySet()) {
NodeData node = entry.getValue();
HashMap<String, String> config = new HashMap<>();
- config.put(Platform.Config.TROGDOR_AGENT_PORT,
- Integer.toString(node.agentPort));
- config.put(Platform.Config.TROGDOR_COORDINATOR_PORT,
- Integer.toString(node.coordinatorPort));
+ if (node.agentPort != 0) {
+ config.put(Platform.Config.TROGDOR_AGENT_PORT,
+ Integer.toString(node.agentPort));
+ }
+ if (node.coordinatorPort != 0) {
+ config.put(Platform.Config.TROGDOR_COORDINATOR_PORT,
+ Integer.toString(node.coordinatorPort));
+ }
node.node = new BasicNode(entry.getKey(), node.hostname, config,
Collections.<String>emptySet());
}
diff --git a/tools/src/test/java/org/apache/kafka/trogdor/common/TopologyTest.java b/tools/src/test/java/org/apache/kafka/trogdor/common/TopologyTest.java
new file mode 100644
index 0000000..2ec9ef7
--- /dev/null
+++ b/tools/src/test/java/org/apache/kafka/trogdor/common/TopologyTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.apache.kafka.trogdor.common;
+
+import org.apache.kafka.trogdor.agent.Agent;
+import org.apache.kafka.trogdor.basic.BasicNode;
+import org.apache.kafka.trogdor.basic.BasicTopology;
+
+import org.apache.kafka.trogdor.coordinator.Coordinator;
+import org.junit.Rule;
+import org.junit.rules.Timeout;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeMap;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TopologyTest {
+ @Rule
+ final public Timeout globalTimeout = Timeout.millis(120000);
+
+ @Test
+ public void testAgentNodeNames() throws Exception {
+ TreeMap<String, Node> nodes = new TreeMap<>();
+ final int numNodes = 5;
+ for (int i = 0; i < numNodes; i++) {
+ HashMap<String, String> conf = new HashMap<>();
+ if (i == 0) {
+ conf.put(Platform.Config.TROGDOR_COORDINATOR_PORT, String.valueOf(Coordinator.DEFAULT_PORT));
+ } else {
+ conf.put(Platform.Config.TROGDOR_AGENT_PORT, String.valueOf(Agent.DEFAULT_PORT));
+ }
+ BasicNode node = new BasicNode(String.format("node%02d", i),
+ String.format("node%d.example.com", i),
+ conf,
+ new HashSet<String>());
+ nodes.put(node.name(), node);
+ }
+ Topology topology = new BasicTopology(nodes);
+ Set<String> names = Topology.Util.agentNodeNames(topology);
+ assertEquals(4, names.size());
+ for (int i = 1; i < numNodes - 1; i++) {
+ assertTrue(names.contains(String.format("node%02d", i)));
+ }
+ }
+};
--
To stop receiving notification emails like this one, please contact
rsivaram@apache.org.