use of org.apache.kafka.trogdor.common.Topology 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 });
}
}
use of org.apache.kafka.trogdor.common.Topology 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 });
}
}
Aggregations