Search in sources :

Example 1 with DiscoverIslCommandData

use of org.openkilda.messaging.command.discovery.DiscoverIslCommandData in project open-kilda by telstra.

the class SpeakerBolt method doCommand.

public void doCommand(Tuple tuple) throws Exception {
    String command = tuple.getStringByField(TupleFields.COMMAND.name());
    List<Values> values = new ArrayList<>();
    if (command.equals(SimulatorCommands.DO_ADD_SWITCH)) {
        values = addSwitch((SwitchMessage) tuple.getValueByField(TupleFields.DATA.name()));
        if (values.size() > 0) {
            for (Values value : values) {
                logger.debug("emitting: {}", value);
                collector.emit(SimulatorTopology.KAFKA_BOLT_STREAM, tuple, value);
            }
        }
        return;
    } else if (command.equals(Commands.DO_DISCOVER_ISL_P2_COMMAND.name())) {
        discoverIslPartTwo(tuple, (IslInfoData) tuple.getValueByField(TupleFields.DATA.name()));
        return;
    }
    CommandData data = (CommandData) tuple.getValueByField(TupleFields.DATA.name());
    if (command.equals(Commands.DO_DELETE_FLOW.name())) {
    } else if (command.equals(Commands.DO_DISCOVER_ISL_COMMAND.name())) {
        discoverIsl(tuple, (DiscoverIslCommandData) data);
    } else if (command.equals(Commands.DO_DISCOVER_PATH_COMMAND.name())) {
    } else if (command.equals(Commands.DO_INSTALL_EGRESS_FLOW.name())) {
    } else if (command.equals(Commands.DO_INSTALL_INGRESS_FLOW.name())) {
    } else if (command.equals(Commands.DO_INSTALL_ONESWITCH_FLOW.name())) {
    } else if (command.equals(Commands.DO_INSTALL_TRANSIT_FLOW.name())) {
    } else {
        logger.error("Unknown switch command: {}".format(command));
        return;
    }
    if (values.size() > 0) {
        for (Values value : values) {
            logger.debug("emitting: {}", value);
            collector.emit(SimulatorTopology.KAFKA_BOLT_STREAM, tuple, value);
        }
    }
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) Values(org.apache.storm.tuple.Values) SwitchMessage(org.openkilda.simulator.messages.SwitchMessage) CommandData(org.openkilda.messaging.command.CommandData) DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData)

Example 2 with DiscoverIslCommandData

use of org.openkilda.messaging.command.discovery.DiscoverIslCommandData in project open-kilda by telstra.

the class DiscoverISLCommandDataTest method switchId.

@Test
public void switchId() throws Exception {
    DiscoverIslCommandData data = new DiscoverIslCommandData();
    data.setSwitchId(switchId);
    assertEquals(switchId, data.getSwitchId());
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) Test(org.junit.Test)

Example 3 with DiscoverIslCommandData

use of org.openkilda.messaging.command.discovery.DiscoverIslCommandData in project open-kilda by telstra.

the class DiscoverISLCommandDataTest method portNo.

@Test
public void portNo() throws Exception {
    DiscoverIslCommandData data = new DiscoverIslCommandData();
    data.setPortNo(outputPort);
    assertEquals(outputPort, data.getPortNo());
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) Test(org.junit.Test)

Example 4 with DiscoverIslCommandData

use of org.openkilda.messaging.command.discovery.DiscoverIslCommandData in project open-kilda by telstra.

the class RecordHandler method doDiscoverIslCommand.

private void doDiscoverIslCommand(CommandData data) {
    DiscoverIslCommandData command = (DiscoverIslCommandData) data;
    logger.debug("sending discover ISL to {}", command);
    String switchId = command.getSwitchId();
    boolean result = context.getPathVerificationService().sendDiscoveryMessage(DatapathId.of(switchId), OFPort.of(command.getPortNo()));
    if (result) {
        logger.debug("packet_out was sent to {}", switchId);
    } else {
        logger.warn("packet_out was not sent to {}-{}", switchId, command.getPortNo());
    }
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData)

Example 5 with DiscoverIslCommandData

use of org.openkilda.messaging.command.discovery.DiscoverIslCommandData in project open-kilda by telstra.

the class CommandBolt method processCommand.

protected void processCommand(Tuple tuple) throws Exception {
    CommandMessage command = Utils.MAPPER.readValue(getJson(tuple), CommandMessage.class);
    if (command.getDestination() == Destination.CONTROLLER) {
        CommandData data = command.getData();
        Commands switchCommand;
        String sw;
        if (data instanceof DiscoverIslCommandData) {
            switchCommand = Commands.DO_DISCOVER_ISL_COMMAND;
            sw = ((DiscoverIslCommandData) data).getSwitchId();
        } else if (data instanceof DiscoverPathCommandData) {
            switchCommand = Commands.DO_DISCOVER_PATH_COMMAND;
            sw = ((DiscoverPathCommandData) data).getSrcSwitchId();
        } else if (data instanceof InstallIngressFlow) {
            switchCommand = Commands.DO_INSTALL_INGRESS_FLOW;
            sw = ((InstallIngressFlow) data).getSwitchId();
        } else if (data instanceof InstallEgressFlow) {
            switchCommand = Commands.DO_INSTALL_EGRESS_FLOW;
            sw = ((InstallEgressFlow) data).getSwitchId();
        } else if (data instanceof InstallTransitFlow) {
            switchCommand = Commands.DO_INSTALL_TRANSIT_FLOW;
            sw = ((InstallTransitFlow) data).getSwitchId();
        } else if (data instanceof InstallOneSwitchFlow) {
            switchCommand = Commands.DO_INSTALL_ONESWITCH_FLOW;
            sw = ((InstallOneSwitchFlow) data).getSwitchId();
        } else if (data instanceof RemoveFlow) {
            switchCommand = Commands.DO_DELETE_FLOW;
            sw = ((RemoveFlow) data).getSwitchId();
        } else {
            logger.error("unknown data type: {}", data.toString());
            throw new Exception("Unknown command {}".format(data.getClass().getSimpleName()));
        }
        List<Integer> taskIDs = collector.emit(SimulatorTopology.COMMAND_BOLT_STREAM, tuple, new Values(sw.toLowerCase(), switchCommand.name(), command.getData()));
    // logger.info("{}:  {} - {}", switchCommand.name(), sw, command.getData().toString());
    }
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) Values(org.apache.storm.tuple.Values) CommandMessage(org.openkilda.messaging.command.CommandMessage) Commands(org.openkilda.simulator.classes.Commands) CommandData(org.openkilda.messaging.command.CommandData) DiscoverPathCommandData(org.openkilda.messaging.command.discovery.DiscoverPathCommandData) DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) DiscoverPathCommandData(org.openkilda.messaging.command.discovery.DiscoverPathCommandData)

Aggregations

DiscoverIslCommandData (org.openkilda.messaging.command.discovery.DiscoverIslCommandData)6 Test (org.junit.Test)3 Values (org.apache.storm.tuple.Values)2 CommandData (org.openkilda.messaging.command.CommandData)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 DiscoverPathCommandData (org.openkilda.messaging.command.discovery.DiscoverPathCommandData)1 Commands (org.openkilda.simulator.classes.Commands)1 SwitchMessage (org.openkilda.simulator.messages.SwitchMessage)1