Search in sources :

Example 1 with BasicTopology

use of org.apache.kafka.trogdor.basic.BasicTopology in project kafka by apache.

the class AgentTest method createBasicPlatform.

private static BasicPlatform createBasicPlatform(Scheduler scheduler) {
    TreeMap<String, Node> nodes = new TreeMap<>();
    HashMap<String, String> config = new HashMap<>();
    config.put(Platform.Config.TROGDOR_AGENT_PORT, Integer.toString(Agent.DEFAULT_PORT));
    nodes.put("node01", new BasicNode("node01", "localhost", config, Collections.emptySet()));
    BasicTopology topology = new BasicTopology(nodes);
    return new BasicPlatform("node01", topology, scheduler, new BasicPlatform.ShellCommandRunner());
}
Also used : BasicPlatform(org.apache.kafka.trogdor.basic.BasicPlatform) BasicTopology(org.apache.kafka.trogdor.basic.BasicTopology) HashMap(java.util.HashMap) BasicNode(org.apache.kafka.trogdor.basic.BasicNode) Node(org.apache.kafka.trogdor.common.Node) TextNode(com.fasterxml.jackson.databind.node.TextNode) BasicNode(org.apache.kafka.trogdor.basic.BasicNode) TreeMap(java.util.TreeMap)

Example 2 with BasicTopology

use of org.apache.kafka.trogdor.basic.BasicTopology in project apache-kafka-on-k8s by banzaicloud.

the class AgentTest method createBasicPlatform.

private static BasicPlatform createBasicPlatform(Scheduler scheduler) {
    TreeMap<String, Node> nodes = new TreeMap<>();
    HashMap<String, String> config = new HashMap<>();
    nodes.put("node01", new BasicNode("node01", "localhost", config, Collections.<String>emptySet()));
    BasicTopology topology = new BasicTopology(nodes);
    return new BasicPlatform("node01", topology, scheduler, new BasicPlatform.ShellCommandRunner());
}
Also used : BasicPlatform(org.apache.kafka.trogdor.basic.BasicPlatform) BasicTopology(org.apache.kafka.trogdor.basic.BasicTopology) HashMap(java.util.HashMap) BasicNode(org.apache.kafka.trogdor.basic.BasicNode) Node(org.apache.kafka.trogdor.common.Node) BasicNode(org.apache.kafka.trogdor.basic.BasicNode) TreeMap(java.util.TreeMap)

Example 3 with BasicTopology

use of org.apache.kafka.trogdor.basic.BasicTopology in project apache-kafka-on-k8s by banzaicloud.

the class TopologyTest method testAgentNodeNames.

@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)));
    }
}
Also used : BasicTopology(org.apache.kafka.trogdor.basic.BasicTopology) HashMap(java.util.HashMap) BasicNode(org.apache.kafka.trogdor.basic.BasicNode) BasicNode(org.apache.kafka.trogdor.basic.BasicNode) BasicTopology(org.apache.kafka.trogdor.basic.BasicTopology) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 4 with BasicTopology

use of org.apache.kafka.trogdor.basic.BasicTopology in project kafka by apache.

the class TopologyTest method testAgentNodeNames.

@Test
public void testAgentNodeNames() {
    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<>());
        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)));
    }
}
Also used : BasicTopology(org.apache.kafka.trogdor.basic.BasicTopology) HashMap(java.util.HashMap) BasicNode(org.apache.kafka.trogdor.basic.BasicNode) BasicNode(org.apache.kafka.trogdor.basic.BasicNode) BasicTopology(org.apache.kafka.trogdor.basic.BasicTopology) TreeMap(java.util.TreeMap) Test(org.junit.jupiter.api.Test)

Aggregations

HashMap (java.util.HashMap)4 TreeMap (java.util.TreeMap)4 BasicNode (org.apache.kafka.trogdor.basic.BasicNode)4 BasicTopology (org.apache.kafka.trogdor.basic.BasicTopology)4 BasicPlatform (org.apache.kafka.trogdor.basic.BasicPlatform)2 Node (org.apache.kafka.trogdor.common.Node)2 TextNode (com.fasterxml.jackson.databind.node.TextNode)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1