@Test public void testSwitchAdded() throws Exception { LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager(); Capture<OFMessage> wc; Capture<FloodlightContext> fc; Set<Short> qPorts; OFPhysicalPort ofpp = new OFPhysicalPort(); ofpp.setName("eth4242"); ofpp.setPortNumber((short)4242); ofpp.setHardwareAddress(HexString.fromHexString("5c:16:c7:00:00:01")); ofpp.setCurrentFeatures(0); ImmutablePort p1 = ImmutablePort.fromOFPhysicalPort(ofpp); IOFSwitch sw1 = createMockSwitch(1L); Map<Long, IOFSwitch> switches = new HashMap<Long, IOFSwitch>(); switches.put(1L, sw1); getMockFloodlightProvider().setSwitches(switches); List<Short> ports = new ArrayList<Short>(); for(short p=1; p<=20; ++p) { ports.add(p); } wc = new Capture<OFMessage>(CaptureType.ALL); fc = new Capture<FloodlightContext>(CaptureType.ALL); expect(sw1.getEnabledPortNumbers()).andReturn(ports).anyTimes(); expect(sw1.getPort(EasyMock.anyShort())).andReturn(p1).anyTimes(); sw1.write(capture(wc), capture(fc)); expectLastCall().anyTimes(); replay(sw1); linkDiscovery.switchActivated(sw1.getId()); verify(sw1); qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId()); assertNotNull(qPorts); assertFalse(qPorts.isEmpty()); Thread.sleep(100); qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId()); assertNotNull(qPorts); assertFalse(qPorts.isEmpty()); Thread.sleep(200); qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId()); assertNotNull(qPorts); assertTrue(qPorts.isEmpty()); assertTrue(wc.hasCaptured()); List<OFMessage> msgList = wc.getValues(); assertTrue(msgList.size() == ports.size() * 2); }
@Override public void switchAdded(long switchId) { }
LinkDiscoveryManager implements IOFMessageListener,
    IOFSwitchListener, IStorageSourceListener, ILinkDiscoveryService,
    IFloodlightModule, IInfoProvider { @Override public void switchAdded(long switchId) { } }
LinkDiscoveryManager implements IOFMessageListener,
    IOFSwitchListener, IStorageSourceListener, ILinkDiscoveryService,
    IFloodlightModule, IInfoProvider { @Override public void switchAdded(long switchId) { }  }
LinkDiscoveryManager implements IOFMessageListener,
    IOFSwitchListener, IStorageSourceListener, ILinkDiscoveryService,
    IFloodlightModule, IInfoProvider { @Override public void switchAdded(long switchId) { }  @Override OFPacketOut generateLLDPMessage(long sw, short port,
                                       boolean isStandard, boolean isReverse); int getLldpFrequency(); int getLldpTimeout(); @Override Map<NodePortTuple, Set<Link>> getPortLinks(); @Override Set<NodePortTuple> getSuppressLLDPsInfo(); @Override void AddToSuppressLLDPs(long sw, short port); @Override void RemoveFromSuppressLLDPs(long sw, short port); boolean isShuttingDown(); @Override boolean isTunnelPort(long sw, short port); @Override ILinkDiscovery.LinkType getLinkType(Link lt, LinkInfo info); @Override Set<Short> getQuarantinedPorts(long sw); @Override Map<Long, Set<Link>> getSwitchLinks(); @Override void addMACToIgnoreList(long mac, int ignoreBits); @Override boolean isAutoPortFastFeature(); @Override void setAutoPortFastFeature(boolean autoPortFastFeature); @Override void addListener(ILinkDiscoveryListener listener); @Override Map<Link, LinkInfo> getLinks(); @Override LinkInfo getLinkInfo(Link link); @Override String getName(); @Override Command receive(IOFSwitch sw, OFMessage msg,
                           FloodlightContext cntx); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override void switchPortChanged(long switchId,
            ImmutablePort port,
            IOFSwitch.PortChangeType type); @Override void switchAdded(long switchId); @Override void switchRemoved(long sw); @Override void switchActivated(long switchId); @Override void switchChanged(long switchId); void setStorageSource(IStorageSourceService storageSource); IStorageSourceService getStorageSource(); @Override void rowsModified(String tableName, Set<Object> rowKeys); @Override void rowsDeleted(String tableName, Set<Object> rowKeys); Long readLinkValidTime(Link lt); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override @LogMessageDocs({ @LogMessageDoc(level = "ERROR", message = "No storage source found.", explanation = "Storage source was not initialized; cannot initialize " + "link discovery.", recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG), @LogMessageDoc(level = "ERROR", message = "Error in installing listener for " + "switch config table {table}", explanation = "Failed to install storage notification for the " + "switch config table", recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG), @LogMessageDoc(level = "ERROR", message = "No storage source found.", explanation = "Storage source was not initialized; cannot initialize " + "link discovery.", recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG), @LogMessageDoc(level = "ERROR", message = "Exception in LLDP send timer.", explanation = "An unknown error occured while sending LLDP " + "messages to switches.", recommendation = LogMessageDoc.CHECK_SWITCH) }) void startUp(FloodlightModuleContext context); @Override Map<String, Object> getInfo(String type); }
LinkDiscoveryManager implements IOFMessageListener,
    IOFSwitchListener, IStorageSourceListener, ILinkDiscoveryService,
    IFloodlightModule, IInfoProvider { @Override public void switchAdded(long switchId) { }  @Override OFPacketOut generateLLDPMessage(long sw, short port,
                                       boolean isStandard, boolean isReverse); int getLldpFrequency(); int getLldpTimeout(); @Override Map<NodePortTuple, Set<Link>> getPortLinks(); @Override Set<NodePortTuple> getSuppressLLDPsInfo(); @Override void AddToSuppressLLDPs(long sw, short port); @Override void RemoveFromSuppressLLDPs(long sw, short port); boolean isShuttingDown(); @Override boolean isTunnelPort(long sw, short port); @Override ILinkDiscovery.LinkType getLinkType(Link lt, LinkInfo info); @Override Set<Short> getQuarantinedPorts(long sw); @Override Map<Long, Set<Link>> getSwitchLinks(); @Override void addMACToIgnoreList(long mac, int ignoreBits); @Override boolean isAutoPortFastFeature(); @Override void setAutoPortFastFeature(boolean autoPortFastFeature); @Override void addListener(ILinkDiscoveryListener listener); @Override Map<Link, LinkInfo> getLinks(); @Override LinkInfo getLinkInfo(Link link); @Override String getName(); @Override Command receive(IOFSwitch sw, OFMessage msg,
                           FloodlightContext cntx); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override void switchPortChanged(long switchId,
            ImmutablePort port,
            IOFSwitch.PortChangeType type); @Override void switchAdded(long switchId); @Override void switchRemoved(long sw); @Override void switchActivated(long switchId); @Override void switchChanged(long switchId); void setStorageSource(IStorageSourceService storageSource); IStorageSourceService getStorageSource(); @Override void rowsModified(String tableName, Set<Object> rowKeys); @Override void rowsDeleted(String tableName, Set<Object> rowKeys); Long readLinkValidTime(Link lt); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override @LogMessageDocs({ @LogMessageDoc(level = "ERROR", message = "No storage source found.", explanation = "Storage source was not initialized; cannot initialize " + "link discovery.", recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG), @LogMessageDoc(level = "ERROR", message = "Error in installing listener for " + "switch config table {table}", explanation = "Failed to install storage notification for the " + "switch config table", recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG), @LogMessageDoc(level = "ERROR", message = "No storage source found.", explanation = "Storage source was not initialized; cannot initialize " + "link discovery.", recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG), @LogMessageDoc(level = "ERROR", message = "Exception in LLDP send timer.", explanation = "An unknown error occured while sending LLDP " + "messages to switches.", recommendation = LogMessageDoc.CHECK_SWITCH) }) void startUp(FloodlightModuleContext context); @Override Map<String, Object> getInfo(String type); static final String MODULE_NAME; }