|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.floodlightcontroller.devicemanager.internal.DeviceManagerImpl
public class DeviceManagerImpl
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.
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 |
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 |
---|
protected static org.slf4j.Logger logger
protected IFloodlightProviderService floodlightProvider
protected ITopologyService topology
protected IStorageSourceService storageSource
protected IRestApiService restApi
protected IThreadPoolService threadPool
protected IFlowReconcileService flowReconcileMgr
protected IFlowReconcileEngineService flowReconcileEngine
protected IDebugCounterService debugCounters
public static final java.lang.String MODULE_NAME
public static final java.lang.String PACKAGE
public IDebugCounter cntIncoming
public IDebugCounter cntReconcileRequest
public IDebugCounter cntReconcileNoSource
public IDebugCounter cntReconcileNoDest
public IDebugCounter cntInvalidSource
public IDebugCounter cntInvalidDest
public IDebugCounter cntNoSource
public IDebugCounter cntNoDest
public IDebugCounter cntDhcpClientNameSnooped
public IDebugCounter cntDeviceOnInternalPortNotLearned
public IDebugCounter cntPacketNotAllowed
public IDebugCounter cntNewDevice
public IDebugCounter cntPacketOnInternalPortForKnownDevice
public IDebugCounter cntNewEntity
public IDebugCounter cntDeviceChanged
public IDebugCounter cntDeviceMoved
public IDebugCounter cntCleanupEntitiesRuns
public IDebugCounter cntEntityRemovedTimeout
public IDebugCounter cntDeviceDeleted
public IDebugCounter cntDeviceReclassifyDelete
public IDebugCounter cntDeviceStrored
public IDebugCounter cntDeviceStoreThrottled
public IDebugCounter cntDeviceRemovedFromStore
public IDebugCounter cntSyncException
public IDebugCounter cntDevicesFromStore
public IDebugCounter cntConsolidateStoreRuns
public IDebugCounter cntConsolidateStoreDevicesRemoved
public IDebugCounter cntTransitionToMaster
protected static final int ENTITY_TIMEOUT
protected static final int ENTITY_CLEANUP_INTERVAL
protected java.util.concurrent.ConcurrentHashMap<java.lang.Long,Device> deviceMap
Device
objects.
protected java.util.concurrent.atomic.AtomicLong deviceKeyCounter
protected DeviceUniqueIndex primaryIndex
protected java.util.Map<java.util.EnumSet<IDeviceService.DeviceField>,DeviceIndex> secondaryIndexMap
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,DeviceManagerImpl.ClassState> classStateMap
protected java.util.Set<java.util.EnumSet<IDeviceService.DeviceField>> perClassIndices
protected IEntityClassifierService entityClassifier
protected ListenerDispatcher<java.lang.String,IDeviceListener> deviceListeners
public DeviceManagerImpl.AttachmentPointComparator apComparator
public SingletonTask entityCleanupTask
protected DeviceManagerImpl.HAListenerDelegate haListenerDelegate
Constructor Detail |
---|
public DeviceManagerImpl()
Method Detail |
---|
public IDevice getDevice(java.lang.Long deviceKey)
IDeviceService
getDevice
in interface IDeviceService
deviceKey
- the key to search for
IDevice.getDeviceKey()
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
IDeviceService
IEntityClassifierService
will
be important in this search. All key fields MUST be supplied.
queryDevices()
might be more appropriate!
findDevice
in interface IDeviceService
macAddress
- The MAC addressvlan
- the VLAN. Null means no VLAN and is valid even if VLAN is a
key field.ipv4Address
- the ipv4 addressswitchDPID
- the switch DPIDswitchPort
- the switch port
IDevice
or null if no device is found.
java.lang.IllegalArgumentException
- if not all key fields of the
current IEntityClassifierService
are specified.IDeviceManager#setEntityClassifier(IEntityClassifierService)
public IDevice findClassDevice(IEntityClass entityClass, long macAddress, java.lang.Short vlan, java.lang.Integer ipv4Address) throws java.lang.IllegalArgumentException
IDeviceService
findClassDevice
in interface IDeviceService
entityClass
- The entity class in which to perform the lookup.macAddress
- The MAC address for the destinationvlan
- the VLAN if availableipv4Address
- The IP address if available.
IDevice
or null if no device is found.
java.lang.IllegalArgumentException
- if not all key fields of the
source's IEntityClass
are specified.IDeviceService.findDevice(long, Short, Integer, Long,
Integer)
public java.util.Collection<? extends IDevice> getAllDevices()
IDeviceService
getAllDevices
in interface IDeviceService
public void addIndex(boolean perClass, java.util.EnumSet<IDeviceService.DeviceField> keyFields)
IDeviceService
addIndex
in interface IDeviceService
perClass
- set to true if the index should be maintained for each
entity class separately.keyFields
- the set of fields on which to indexpublic 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)
IDeviceService
queryDevices
in interface IDeviceService
macAddress
- The MAC addressvlan
- the VLANipv4Address
- the ipv4 addressswitchDPID
- the switch DPIDswitchPort
- the switch port
IDeviceService.queryClassDevices(IEntityClass, Long,
Short, Integer, Long, Integer)
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)
IDeviceService
queryClassDevices
in interface IDeviceService
entityClass
- The entity class in which to perform the querymacAddress
- The MAC addressvlan
- the VLANipv4Address
- the ipv4 addressswitchDPID
- the switch DPIDswitchPort
- the switch port
IDeviceService#queryClassDevices(Long,
Short, Integer, Long, Integer)
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)
public void addListener(IDeviceListener listener)
IDeviceService
addListener
in interface IDeviceService
listener
- The listener that wants the notificationspublic void addSuppressAPs(long swId, int port)
IDeviceService
addSuppressAPs
in interface IDeviceService
public void removeSuppressAPs(long swId, int port)
removeSuppressAPs
in interface IDeviceService
public java.util.Set<SwitchPort> getSuppressAPs()
getSuppressAPs
in interface IDeviceService
public java.util.Map<java.lang.String,java.lang.Object> getInfo(java.lang.String type)
IInfoProvider
getInfo
in interface IInfoProvider
public java.lang.String getName()
IListener
getName
in interface IListener<OFType>
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
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 IListener.Command reconcileFlows(java.util.ArrayList<OFMatchReconcile> ofmRcList)
IFlowReconcileListener
reconcileFlows
in interface IFlowReconcileListener
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
protected IListener.Command reconcileFlow(OFMatchReconcile ofm)
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 fmc) throws FloodlightModuleException
IFloodlightModule
init
in interface IFloodlightModule
FloodlightModuleException
public void startUp(FloodlightModuleContext fmc) throws FloodlightModuleException
IFloodlightModule
startUp
in interface IFloodlightModule
FloodlightModuleException
protected IListener.Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx)
public boolean isValidAttachmentPoint(long switchDPID, int switchPort)
switchDPID
- the DPIDswitchPort
- the port
protected Entity getSourceEntityFromPacket(Ethernet eth, long swdpid, int port)
Ethernet
packet.
eth
- the packet to parsesw
- the switch on which the packet arrivedpi
- the original packetin
protected void learnDeviceFromArpResponseData(Ethernet eth, long swdpid, int port)
protected Entity getDestEntityFromPacket(Ethernet eth)
eth
-
protected Device findDeviceByEntity(Entity entity)
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!
entity
- the entity to search for
Device
object if foundprotected Device findDestByEntity(IEntityClass reference, Entity dstEntity)
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
Device
or null if no device is found.protected Device learnDeviceByEntity(Entity entity)
Device
based on the provided Entity
. Also
learns based on the new entity, and will update existing devices as
required.
entity
- the Entity
Device
object if foundprotected boolean isEntityAllowed(Entity entity, IEntityClass entityClass)
protected java.util.EnumSet<IDeviceService.DeviceField> findChangedFields(Device device, Entity newEntity)
protected void processUpdates(java.util.Queue<DeviceManagerImpl.DeviceUpdate> updates)
updates
- the updates to process.protected void notifyListeners(java.util.List<IDeviceListener> listeners, DeviceManagerImpl.DeviceUpdate update)
protected boolean allKeyFieldsPresent(Entity e, java.util.EnumSet<IDeviceService.DeviceField> keyFields)
e
- entity to checkkeyFields
- the key fields to check e against
protected void cleanupEntities()
protected void removeEntity(Entity removed, IEntityClass entityClass, java.lang.Long deviceKey, java.util.Collection<Entity> others)
protected void deleteDevice(Device device)
device
- protected java.util.Iterator<Device> queryClassByEntity(IEntityClass clazz, java.util.EnumSet<IDeviceService.DeviceField> keyFields, Entity entity)
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 Device allocateDevice(Device device, Entity entity, int insertionpoint)
protected Device allocateDevice(Device device, java.util.Set<Entity> entities)
public void topologyChanged(java.util.List<ILinkDiscovery.LDUpdate> updateList)
topologyChanged
in interface ITopologyListener
protected void sendDeviceMovedNotification(Device d)
updates
- the updates to process.public void entityClassChanged(java.util.Set<java.lang.String> entityClassNames)
IEntityClassListener
entityClassChanged
in interface IEntityClassListener
entityClassNames
- Set of entity classes changedprotected boolean reclassifyDevice(Device device)
device
- protected void setSyncServiceIfNotSet(ISyncService syncService)
syncService
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |