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));
}
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());
}
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));
}
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());
}
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 });
}
}
Aggregations