Search in sources :

Example 1 with LinkMessage

use of org.openkilda.simulator.messages.LinkMessage in project open-kilda by telstra.

the class SpeakerBoltTest method setUp.

@Before
public void setUp() throws Exception {
    mapper = new ObjectMapper();
    speakerBolt = new SpeakerBolt();
    speakerBolt.prepare(null, null, null);
    link = new LinkMessage(linkLatency, localLinkPort, peerSwitch, peerPort);
    links.add(link);
    switchMessage = new SwitchMessage(dpid, numOfPorts, links);
}
Also used : LinkMessage(org.openkilda.simulator.messages.LinkMessage) SwitchMessage(org.openkilda.simulator.messages.SwitchMessage) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 2 with LinkMessage

use of org.openkilda.simulator.messages.LinkMessage in project open-kilda by telstra.

the class SpeakerBolt method addSwitch.

protected List<Values> addSwitch(SwitchMessage switchMessage) throws Exception {
    ISwitchImpl sw = switches.get(switchMessage.getDpid());
    List<Values> values = new ArrayList<>();
    if (sw == null) {
        logger.info("switch does not exist, adding it");
        sw = new ISwitchImpl(switchMessage.getDpid(), switchMessage.getNumOfPorts(), PortStateType.DOWN);
        sw.activate();
        List<LinkMessage> links = switchMessage.getLinks();
        for (LinkMessage l : links) {
            IPortImpl localPort = sw.getPort(l.getLocalPort());
            localPort.setLatency(l.getLatency());
            localPort.setPeerPortNum(l.getPeerPort());
            localPort.setPeerSwitch(l.getPeerSwitch());
            localPort.enable();
        }
        switches.put(sw.getDpid().toString(), sw);
        values.add(new Values("INFO", makeSwitchMessage(sw, SwitchState.ADDED)));
        values.add(new Values("INFO", makeSwitchMessage(sw, SwitchState.ACTIVATED)));
        for (IPortImpl p : sw.getPorts()) {
            // TODO: see if OF sends DOWN
            PortChangeType changeType = p.isActive() ? PortChangeType.UP : PortChangeType.DOWN;
            if (changeType == PortChangeType.UP) {
                values.add(new Values("INFO", makePortMessage(sw, p.getNumber(), changeType)));
            }
        }
    }
    return values;
}
Also used : LinkMessage(org.openkilda.simulator.messages.LinkMessage) Values(org.apache.storm.tuple.Values)

Aggregations

LinkMessage (org.openkilda.simulator.messages.LinkMessage)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Values (org.apache.storm.tuple.Values)1 Before (org.junit.Before)1 SwitchMessage (org.openkilda.simulator.messages.SwitchMessage)1