use of org.openkilda.simulator.messages.simulator.command.AddSwitchCommand in project open-kilda by telstra.
the class SpeakerBolt method doSimulatorCommand.
public void doSimulatorCommand(Tuple tuple) throws Exception {
List<Values> values = new ArrayList<>();
if (tuple.getFields().contains("command")) {
String command = tuple.getStringByField("command");
switch(command) {
case SimulatorCommands.DO_ADD_SWITCH:
// TODO: this is an ugly hack...
if (tuple.getValueByField("data") instanceof AddSwitchCommand) {
values = addSwitch((AddSwitchCommand) tuple.getValueByField("data"));
} else {
values = addSwitch((SwitchMessage) tuple.getValueByField("data"));
}
break;
case SimulatorCommands.DO_ADD_LINK:
values = addLink((AddLinkCommandMessage) tuple.getValueByField("data"));
break;
case SimulatorCommands.DO_PORT_MOD:
values = modPort((PortModMessage) tuple.getValueByField("data"));
break;
default:
logger.error(String.format("Uknown SimulatorCommand %s", command));
}
} else {
SimulatorMessage message = (SimulatorMessage) tuple.getValueByField("data");
if (message instanceof SwitchModMessage) {
SwitchModMessage switchModMessage = (SwitchModMessage) message;
ISwitchImpl sw = getSwitch(switchModMessage.getDpid());
// sw.mod(switchModMessage.getState());
} else {
logger.error("Unkown SimulatorMessage {}", message.getClass().getSimpleName());
}
}
if (values.size() > 0) {
for (Values value : values) {
logger.debug("emitting: {}", value);
collector.emit(SimulatorTopology.KAFKA_BOLT_STREAM, tuple, value);
}
}
}
Aggregations