Search in sources :

Example 1 with Node

use of org.apache.kafka.trogdor.common.Node in project kafka by apache.

the class DegradedNetworkFaultWorker method stop.

@Override
public void stop(Platform platform) throws Exception {
    log.info("Deactivating DegradedNetworkFaultWorker {}.", id);
    this.status.update(new TextNode("disabling traffic control " + id));
    Node curNode = platform.curNode();
    DegradedNetworkFaultSpec.NodeDegradeSpec nodeSpec = nodeSpecs.get(curNode.name());
    if (nodeSpec != null) {
        for (String device : devicesForSpec(nodeSpec)) {
            disableTrafficControl(platform, device);
        }
    }
    this.status.update(new TextNode("disabled traffic control " + id));
}
Also used : Node(org.apache.kafka.trogdor.common.Node) TextNode(com.fasterxml.jackson.databind.node.TextNode) TextNode(com.fasterxml.jackson.databind.node.TextNode)

Example 2 with Node

use of org.apache.kafka.trogdor.common.Node 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 3 with Node

use of org.apache.kafka.trogdor.common.Node in project kafka by apache.

the class DegradedNetworkFaultWorker method start.

@Override
public void start(Platform platform, WorkerStatusTracker status, KafkaFutureImpl<String> haltFuture) throws Exception {
    log.info("Activating DegradedNetworkFaultWorker {}.", id);
    this.status = status;
    this.status.update(new TextNode("enabling traffic control " + id));
    Node curNode = platform.curNode();
    DegradedNetworkFaultSpec.NodeDegradeSpec nodeSpec = nodeSpecs.get(curNode.name());
    if (nodeSpec != null) {
        for (String device : devicesForSpec(nodeSpec)) {
            if (nodeSpec.latencyMs() < 0 || nodeSpec.rateLimitKbit() < 0) {
                throw new RuntimeException("Expected non-negative values for latencyMs and rateLimitKbit, but got " + nodeSpec);
            } else {
                enableTrafficControl(platform, device, nodeSpec.latencyMs(), nodeSpec.rateLimitKbit());
            }
        }
    }
    this.status.update(new TextNode("enabled traffic control " + id));
}
Also used : Node(org.apache.kafka.trogdor.common.Node) TextNode(com.fasterxml.jackson.databind.node.TextNode) TextNode(com.fasterxml.jackson.databind.node.TextNode)

Example 4 with Node

use of org.apache.kafka.trogdor.common.Node 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 5 with Node

use of org.apache.kafka.trogdor.common.Node in project apache-kafka-on-k8s by banzaicloud.

the class NetworkPartitionFaultWorker method runIptablesCommands.

private void runIptablesCommands(Platform platform, String iptablesAction) throws Exception {
    Node curNode = platform.curNode();
    Topology topology = platform.topology();
    TreeSet<String> toBlock = new TreeSet<>();
    for (Set<String> partitionSet : partitionSets) {
        if (!partitionSet.contains(curNode.name())) {
            for (String nodeName : partitionSet) {
                toBlock.add(nodeName);
            }
        }
    }
    for (String nodeName : toBlock) {
        Node node = topology.node(nodeName);
        InetAddress addr = InetAddress.getByName(node.hostname());
        platform.runCommand(new String[] { "sudo", "iptables", iptablesAction, "INPUT", "-p", "tcp", "-s", addr.getHostAddress(), "-j", "DROP", "-m", "comment", "--comment", nodeName });
    }
}
Also used : TreeSet(java.util.TreeSet) Node(org.apache.kafka.trogdor.common.Node) Topology(org.apache.kafka.trogdor.common.Topology) InetAddress(java.net.InetAddress)

Aggregations

Node (org.apache.kafka.trogdor.common.Node)6 TextNode (com.fasterxml.jackson.databind.node.TextNode)4 InetAddress (java.net.InetAddress)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2 BasicNode (org.apache.kafka.trogdor.basic.BasicNode)2 BasicPlatform (org.apache.kafka.trogdor.basic.BasicPlatform)2 BasicTopology (org.apache.kafka.trogdor.basic.BasicTopology)2 Topology (org.apache.kafka.trogdor.common.Topology)2