LinkDiscoveryManager implements IOFMessageListener, IOFSwitchListener, 
IStorageSourceListener, ILinkDiscoveryService,
IFloodlightModule, IInfoProvider, IHAListener { @Override public void removedSwitch(IOFSwitch iofSwitch) { long sw = iofSwitch.getId(); evHistTopoSwitch(iofSwitch, EvAction.SWITCH_DISCONNECTED, "None"); List<Link> eraseList = new ArrayList<Link>(); lock.writeLock().lock(); try { if (switchLinks.containsKey(sw)) { if (log.isTraceEnabled()) { log.trace("Handle switchRemoved. Switch {}; removing links {}", HexString.toHexString(sw), switchLinks.get(sw)); } eraseList.addAll(switchLinks.get(sw)); deleteLinks(eraseList, "Switch Removed"); LDUpdate update = new LDUpdate(sw, null, UpdateOperation.SWITCH_REMOVED); updates.add(update); } } finally { lock.writeLock().unlock(); } }  int getLldpFrequency(); int getLldpTimeout(); Map<NodePortTuple, Set<Link>> getPortLinks(); Set<NodePortTuple> getSuppressLLDPsInfo(); void AddToSuppressLLDPs(long sw, short port); void RemoveFromSuppressLLDPs(long sw, short port); boolean isShuttingDown(); boolean isFastPort(long sw, short port); ILinkDiscovery.LinkType getLinkType(Link lt, LinkInfo info); Set<Short> getQuarantinedPorts(long sw); @Override String getName(); @Override Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); Map<Long, Set<Link>> getSwitchLinks(); @Override void addedSwitch(IOFSwitch sw); @Override void removedSwitch(IOFSwitch iofSwitch); @Override void switchPortChanged(Long switchId); Map<NodePortTuple, Set<Link>> getPortBroadcastDomainLinks(); @Override Map<Link, LinkInfo> getLinks(); Long readLinkValidTime(Link lt); @Override void addListener(ILinkDiscoveryListener listener); void addLinkDiscoveryAware(ILinkDiscoveryListener linkDiscoveryAwareComponent); void removeLinkDiscoveryAware(ILinkDiscoveryListener linkDiscoveryAwareComponent); void setStorageSource(IStorageSourceService storageSource); IStorageSourceService getStorageSource(); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override void rowsModified(String tableName, Set<Object> rowKeys); @Override void rowsDeleted(String tableName, Set<Object> rowKeys); @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); void evHistTopoCluster(long dpid, long clusterIdOld,
                                  long clusterIdNew, EvAction action, String reason); @Override Map<String, Object> getInfo(String type); @Override void roleChanged(Role oldRole, Role newRole); @Override void controllerNodeIPsChanged(
                                         Map<String, String> curControllerNodeIPs,
                                         Map<String, String> addedControllerNodeIPs,
                                         Map<String, String> removedControllerNodeIPs); boolean isAutoPortFastFeature(); void setAutoPortFastFeature(boolean autoPortFastFeature); public EventHistory<EventHistoryTopologySwitch> evHistTopologySwitch; public EventHistory<EventHistoryTopologyLink> evHistTopologyLink; public EventHistory<EventHistoryTopologyCluster> evHistTopologyCluster; public EventHistoryTopologySwitch evTopoSwitch; public EventHistoryTopologyLink evTopoLink; public EventHistoryTopologyCluster evTopoCluster; }
@Test public void testRemovedSwitch() { LinkDiscoveryManager topology = getTopology(); Link lt = new Link(1L, 2, 2L, 1); NodePortTuple srcNpt = new NodePortTuple(1L, 2); NodePortTuple dstNpt = new NodePortTuple(2L, 1); LinkInfo info = new LinkInfo(System.currentTimeMillis(), System.currentTimeMillis(), null, 0, 0); topology.addOrUpdateLink(lt, info); IOFSwitch sw1 = getMockFloodlightProvider().getSwitches().get(1L); IOFSwitch sw2 = getMockFloodlightProvider().getSwitches().get(2L); topology.removedSwitch(sw1); verify(sw1, sw2); assertNull(topology.switchLinks.get(lt.getSrc())); assertNull(topology.switchLinks.get(lt.getDst())); assertNull(topology.portLinks.get(srcNpt)); assertNull(topology.portLinks.get(dstNpt)); assertTrue(topology.links.isEmpty()); }