Search in sources :

Example 6 with Node

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

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) TextNode(com.fasterxml.jackson.databind.node.TextNode) 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