@Test public void addSwitch() throws Exception { speakerBolt.addSwitch(switchMessage); assertEquals(1, speakerBolt.switches.size()); ISwitchImpl sw = speakerBolt.switches.get(dpid); assertTrue(sw.isActive()); List<IPortImpl> ports = sw.getPorts(); assertEquals(numOfPorts, ports.size()); for (IPortImpl port : ports) { if (port.getNumber() != localLinkPort) { assertFalse(port.isActive()); assertFalse(port.isActiveIsl()); } else { assertTrue(port.isActive()); assertTrue(port.isActiveIsl()); } } }
protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; }
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; } }
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; }  }
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; }  ISwitchImpl getSwitch(SwitchId name); void doSimulatorCommand(Tuple tuple); void doCommand(Tuple tuple); @Override void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector); @Override void execute(Tuple tuple); @Override void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer); }
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; }  ISwitchImpl getSwitch(SwitchId name); void doSimulatorCommand(Tuple tuple); void doCommand(Tuple tuple); @Override void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector); @Override void execute(Tuple tuple); @Override void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer);  }