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