|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.floodlightcontroller.linkdiscovery.internal.LinkDiscoveryManager
public class LinkDiscoveryManager
This class sends out LLDP messages containing the sending switch's datapath id as well as the outgoing port number. Received LLrescDP messages that match a known switch cause a new LinkTuple to be created according to the invariant rules listed below. This new LinkTuple is also passed to routing if it exists to trigger updates. This class also handles removing links that are associated to switch ports that go down, and switches that are disconnected. Invariants: -portLinks and switchLinks will not contain empty Sets outside of critical sections -portLinks contains LinkTuples where one of the src or dst SwitchPortTuple matches the map key -switchLinks contains LinkTuples where one of the src or dst SwitchPortTuple's id matches the switch id -Each LinkTuple will be indexed into switchLinks for both src.id and dst.id, and portLinks for each src and dst -The updates queue is only added to from within a held write lock
Nested Class Summary | |
---|---|
class |
LinkDiscoveryManager.DirectLinkEvent
|
protected class |
LinkDiscoveryManager.QuarantineWorker
Quarantine Ports. |
Nested classes/interfaces inherited from interface net.floodlightcontroller.core.IListener |
---|
IListener.Command |
Field Summary | |
---|---|
protected boolean |
AUTOPORTFAST_DEFAULT
Flag to indicate if automatic port fast is enabled or not. |
protected boolean |
autoPortFastFeature
|
protected int |
BDDP_TASK_INTERVAL
|
protected int |
BDDP_TASK_SIZE
|
protected SingletonTask |
bddpTask
Quarantine task |
protected LLDPTLV |
controllerTLV
|
protected IDebugCounterService |
debugCounters
|
protected IDebugEventService |
debugEvents
|
protected int |
DISCOVERY_TASK_INTERVAL
|
protected SingletonTask |
discoveryTask
|
protected IEventUpdater<LinkDiscoveryManager.DirectLinkEvent> |
evDirectLink
|
protected static int |
EVENT_HISTORY_SIZE
|
protected IFloodlightProviderService |
floodlightProvider
|
protected java.util.Set<net.floodlightcontroller.linkdiscovery.internal.LinkDiscoveryManager.MACRange> |
ignoreMACSet
|
protected int |
LINK_TIMEOUT
|
protected java.util.ArrayList<ILinkDiscoveryListener> |
linkDiscoveryAware
|
protected java.util.Map<Link,LinkInfo> |
links
Map from link to the most recent time it was verified functioning |
protected int |
LLDP_TO_ALL_INTERVAL
|
protected int |
LLDP_TO_KNOWN_INTERVAL
|
protected long |
lldpClock
|
protected java.util.concurrent.locks.ReentrantReadWriteLock |
lock
|
protected static org.slf4j.Logger |
log
|
protected java.util.concurrent.LinkedBlockingQueue<NodePortTuple> |
maintenanceQueue
|
static java.lang.String |
MODULE_NAME
|
protected static INotificationManager |
notifier
|
protected java.util.Map<NodePortTuple,java.util.Set<Link>> |
portLinks
Map from a id:port to the set of links containing it as an endpoint |
protected java.util.concurrent.LinkedBlockingQueue<NodePortTuple> |
quarantineQueue
A list of ports that are quarantined for discovering links through them. |
protected IRestApiService |
restApi
|
protected IFloodlightProviderService.Role |
role
|
protected boolean |
shuttingDown
|
protected IStorageSourceService |
storageSource
|
protected java.util.Set<NodePortTuple> |
suppressLinkDiscovery
List of ports through which LLDP/BDDPs are not sent. |
protected java.util.Map<java.lang.Long,java.util.Set<Link>> |
switchLinks
Map from switch id to a set of all links with it as an endpoint |
protected IThreadPoolService |
threadPool
|
protected java.util.concurrent.BlockingQueue<ILinkDiscovery.LDUpdate> |
updates
|
protected java.lang.Thread |
updatesThread
|
Constructor Summary | |
---|---|
LinkDiscoveryManager()
|
Method Summary | |
---|---|
void |
addListener(ILinkDiscoveryListener listener)
Adds a listener to listen for ILinkDiscoveryService messages |
void |
addMACToIgnoreList(long mac,
int ignoreBits)
addMACToIgnoreList is a service provided by LinkDiscovery to ignore certain packets early in the packet-in processing chain. |
protected boolean |
addOrUpdateLink(Link lt,
LinkInfo newInfo)
|
protected void |
addToMaintenanceQueue(NodePortTuple npt)
Add a switch port to maintenance queue. |
protected void |
addToQuarantineQueue(NodePortTuple npt)
Add a switch port to the quarantine queue. |
void |
AddToSuppressLLDPs(long sw,
int port)
Add a switch port to the suppressed LLDP list. |
protected void |
deleteLink(Link link,
java.lang.String reason)
Delete a link |
protected void |
deleteLinks(java.util.List<Link> links,
java.lang.String reason)
Removes links from memory and storage. |
protected void |
deleteLinks(java.util.List<Link> links,
java.lang.String reason,
java.util.List<ILinkDiscovery.LDUpdate> updateList)
Removes links from memory and storage. |
protected void |
deleteLinksOnPort(NodePortTuple npt,
java.lang.String reason)
Delete links incident on a given switch port. |
protected void |
discover(long sw,
int port)
|
protected void |
discover(NodePortTuple npt)
|
protected void |
discoverLinks()
|
protected void |
discoverOnAllPorts()
Send LLDPs to all switch-ports |
OFPacketOut |
generateLLDPMessage(long sw,
int port,
boolean isStandard,
boolean isReverse)
Returns OFPacketOut which contains the LLDP data corresponding to switchport (sw, port). |
protected java.util.List<OFAction> |
getDiscoveryActions(IOFSwitch sw,
OFPhysicalPort port)
Get the actions for packet-out corresponding to a specific port. |
java.util.Map<java.lang.String,java.lang.Object> |
getInfo(java.lang.String type)
Called when rest API requests information of a particular type |
LinkInfo |
getLinkInfo(Link link)
Retrieves the link info for a given link |
java.util.Map<Link,LinkInfo> |
getLinks()
Retrieves a map of all known link connections between OpenFlow switches and the associated info (valid time, port states) for the link. |
ILinkDiscovery.LinkType |
getLinkType(Link lt,
LinkInfo info)
Returns link type of a given link |
int |
getLldpFrequency()
Get the LLDP sending period in seconds. |
int |
getLldpTimeout()
Get the LLDP timeout value in seconds |
java.util.Collection<java.lang.Class<? extends IFloodlightService>> |
getModuleDependencies()
Get a list of Modules that this module depends on. |
java.util.Collection<java.lang.Class<? extends IFloodlightService>> |
getModuleServices()
Return the list of interfaces that this module implements. |
java.lang.String |
getName()
The name assigned to this listener |
java.util.Map<NodePortTuple,java.util.Set<Link>> |
getPortLinks()
Get the map of node-port tuples from link DB |
java.util.Set<java.lang.Integer> |
getQuarantinedPorts(long sw)
Get the set of quarantined ports on a switch |
java.util.Map<java.lang.Class<? extends IFloodlightService>,IFloodlightService> |
getServiceImpls()
Instantiate (as needed) and return objects that implement each of the services exported by this module. |
IStorageSourceService |
getStorageSource()
Gets the storage source for this ITopology |
java.util.Set<NodePortTuple> |
getSuppressLLDPsInfo()
Retrieves a set of all switch ports on which lldps are suppressed. |
java.util.Map<java.lang.Long,java.util.Set<Link>> |
getSwitchLinks()
Returns an unmodifiable map from switch id to a set of all links with it as an endpoint. |
protected ILinkDiscovery.UpdateOperation |
getUpdateOperation(int srcPortState)
|
protected ILinkDiscovery.UpdateOperation |
getUpdateOperation(int srcPortState,
int dstPortState)
|
protected IListener.Command |
handlePacketIn(long sw,
OFPacketIn pi,
FloodlightContext cntx)
|
void |
init(FloodlightModuleContext context)
This is a hook for each module to do its internal initialization, e.g., call setService(context.getService("Service")) All module dependencies are resolved when this is called, but not every module is initialized. |
boolean |
isAutoPortFastFeature()
Get the status of auto port fast feature. |
boolean |
isCallbackOrderingPostreq(OFType type,
java.lang.String name)
Check if the module called name is a callback ordering post-requisite for this module. |
boolean |
isCallbackOrderingPrereq(OFType type,
java.lang.String name)
Check if the module called name is a callback ordering prerequisite for this module. |
protected boolean |
isIncomingDiscoveryAllowed(long sw,
int port,
boolean isStandard)
Check if incoming discovery messages are enabled or not. |
protected boolean |
isLinkAllowed(long src,
int srcPort,
long dst,
int dstPort)
This method is used to specifically ignore/consider specific links. |
protected boolean |
isLinkDiscoverySuppressed(long sw,
int portNumber)
|
protected boolean |
isOutgoingDiscoveryAllowed(long sw,
int port,
boolean isStandard,
boolean isReverse)
Check if outgoing discovery messages are enabled or not. |
boolean |
isShuttingDown()
|
boolean |
isTunnelPort(long sw,
int port)
Returns if a given switchport is a tunnel endpoint or not |
protected void |
processBDDPLists()
This method processes the quarantine list in bursts. |
java.lang.Long |
readLinkValidTime(Link lt)
|
protected void |
readTopologyConfigFromStorage()
|
IListener.Command |
receive(IOFSwitch sw,
OFMessage msg,
FloodlightContext cntx)
This is the method Floodlight uses to call listeners with OpenFlow messages |
protected void |
removeFromMaintenanceQueue(NodePortTuple npt)
Remove a switch port from maintenance queue. |
protected void |
removeFromQuarantineQueue(NodePortTuple npt)
Remove a switch port from the quarantine queue. |
void |
RemoveFromSuppressLLDPs(long sw,
int port)
Remove a switch port from the suppressed LLDP list. |
protected void |
removeLinkFromStorage(Link lt)
Removes a link from storage using an asynchronous call. |
void |
rowsDeleted(java.lang.String tableName,
java.util.Set<java.lang.Object> rowKeys)
Called when a new row is deleted from the table. |
void |
rowsModified(java.lang.String tableName,
java.util.Set<java.lang.Object> rowKeys)
Called when rows are inserted or updated in the table. |
protected void |
sendDiscoveryMessage(long sw,
int port,
boolean isStandard,
boolean isReverse)
Send link discovery message out of a given switch port. |
void |
setAutoPortFastFeature(boolean autoPortFastFeature)
Set the state for auto port fast feature. |
protected void |
setControllerTLV()
|
void |
setStorageSource(IStorageSourceService storageSource)
Sets the IStorageSource to use for Topology |
void |
startUp(FloodlightModuleContext context)
This is a hook for each module to do its external initializations, e.g., register for callbacks or query for state in other modules It is expected that this function will not block and that modules that want non-event driven CPU will spawn their own threads. |
void |
switchActivated(long switchId)
Fired when a switch becomes active *on the local controller*, I.e., the switch is connected to the local controller and is in MASTER mode |
void |
switchAdded(long switchId)
Fired when switch becomes known to the controller cluster. |
void |
switchChanged(long switchId)
Fired when any non-port related information (e.g., attributes, features) change after a switchAdded TODO: currently unused |
void |
switchPortChanged(long switchId,
ImmutablePort port,
IOFSwitch.PortChangeType type)
We don't react the port changed notifications here. |
void |
switchRemoved(long sw)
Fired when a switch disconnects from the cluster , |
protected void |
timeoutLinks()
Iterates through the list of links and deletes if the last discovery message reception time exceeds timeout values. |
protected boolean |
updateLink(Link lt,
LinkInfo oldInfo,
LinkInfo newInfo)
|
protected void |
writeLinkToStorage(Link lt,
LinkInfo linkInfo)
Writes a LinkTuple and corresponding LinkInfo to storage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.slf4j.Logger log
protected static final INotificationManager notifier
public static final java.lang.String MODULE_NAME
protected IEventUpdater<LinkDiscoveryManager.DirectLinkEvent> evDirectLink
protected IFloodlightProviderService floodlightProvider
protected IStorageSourceService storageSource
protected IThreadPoolService threadPool
protected IRestApiService restApi
protected IDebugCounterService debugCounters
protected IDebugEventService debugEvents
protected IFloodlightProviderService.Role role
protected static int EVENT_HISTORY_SIZE
protected SingletonTask discoveryTask
protected final int DISCOVERY_TASK_INTERVAL
protected final int LINK_TIMEOUT
protected final int LLDP_TO_ALL_INTERVAL
protected long lldpClock
protected final int LLDP_TO_KNOWN_INTERVAL
protected LLDPTLV controllerTLV
protected java.util.concurrent.locks.ReentrantReadWriteLock lock
protected boolean AUTOPORTFAST_DEFAULT
protected boolean autoPortFastFeature
protected java.util.Map<Link,LinkInfo> links
protected java.util.Map<java.lang.Long,java.util.Set<Link>> switchLinks
protected java.util.Map<NodePortTuple,java.util.Set<Link>> portLinks
protected volatile boolean shuttingDown
protected java.util.ArrayList<ILinkDiscoveryListener> linkDiscoveryAware
protected java.util.concurrent.BlockingQueue<ILinkDiscovery.LDUpdate> updates
protected java.lang.Thread updatesThread
protected java.util.Set<NodePortTuple> suppressLinkDiscovery
protected java.util.concurrent.LinkedBlockingQueue<NodePortTuple> quarantineQueue
protected java.util.concurrent.LinkedBlockingQueue<NodePortTuple> maintenanceQueue
protected SingletonTask bddpTask
protected final int BDDP_TASK_INTERVAL
protected final int BDDP_TASK_SIZE
protected java.util.Set<net.floodlightcontroller.linkdiscovery.internal.LinkDiscoveryManager.MACRange> ignoreMACSet
Constructor Detail |
---|
public LinkDiscoveryManager()
Method Detail |
---|
public OFPacketOut generateLLDPMessage(long sw, int port, boolean isStandard, boolean isReverse)
ILinkDiscoveryService
generateLLDPMessage
in interface ILinkDiscoveryService
public int getLldpFrequency()
public int getLldpTimeout()
public java.util.Map<NodePortTuple,java.util.Set<Link>> getPortLinks()
ILinkDiscoveryService
getPortLinks
in interface ILinkDiscoveryService
public java.util.Set<NodePortTuple> getSuppressLLDPsInfo()
ILinkDiscoveryService
getSuppressLLDPsInfo
in interface ILinkDiscoveryService
public void AddToSuppressLLDPs(long sw, int port)
AddToSuppressLLDPs
in interface ILinkDiscoveryService
public void RemoveFromSuppressLLDPs(long sw, int port)
RemoveFromSuppressLLDPs
in interface ILinkDiscoveryService
public boolean isShuttingDown()
public boolean isTunnelPort(long sw, int port)
ILinkDiscoveryService
isTunnelPort
in interface ILinkDiscoveryService
public ILinkDiscovery.LinkType getLinkType(Link lt, LinkInfo info)
ILinkDiscoveryService
getLinkType
in interface ILinkDiscoveryService
public java.util.Set<java.lang.Integer> getQuarantinedPorts(long sw)
ILinkDiscoveryService
getQuarantinedPorts
in interface ILinkDiscoveryService
public java.util.Map<java.lang.Long,java.util.Set<Link>> getSwitchLinks()
ILinkDiscoveryService
getSwitchLinks
in interface ILinkDiscoveryService
public void addMACToIgnoreList(long mac, int ignoreBits)
ILinkDiscoveryService
addMACToIgnoreList
in interface ILinkDiscoveryService
mac
- The base MAC address that is to be ignoredignoreBits
- The number of LSBs to ignore. A value of 0 will add
only one MAC address 'mac' to ignore list. A value of 48 will add
ALL MAC addresses to the ignore list. This will cause a drop of
ALL packet ins.public boolean isAutoPortFastFeature()
ILinkDiscoveryService
isAutoPortFastFeature
in interface ILinkDiscoveryService
public void setAutoPortFastFeature(boolean autoPortFastFeature)
ILinkDiscoveryService
setAutoPortFastFeature
in interface ILinkDiscoveryService
public void addListener(ILinkDiscoveryListener listener)
ILinkDiscoveryService
addListener
in interface ILinkDiscoveryService
listener
- The listener that wants the notificationspublic java.util.Map<Link,LinkInfo> getLinks()
ILinkDiscoveryService
getLinks
in interface ILinkDiscoveryService
public LinkInfo getLinkInfo(Link link)
ILinkDiscoveryService
getLinkInfo
in interface ILinkDiscoveryService
link
- link for which the link info should be returned
public java.lang.String getName()
IListener
getName
in interface IListener<OFType>
public IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx)
IOFMessageListener
receive
in interface IOFMessageListener
sw
- the OpenFlow switch that sent this messagemsg
- the messagecntx
- a Floodlight message context object you can use to pass
information between listeners
public boolean isCallbackOrderingPrereq(OFType type, java.lang.String name)
IListener
isCallbackOrderingPrereq
in interface IListener<OFType>
type
- the object type to which this appliesname
- the name of the module
public boolean isCallbackOrderingPostreq(OFType type, java.lang.String name)
IListener
isCallbackOrderingPostreq
in interface IListener<OFType>
type
- the object type to which this appliesname
- the name of the module
protected IListener.Command handlePacketIn(long sw, OFPacketIn pi, FloodlightContext cntx)
protected boolean isLinkDiscoverySuppressed(long sw, int portNumber)
protected void discoverLinks()
protected void addToQuarantineQueue(NodePortTuple npt)
npt
- protected void removeFromQuarantineQueue(NodePortTuple npt)
protected void addToMaintenanceQueue(NodePortTuple npt)
npt
- protected void removeFromMaintenanceQueue(NodePortTuple npt)
npt
- protected void processBDDPLists()
protected void discover(NodePortTuple npt)
protected void discover(long sw, int port)
protected boolean isIncomingDiscoveryAllowed(long sw, int port, boolean isStandard)
sw
- port
- isStandard
-
protected boolean isOutgoingDiscoveryAllowed(long sw, int port, boolean isStandard, boolean isReverse)
sw
- port
- isStandard
- isReverse
-
protected java.util.List<OFAction> getDiscoveryActions(IOFSwitch sw, OFPhysicalPort port)
port
-
protected void sendDiscoveryMessage(long sw, int port, boolean isStandard, boolean isReverse)
sw
- port
- isStandard
- indicates standard or modified LLDPisReverse
- indicates whether the LLDP was sent as a responseprotected void discoverOnAllPorts()
protected ILinkDiscovery.UpdateOperation getUpdateOperation(int srcPortState, int dstPortState)
protected ILinkDiscovery.UpdateOperation getUpdateOperation(int srcPortState)
protected boolean isLinkAllowed(long src, int srcPort, long dst, int dstPort)
protected boolean updateLink(Link lt, LinkInfo oldInfo, LinkInfo newInfo)
protected boolean addOrUpdateLink(Link lt, LinkInfo newInfo)
protected void deleteLink(Link link, java.lang.String reason)
link
- - link to be deleted.reason
- - reason why the link is deleted.protected void deleteLinks(java.util.List<Link> links, java.lang.String reason)
links
- The List of @LinkTuple to delete.protected void deleteLinks(java.util.List<Link> links, java.lang.String reason, java.util.List<ILinkDiscovery.LDUpdate> updateList)
links
- The List of @LinkTuple to delete.protected void deleteLinksOnPort(NodePortTuple npt, java.lang.String reason)
npt
- reason
- protected void timeoutLinks()
protected void setControllerTLV()
public void switchPortChanged(long switchId, ImmutablePort port, IOFSwitch.PortChangeType type)
switchPortChanged
in interface IOFSwitchListener
public void switchAdded(long switchId)
IOFSwitchListener
switchAdded
in interface IOFSwitchListener
switchId
- the datapath Id of the new switchpublic void switchRemoved(long sw)
IOFSwitchListener
switchRemoved
in interface IOFSwitchListener
sw
- the datapath Id of the switchpublic void switchActivated(long switchId)
IOFSwitchListener
switchActivated
in interface IOFSwitchListener
switchId
- the datapath Id of the switchpublic void switchChanged(long switchId)
IOFSwitchListener
switchChanged
in interface IOFSwitchListener
public void setStorageSource(IStorageSourceService storageSource)
storageSource
- the storage source to usepublic IStorageSourceService getStorageSource()
public void rowsModified(java.lang.String tableName, java.util.Set<java.lang.Object> rowKeys)
IStorageSourceListener
rowsModified
in interface IStorageSourceListener
tableName
- The table where the rows were insertedrowKeys
- The keys of the rows that were insertedpublic void rowsDeleted(java.lang.String tableName, java.util.Set<java.lang.Object> rowKeys)
IStorageSourceListener
rowsDeleted
in interface IStorageSourceListener
tableName
- The table where the rows were deletedrowKeys
- The keys of the rows that were deletedprotected void readTopologyConfigFromStorage()
protected void writeLinkToStorage(Link lt, LinkInfo linkInfo)
lt
- The LinkTuple to writelinkInfo
- The LinkInfo to writeprotected void removeLinkFromStorage(Link lt)
lt
- The LinkTuple to delete.public java.lang.Long readLinkValidTime(Link lt)
public java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleServices()
IFloodlightModule
getModuleServices
in interface IFloodlightModule
public java.util.Map<java.lang.Class<? extends IFloodlightService>,IFloodlightService> getServiceImpls()
IFloodlightModule
getServiceImpls
in interface IFloodlightModule
public java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleDependencies()
IFloodlightModule
getModuleDependencies
in interface IFloodlightModule
public void init(FloodlightModuleContext context) throws FloodlightModuleException
IFloodlightModule
init
in interface IFloodlightModule
FloodlightModuleException
public void startUp(FloodlightModuleContext context) throws FloodlightModuleException
IFloodlightModule
startUp
in interface IFloodlightModule
FloodlightModuleException
public java.util.Map<java.lang.String,java.lang.Object> getInfo(java.lang.String type)
IInfoProvider
getInfo
in interface IInfoProvider
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |