net.floodlightcontroller.devicemanager.internal
Class DeviceManagerImpl

java.lang.Object
  extended by net.floodlightcontroller.devicemanager.internal.DeviceManagerImpl
All Implemented Interfaces:
IInfoProvider, IListener<OFType>, IOFMessageListener, IFloodlightModule, IFloodlightService, IDeviceService, IEntityClassListener, IFlowReconcileListener, ITopologyListener

public class DeviceManagerImpl
extends java.lang.Object
implements IDeviceService, IOFMessageListener, ITopologyListener, IFloodlightModule, IEntityClassListener, IFlowReconcileListener, IInfoProvider

DeviceManager creates Devices based upon MAC addresses seen in the network. It tracks any network addresses mapped to the Device, and its location within the network.

Author:
readams

Nested Class Summary
protected  class DeviceManagerImpl.AttachmentPointComparator
          AttachmentPointComparator Compares two attachment points and returns the latest one.
protected  class DeviceManagerImpl.ClassState
          Used to cache state about specific entity classes
protected static class DeviceManagerImpl.DeviceUpdate
          A device update event to be dispatched
protected  class DeviceManagerImpl.HAListenerDelegate
           
 
Nested classes/interfaces inherited from interface net.floodlightcontroller.devicemanager.IDeviceService
IDeviceService.DeviceField
 
Nested classes/interfaces inherited from interface net.floodlightcontroller.core.IListener
IListener.Command
 
Field Summary
 DeviceManagerImpl.AttachmentPointComparator apComparator
          Comparator for sorting by cluster ID
protected  java.util.concurrent.ConcurrentHashMap<java.lang.String,DeviceManagerImpl.ClassState> classStateMap
          This map contains state for each of the that exist
 IDebugCounter cntCleanupEntitiesRuns
           
 IDebugCounter cntConsolidateStoreDevicesRemoved
           
 IDebugCounter cntConsolidateStoreRuns
           
 IDebugCounter cntDeviceChanged
           
 IDebugCounter cntDeviceDeleted
           
 IDebugCounter cntDeviceMoved
           
 IDebugCounter cntDeviceOnInternalPortNotLearned
           
 IDebugCounter cntDeviceReclassifyDelete
           
 IDebugCounter cntDeviceRemovedFromStore
           
 IDebugCounter cntDevicesFromStore
           
 IDebugCounter cntDeviceStoreThrottled
           
 IDebugCounter cntDeviceStrored
           
 IDebugCounter cntDhcpClientNameSnooped
           
 IDebugCounter cntEntityRemovedTimeout
           
 IDebugCounter cntIncoming
           
 IDebugCounter cntInvalidDest
           
 IDebugCounter cntInvalidSource
           
 IDebugCounter cntNewDevice
           
 IDebugCounter cntNewEntity
           
 IDebugCounter cntNoDest
           
 IDebugCounter cntNoSource
           
 IDebugCounter cntPacketNotAllowed
           
 IDebugCounter cntPacketOnInternalPortForKnownDevice
           
 IDebugCounter cntReconcileNoDest
           
 IDebugCounter cntReconcileNoSource
           
 IDebugCounter cntReconcileRequest
           
 IDebugCounter cntSyncException
           
 IDebugCounter cntTransitionToMaster
           
protected  IDebugCounterService debugCounters
           
protected  java.util.concurrent.atomic.AtomicLong deviceKeyCounter
          Counter used to generate device keys
protected  ListenerDispatcher<java.lang.String,IDeviceListener> deviceListeners
          Device manager event listeners reclassifyDeviceListeners are notified first before reconcileDeviceListeners.
protected  java.util.concurrent.ConcurrentHashMap<java.lang.Long,Device> deviceMap
          This is the master device map that maps device IDs to Device objects.
protected static int ENTITY_CLEANUP_INTERVAL
          Time in seconds between cleaning up old entities/devices
protected static int ENTITY_TIMEOUT
          Time in milliseconds before entities will expire
protected  IEntityClassifierService entityClassifier
          The entity classifier currently in use
 SingletonTask entityCleanupTask
          Periodic task to clean up expired entities
protected  IFloodlightProviderService floodlightProvider
           
protected  IFlowReconcileEngineService flowReconcileEngine
           
protected  IFlowReconcileService flowReconcileMgr
           
protected  DeviceManagerImpl.HAListenerDelegate haListenerDelegate
          Listens for HA notifications
protected static org.slf4j.Logger logger
           
static java.lang.String MODULE_NAME
          Debug Counters
static java.lang.String PACKAGE
           
protected  java.util.Set<java.util.EnumSet<IDeviceService.DeviceField>> perClassIndices
          This is the list of indices we want on a per-class basis
protected  DeviceUniqueIndex primaryIndex
          This is the primary entity index that contains all entities
protected  IRestApiService restApi
           
protected  java.util.Map<java.util.EnumSet<IDeviceService.DeviceField>,DeviceIndex> secondaryIndexMap
          This stores secondary indices over the fields in the devices
protected  IStorageSourceService storageSource
           
protected  IThreadPoolService threadPool
           
protected  ITopologyService topology
           
 
Fields inherited from interface net.floodlightcontroller.devicemanager.IDeviceService
CONTEXT_DST_DEVICE, CONTEXT_ORIG_DST_DEVICE, CONTEXT_SRC_DEVICE, fcStore
 
Constructor Summary
DeviceManagerImpl()
           
 
Method Summary
 void addIndex(boolean perClass, java.util.EnumSet<IDeviceService.DeviceField> keyFields)
          Create an index over a set of fields.
 void addListener(IDeviceListener listener)
          Adds a listener to listen for IDeviceManagerServices notifications
 void addSuppressAPs(long swId, int port)
          Specify points in the network where attachment points are not to be learned.
protected  boolean allKeyFieldsPresent(Entity e, java.util.EnumSet<IDeviceService.DeviceField> keyFields)
          Check if the entity e has all the keyFields set.
protected  Device allocateDevice(Device device, Entity entity, int insertionpoint)
           
protected  Device allocateDevice(Device device, java.util.Set<Entity> entities)
           
protected  Device allocateDevice(java.lang.Long deviceKey, Entity entity, IEntityClass entityClass)
           
protected  Device allocateDevice(java.lang.Long deviceKey, java.lang.String dhcpClientName, java.util.List<AttachmentPoint> aps, java.util.List<AttachmentPoint> trueAPs, java.util.Collection<Entity> entities, IEntityClass entityClass)
           
protected  void cleanupEntities()
          Clean up expired entities/devices
protected  void deleteDevice(Device device)
          method to delete a given device, remove all entities first and then finally delete the device itself.
 void entityClassChanged(java.util.Set<java.lang.String> entityClassNames)
          Process entity classes change event.
protected  java.util.EnumSet<IDeviceService.DeviceField> findChangedFields(Device device, Entity newEntity)
           
 IDevice findClassDevice(IEntityClass entityClass, long macAddress, java.lang.Short vlan, java.lang.Integer ipv4Address)
          Get a destination device using entity fields that corresponds with the given source device.
protected  Device findDestByEntity(IEntityClass reference, Entity dstEntity)
          Get a destination device using entity fields that corresponds with the given source device.
 IDevice findDevice(long macAddress, java.lang.Short vlan, java.lang.Integer ipv4Address, java.lang.Long switchDPID, java.lang.Integer switchPort)
          Search for a device exactly matching the provided device fields.
protected  Device findDeviceByEntity(Entity entity)
          Look up a Device based on the provided Entity.
 java.util.Collection<? extends IDevice> getAllDevices()
          Get an unmodifiable collection view over all devices currently known.
protected  Entity getDestEntityFromPacket(Ethernet eth)
          Get a (partial) entity for the destination from the packet.
 IDevice getDevice(java.lang.Long deviceKey)
          Get the device with the given device key.
protected  java.util.Iterator<Device> getDeviceIteratorForQuery(java.lang.Long macAddress, java.lang.Short vlan, java.lang.Integer ipv4Address, java.lang.Long switchDPID, java.lang.Integer switchPort)
           
 java.util.Map<java.lang.String,java.lang.Object> getInfo(java.lang.String type)
          Called when rest API requests information of a particular type
 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<java.lang.Class<? extends IFloodlightService>,IFloodlightService> getServiceImpls()
          Instantiate (as needed) and return objects that implement each of the services exported by this module.
protected  Entity getSourceEntityFromPacket(Ethernet eth, long swdpid, int port)
          Parse an entity from an Ethernet packet.
 java.util.Set<SwitchPort> getSuppressAPs()
           
 void init(FloodlightModuleContext fmc)
          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 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 isEntityAllowed(Entity entity, IEntityClass entityClass)
           
 boolean isValidAttachmentPoint(long switchDPID, int switchPort)
          Check whether the given attachment point is valid given the current topology
protected  Device learnDeviceByEntity(Entity entity)
          Look up a Device based on the provided Entity.
protected  void learnDeviceFromArpResponseData(Ethernet eth, long swdpid, int port)
          Learn device from ARP data in scenarios where the Ethernet source MAC is different from the sender hardware address in ARP data.
protected  void notifyListeners(java.util.List<IDeviceListener> listeners, DeviceManagerImpl.DeviceUpdate update)
           
protected  IListener.Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx)
           
protected  void processUpdates(java.util.Queue<DeviceManagerImpl.DeviceUpdate> updates)
          Send update notifications to listeners
protected  java.util.Iterator<Device> queryClassByEntity(IEntityClass clazz, java.util.EnumSet<IDeviceService.DeviceField> keyFields, Entity entity)
           
 java.util.Iterator<? extends IDevice> queryClassDevices(IEntityClass entityClass, java.lang.Long macAddress, java.lang.Short vlan, java.lang.Integer ipv4Address, java.lang.Long switchDPID, java.lang.Integer switchPort)
          Find devices that match the provided query.
 java.util.Iterator<? extends IDevice> queryDevices(java.lang.Long macAddress, java.lang.Short vlan, java.lang.Integer ipv4Address, java.lang.Long switchDPID, java.lang.Integer switchPort)
          Find devices that match the provided query.
 IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx)
          This is the method Floodlight uses to call listeners with OpenFlow messages
protected  boolean reclassifyDevice(Device device)
          this method will reclassify and reconcile a device - possibilities are - create new device(s), remove entities from this device.
protected  IListener.Command reconcileFlow(OFMatchReconcile ofm)
           
 IListener.Command reconcileFlows(java.util.ArrayList<OFMatchReconcile> ofmRcList)
          Given an input OFMatch, this method applies the policy of the reconciler and returns a the same input OFMatch structure modified.
protected  void removeEntity(Entity removed, IEntityClass entityClass, java.lang.Long deviceKey, java.util.Collection<Entity> others)
           
 void removeSuppressAPs(long swId, int port)
           
protected  void sendDeviceMovedNotification(Device d)
          Send update notifications to listeners
protected  void setSyncServiceIfNotSet(ISyncService syncService)
          For testing.
 void startUp(FloodlightModuleContext fmc)
          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 topologyChanged(java.util.List<ILinkDiscovery.LDUpdate> updateList)
          Topology listener method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.slf4j.Logger logger

floodlightProvider

protected IFloodlightProviderService floodlightProvider

topology

protected ITopologyService topology

storageSource

protected IStorageSourceService storageSource

restApi

protected IRestApiService restApi

threadPool

protected IThreadPoolService threadPool

flowReconcileMgr

protected IFlowReconcileService flowReconcileMgr

flowReconcileEngine

protected IFlowReconcileEngineService flowReconcileEngine

debugCounters

protected IDebugCounterService debugCounters

MODULE_NAME

public static final java.lang.String MODULE_NAME
Debug Counters

See Also:
Constant Field Values

PACKAGE

public static final java.lang.String PACKAGE

cntIncoming

public IDebugCounter cntIncoming

cntReconcileRequest

public IDebugCounter cntReconcileRequest

cntReconcileNoSource

public IDebugCounter cntReconcileNoSource

cntReconcileNoDest

public IDebugCounter cntReconcileNoDest

cntInvalidSource

public IDebugCounter cntInvalidSource

cntInvalidDest

public IDebugCounter cntInvalidDest

cntNoSource

public IDebugCounter cntNoSource

cntNoDest

public IDebugCounter cntNoDest

cntDhcpClientNameSnooped

public IDebugCounter cntDhcpClientNameSnooped

cntDeviceOnInternalPortNotLearned

public IDebugCounter cntDeviceOnInternalPortNotLearned

cntPacketNotAllowed

public IDebugCounter cntPacketNotAllowed

cntNewDevice

public IDebugCounter cntNewDevice

cntPacketOnInternalPortForKnownDevice

public IDebugCounter cntPacketOnInternalPortForKnownDevice

cntNewEntity

public IDebugCounter cntNewEntity

cntDeviceChanged

public IDebugCounter cntDeviceChanged

cntDeviceMoved

public IDebugCounter cntDeviceMoved

cntCleanupEntitiesRuns

public IDebugCounter cntCleanupEntitiesRuns

cntEntityRemovedTimeout

public IDebugCounter cntEntityRemovedTimeout

cntDeviceDeleted

public IDebugCounter cntDeviceDeleted

cntDeviceReclassifyDelete

public IDebugCounter cntDeviceReclassifyDelete

cntDeviceStrored

public IDebugCounter cntDeviceStrored

cntDeviceStoreThrottled

public IDebugCounter cntDeviceStoreThrottled

cntDeviceRemovedFromStore

public IDebugCounter cntDeviceRemovedFromStore

cntSyncException

public IDebugCounter cntSyncException

cntDevicesFromStore

public IDebugCounter cntDevicesFromStore

cntConsolidateStoreRuns

public IDebugCounter cntConsolidateStoreRuns

cntConsolidateStoreDevicesRemoved

public IDebugCounter cntConsolidateStoreDevicesRemoved

cntTransitionToMaster

public IDebugCounter cntTransitionToMaster

ENTITY_TIMEOUT

protected static final int ENTITY_TIMEOUT
Time in milliseconds before entities will expire

See Also:
Constant Field Values

ENTITY_CLEANUP_INTERVAL

protected static final int ENTITY_CLEANUP_INTERVAL
Time in seconds between cleaning up old entities/devices

See Also:
Constant Field Values

deviceMap

protected java.util.concurrent.ConcurrentHashMap<java.lang.Long,Device> deviceMap
This is the master device map that maps device IDs to Device objects.


deviceKeyCounter

protected java.util.concurrent.atomic.AtomicLong deviceKeyCounter
Counter used to generate device keys


primaryIndex

protected DeviceUniqueIndex primaryIndex
This is the primary entity index that contains all entities


secondaryIndexMap

protected java.util.Map<java.util.EnumSet<IDeviceService.DeviceField>,DeviceIndex> secondaryIndexMap
This stores secondary indices over the fields in the devices


classStateMap

protected java.util.concurrent.ConcurrentHashMap<java.lang.String,DeviceManagerImpl.ClassState> classStateMap
This map contains state for each of the that exist


perClassIndices

protected java.util.Set<java.util.EnumSet<IDeviceService.DeviceField>> perClassIndices
This is the list of indices we want on a per-class basis


entityClassifier

protected IEntityClassifierService entityClassifier
The entity classifier currently in use


deviceListeners

protected ListenerDispatcher<java.lang.String,IDeviceListener> deviceListeners
Device manager event listeners reclassifyDeviceListeners are notified first before reconcileDeviceListeners. This is to make sure devices are correctly reclassified before reconciliation.


apComparator

public DeviceManagerImpl.AttachmentPointComparator apComparator
Comparator for sorting by cluster ID


entityCleanupTask

public SingletonTask entityCleanupTask
Periodic task to clean up expired entities


haListenerDelegate

protected DeviceManagerImpl.HAListenerDelegate haListenerDelegate
Listens for HA notifications

Constructor Detail

DeviceManagerImpl

public DeviceManagerImpl()
Method Detail

getDevice

public IDevice getDevice(java.lang.Long deviceKey)
Description copied from interface: IDeviceService
Get the device with the given device key.

Specified by:
getDevice in interface IDeviceService
Parameters:
deviceKey - the key to search for
Returns:
the device associated with the key, or null if no such device
See Also:
IDevice.getDeviceKey()

findDevice

public IDevice findDevice(long macAddress,
                          java.lang.Short vlan,
                          java.lang.Integer ipv4Address,
                          java.lang.Long switchDPID,
                          java.lang.Integer switchPort)
                   throws java.lang.IllegalArgumentException
Description copied from interface: IDeviceService
Search for a device exactly matching the provided device fields. This is the same lookup process that is used for packet_in processing and device learning. Thus, findDevice() can be used to match flow entries from switches to devices. Only the key fields as defined by the IEntityClassifierService will be important in this search. All key fields MUST be supplied. queryDevices() might be more appropriate!

Specified by:
findDevice in interface IDeviceService
Parameters:
macAddress - The MAC address
vlan - the VLAN. Null means no VLAN and is valid even if VLAN is a key field.
ipv4Address - the ipv4 address
switchDPID - the switch DPID
switchPort - the switch port
Returns:
an IDevice or null if no device is found.
Throws:
java.lang.IllegalArgumentException - if not all key fields of the current IEntityClassifierService are specified.
See Also:
IDeviceManager#setEntityClassifier(IEntityClassifierService)

findClassDevice

public IDevice findClassDevice(IEntityClass entityClass,
                               long macAddress,
                               java.lang.Short vlan,
                               java.lang.Integer ipv4Address)
                        throws java.lang.IllegalArgumentException
Description copied from interface: IDeviceService
Get a destination device using entity fields that corresponds with the given source device. The source device is important since there could be ambiguity in the destination device without the attachment point information. Search for a device in a given entity class. This is the same as the lookup process for destination devices. Only the key fields as defined by the reference entity class will be important in this search. All key fields MUST be supplied.

Specified by:
findClassDevice in interface IDeviceService
Parameters:
entityClass - The entity class in which to perform the lookup.
macAddress - The MAC address for the destination
vlan - the VLAN if available
ipv4Address - The IP address if available.
Returns:
an IDevice or null if no device is found.
Throws:
java.lang.IllegalArgumentException - if not all key fields of the source's IEntityClass are specified.
See Also:
IDeviceService.findDevice(long, Short, Integer, Long, Integer)

getAllDevices

public java.util.Collection<? extends IDevice> getAllDevices()
Description copied from interface: IDeviceService
Get an unmodifiable collection view over all devices currently known.

Specified by:
getAllDevices in interface IDeviceService
Returns:
the collection of all devices

addIndex

public void addIndex(boolean perClass,
                     java.util.EnumSet<IDeviceService.DeviceField> keyFields)
Description copied from interface: IDeviceService
Create an index over a set of fields. This allows efficient lookup of devices when querying using the indexed set of specified fields. The index must be registered before any device learning takes place, or it may be incomplete. It's OK if this is called multiple times with the same fields; only one index will be created for each unique set of fields.

Specified by:
addIndex in interface IDeviceService
Parameters:
perClass - set to true if the index should be maintained for each entity class separately.
keyFields - the set of fields on which to index

queryDevices

public java.util.Iterator<? extends IDevice> queryDevices(java.lang.Long macAddress,
                                                          java.lang.Short vlan,
                                                          java.lang.Integer ipv4Address,
                                                          java.lang.Long switchDPID,
                                                          java.lang.Integer switchPort)
Description copied from interface: IDeviceService
Find devices that match the provided query. Any fields that are null will not be included in the query. If there is an index for the query, then it will be performed efficiently using the index. Otherwise, there will be a full scan of the device list.

Specified by:
queryDevices in interface IDeviceService
Parameters:
macAddress - The MAC address
vlan - the VLAN
ipv4Address - the ipv4 address
switchDPID - the switch DPID
switchPort - the switch port
Returns:
an iterator over a set of devices matching the query
See Also:
IDeviceService.queryClassDevices(IEntityClass, Long, Short, Integer, Long, Integer)

queryClassDevices

public java.util.Iterator<? extends IDevice> queryClassDevices(IEntityClass entityClass,
                                                               java.lang.Long macAddress,
                                                               java.lang.Short vlan,
                                                               java.lang.Integer ipv4Address,
                                                               java.lang.Long switchDPID,
                                                               java.lang.Integer switchPort)
Description copied from interface: IDeviceService
Find devices that match the provided query. Only the index for the specified class will be searched. Any fields that are null will not be included in the query. If there is an index for the query, then it will be performed efficiently using the index. Otherwise, there will be a full scan of the device list.

Specified by:
queryClassDevices in interface IDeviceService
Parameters:
entityClass - The entity class in which to perform the query
macAddress - The MAC address
vlan - the VLAN
ipv4Address - the ipv4 address
switchDPID - the switch DPID
switchPort - the switch port
Returns:
an iterator over a set of devices matching the query
See Also:
IDeviceService#queryClassDevices(Long, Short, Integer, Long, Integer)

getDeviceIteratorForQuery

protected java.util.Iterator<Device> getDeviceIteratorForQuery(java.lang.Long macAddress,
                                                               java.lang.Short vlan,
                                                               java.lang.Integer ipv4Address,
                                                               java.lang.Long switchDPID,
                                                               java.lang.Integer switchPort)

addListener

public void addListener(IDeviceListener listener)
Description copied from interface: IDeviceService
Adds a listener to listen for IDeviceManagerServices notifications

Specified by:
addListener in interface IDeviceService
Parameters:
listener - The listener that wants the notifications

addSuppressAPs

public void addSuppressAPs(long swId,
                           int port)
Description copied from interface: IDeviceService
Specify points in the network where attachment points are not to be learned.

Specified by:
addSuppressAPs in interface IDeviceService

removeSuppressAPs

public void removeSuppressAPs(long swId,
                              int port)
Specified by:
removeSuppressAPs in interface IDeviceService

getSuppressAPs

public java.util.Set<SwitchPort> getSuppressAPs()
Specified by:
getSuppressAPs in interface IDeviceService

getInfo

public java.util.Map<java.lang.String,java.lang.Object> getInfo(java.lang.String type)
Description copied from interface: IInfoProvider
Called when rest API requests information of a particular type

Specified by:
getInfo in interface IInfoProvider
Returns:

getName

public java.lang.String getName()
Description copied from interface: IListener
The name assigned to this listener

Specified by:
getName in interface IListener<OFType>
Returns:

isCallbackOrderingPrereq

public boolean isCallbackOrderingPrereq(OFType type,
                                        java.lang.String name)
Description copied from interface: IListener
Check if the module called name is a callback ordering prerequisite for this module. In other words, if this function returns true for the given name, then this listener will be called after that message listener.

Specified by:
isCallbackOrderingPrereq in interface IListener<OFType>
Parameters:
type - the object type to which this applies
name - the name of the module
Returns:
whether name is a prerequisite.

isCallbackOrderingPostreq

public boolean isCallbackOrderingPostreq(OFType type,
                                         java.lang.String name)
Description copied from interface: IListener
Check if the module called name is a callback ordering post-requisite for this module. In other words, if this function returns true for the given name, then this listener will be called before that message listener.

Specified by:
isCallbackOrderingPostreq in interface IListener<OFType>
Parameters:
type - the object type to which this applies
name - the name of the module
Returns:
whether name is a post-requisite.

receive

public IListener.Command receive(IOFSwitch sw,
                                 OFMessage msg,
                                 FloodlightContext cntx)
Description copied from interface: IOFMessageListener
This is the method Floodlight uses to call listeners with OpenFlow messages

Specified by:
receive in interface IOFMessageListener
Parameters:
sw - the OpenFlow switch that sent this message
msg - the message
cntx - a Floodlight message context object you can use to pass information between listeners
Returns:
the command to continue or stop the execution

reconcileFlows

public IListener.Command reconcileFlows(java.util.ArrayList<OFMatchReconcile> ofmRcList)
Description copied from interface: IFlowReconcileListener
Given an input OFMatch, this method applies the policy of the reconciler and returns a the same input OFMatch structure modified. Additional OFMatches, if needed, are returned in OFMatch-list. All the OFMatches are assumed to have "PERMIT" action.

Specified by:
reconcileFlows in interface IFlowReconcileListener
Parameters:
ofmRcList - input flow matches, to be updated to be consistent with the policies of this reconciler Additional OFMatch-es can be added to the "list" as needed. For example after a new ACL application, one flow-match may result in multiple flow-matches The method must also update the ReconcileAction member in ofmRcList entries to indicate if the flow needs to be modified, deleted or left unchanged OR of a new entry is to be added after flow reconciliation
Returns:
Command.CONTINUE if the OFMatch should be sent to the next flow reconciler. Command.STOP if the OFMatch shouldn't be processed further. In this case the no reconciled flow-mods would be programmed

reconcileFlow

protected IListener.Command reconcileFlow(OFMatchReconcile ofm)

getModuleServices

public java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleServices()
Description copied from interface: IFloodlightModule
Return the list of interfaces that this module implements. All interfaces must inherit IFloodlightService

Specified by:
getModuleServices in interface IFloodlightModule
Returns:

getServiceImpls

public java.util.Map<java.lang.Class<? extends IFloodlightService>,IFloodlightService> getServiceImpls()
Description copied from interface: IFloodlightModule
Instantiate (as needed) and return objects that implement each of the services exported by this module. The map returned maps the implemented service to the object. The object could be the same object or different objects for different exported services.

Specified by:
getServiceImpls in interface IFloodlightModule
Returns:
The map from service interface class to service implementation

getModuleDependencies

public java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleDependencies()
Description copied from interface: IFloodlightModule
Get a list of Modules that this module depends on. The module system will ensure that each these dependencies is resolved before the subsequent calls to init().

Specified by:
getModuleDependencies in interface IFloodlightModule
Returns:
The Collection of IFloodlightServices that this module depends on.

init

public void init(FloodlightModuleContext fmc)
          throws FloodlightModuleException
Description copied from interface: IFloodlightModule
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.

Specified by:
init in interface IFloodlightModule
Throws:
FloodlightModuleException

startUp

public void startUp(FloodlightModuleContext fmc)
             throws FloodlightModuleException
Description copied from interface: IFloodlightModule
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.

Specified by:
startUp in interface IFloodlightModule
Throws:
FloodlightModuleException

processPacketInMessage

protected IListener.Command processPacketInMessage(IOFSwitch sw,
                                                   OFPacketIn pi,
                                                   FloodlightContext cntx)

isValidAttachmentPoint

public boolean isValidAttachmentPoint(long switchDPID,
                                      int switchPort)
Check whether the given attachment point is valid given the current topology

Parameters:
switchDPID - the DPID
switchPort - the port
Returns:
true if it's a valid attachment point

getSourceEntityFromPacket

protected Entity getSourceEntityFromPacket(Ethernet eth,
                                           long swdpid,
                                           int port)
Parse an entity from an Ethernet packet.

Parameters:
eth - the packet to parse
sw - the switch on which the packet arrived
pi - the original packetin
Returns:
the entity from the packet

learnDeviceFromArpResponseData

protected void learnDeviceFromArpResponseData(Ethernet eth,
                                              long swdpid,
                                              int port)
Learn device from ARP data in scenarios where the Ethernet source MAC is different from the sender hardware address in ARP data.


getDestEntityFromPacket

protected Entity getDestEntityFromPacket(Ethernet eth)
Get a (partial) entity for the destination from the packet.

Parameters:
eth -
Returns:

findDeviceByEntity

protected Device findDeviceByEntity(Entity entity)
Look up a Device based on the provided Entity. We first check the primary index. If we do not find an entry there we classify the device into its IEntityClass and query the classIndex. This implies that all key field of the current IEntityClassifier must be present in the entity for the lookup to succeed!

Parameters:
entity - the entity to search for
Returns:
The Device object if found

findDestByEntity

protected Device findDestByEntity(IEntityClass reference,
                                  Entity dstEntity)
Get a destination device using entity fields that corresponds with the given source device. The source device is important since there could be ambiguity in the destination device without the attachment point information.

Parameters:
reference - the source device's entity class. The returned destination will be in the same entity class as the source.
dstEntity - the entity to look up
Returns:
an Device or null if no device is found.

learnDeviceByEntity

protected Device learnDeviceByEntity(Entity entity)
Look up a Device based on the provided Entity. Also learns based on the new entity, and will update existing devices as required.

Parameters:
entity - the Entity
Returns:
The Device object if found

isEntityAllowed

protected boolean isEntityAllowed(Entity entity,
                                  IEntityClass entityClass)

findChangedFields

protected java.util.EnumSet<IDeviceService.DeviceField> findChangedFields(Device device,
                                                                          Entity newEntity)

processUpdates

protected void processUpdates(java.util.Queue<DeviceManagerImpl.DeviceUpdate> updates)
Send update notifications to listeners

Parameters:
updates - the updates to process.

notifyListeners

protected void notifyListeners(java.util.List<IDeviceListener> listeners,
                               DeviceManagerImpl.DeviceUpdate update)

allKeyFieldsPresent

protected boolean allKeyFieldsPresent(Entity e,
                                      java.util.EnumSet<IDeviceService.DeviceField> keyFields)
Check if the entity e has all the keyFields set. Returns false if not

Parameters:
e - entity to check
keyFields - the key fields to check e against
Returns:

cleanupEntities

protected void cleanupEntities()
Clean up expired entities/devices


removeEntity

protected void removeEntity(Entity removed,
                            IEntityClass entityClass,
                            java.lang.Long deviceKey,
                            java.util.Collection<Entity> others)

deleteDevice

protected void deleteDevice(Device device)
method to delete a given device, remove all entities first and then finally delete the device itself.

Parameters:
device -

queryClassByEntity

protected java.util.Iterator<Device> queryClassByEntity(IEntityClass clazz,
                                                        java.util.EnumSet<IDeviceService.DeviceField> keyFields,
                                                        Entity entity)

allocateDevice

protected Device allocateDevice(java.lang.Long deviceKey,
                                Entity entity,
                                IEntityClass entityClass)

allocateDevice

protected Device allocateDevice(java.lang.Long deviceKey,
                                java.lang.String dhcpClientName,
                                java.util.List<AttachmentPoint> aps,
                                java.util.List<AttachmentPoint> trueAPs,
                                java.util.Collection<Entity> entities,
                                IEntityClass entityClass)

allocateDevice

protected Device allocateDevice(Device device,
                                Entity entity,
                                int insertionpoint)

allocateDevice

protected Device allocateDevice(Device device,
                                java.util.Set<Entity> entities)

topologyChanged

public void topologyChanged(java.util.List<ILinkDiscovery.LDUpdate> updateList)
Topology listener method.

Specified by:
topologyChanged in interface ITopologyListener

sendDeviceMovedNotification

protected void sendDeviceMovedNotification(Device d)
Send update notifications to listeners

Parameters:
updates - the updates to process.

entityClassChanged

public void entityClassChanged(java.util.Set<java.lang.String> entityClassNames)
Description copied from interface: IEntityClassListener
Process entity classes change event.

Specified by:
entityClassChanged in interface IEntityClassListener
Parameters:
entityClassNames - Set of entity classes changed

reclassifyDevice

protected boolean reclassifyDevice(Device device)
this method will reclassify and reconcile a device - possibilities are - create new device(s), remove entities from this device. If the device entity class did not change then it returns false else true.

Parameters:
device -

setSyncServiceIfNotSet

protected void setSyncServiceIfNotSet(ISyncService syncService)
For testing. Sets the syncService. Only call after init but before startUp. Used by MockDeviceManager

Parameters:
syncService -