net.floodlightcontroller.devicemanager.internal
Class Device

java.lang.Object
  extended by net.floodlightcontroller.devicemanager.internal.Device
All Implemented Interfaces:
IDevice

public class Device
extends java.lang.Object
implements IDevice

Concrete implementation of IDevice

Author:
readams

Field Summary
protected  java.util.List<AttachmentPoint> attachmentPoints
          The current attachment points for the device.
protected  DeviceManagerImpl deviceManager
           
protected  java.lang.String dhcpClientName
           
protected  Entity[] entities
           
protected static org.slf4j.Logger log
           
protected  java.lang.String macAddressString
           
protected  java.util.List<AttachmentPoint> oldAPs
          These are the old attachment points for the device that were valid no more than INACTIVITY_TIME ago.
protected  java.lang.Short[] vlanIds
           
 
Constructor Summary
Device(Device device, Entity newEntity, int insertionpoint)
          Construct a new device consisting of the entities from the old device plus an additional entity.
Device(DeviceManagerImpl deviceManager, java.lang.Long deviceKey, Entity entity, IEntityClass entityClass)
          Create a device from an entities
Device(DeviceManagerImpl deviceManager, java.lang.Long deviceKey, java.lang.String dhcpClientName, java.util.Collection<AttachmentPoint> oldAPs, java.util.Collection<AttachmentPoint> attachmentPoints, java.util.Collection<Entity> entities, IEntityClass entityClass)
          Create a device from a set of entities
 
Method Summary
 boolean deleteAttachmentPoint(long sw)
           
 boolean deleteAttachmentPoint(long sw, int port)
          Delete (sw,port) from the list of list of attachment points and oldAPs.
protected  int entityIndex(Entity entity)
          Check whether the device contains the specified entity
 boolean equals(java.lang.Object obj)
           
 SwitchPort[] getAttachmentPoints()
          Get all unique attachment points associated with the device.
 SwitchPort[] getAttachmentPoints(boolean includeError)
          Get all unique attachment points associated with the device.
 java.lang.Long getDeviceKey()
          Get the primary key for this device.
 java.lang.String getDHCPClientName()
           
 Entity[] getEntities()
           
 IEntityClass getEntityClass()
          Get the entity class for the device.
 java.lang.Integer[] getIPv4Addresses()
          Get all unique IPv4 addresses associated with the device.
 java.util.Date getLastSeen()
          Get the most recent timestamp for this device
 long getMACAddress()
          Get the MAC address of the device as a Long value.
 java.lang.String getMACAddressString()
          Get the MAC address of the device as a String value.
 SwitchPort[] getOldAP()
          Get all old attachment points associated with the device.
 java.lang.Short[] getSwitchPortVlanIds(SwitchPort swp)
          Returns all unique VLAN IDs for the device that were observed on the given switch port
 java.lang.Short[] getVlanId()
          Get all unique VLAN IDs for the device.
 int hashCode()
           
 java.lang.String toString()
           
protected  boolean updateAttachmentPoint()
          Update the known attachment points.
protected  boolean updateAttachmentPoint(long sw, int port, long lastSeen)
          Update the list of attachment points given that a new packet-in was seen from (sw, port) at time (lastSeen).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static org.slf4j.Logger log

deviceManager

protected final DeviceManagerImpl deviceManager

entities

protected final Entity[] entities

macAddressString

protected final java.lang.String macAddressString

vlanIds

protected final java.lang.Short[] vlanIds

dhcpClientName

protected volatile java.lang.String dhcpClientName

oldAPs

protected volatile java.util.List<AttachmentPoint> oldAPs
These are the old attachment points for the device that were valid no more than INACTIVITY_TIME ago.


attachmentPoints

protected volatile java.util.List<AttachmentPoint> attachmentPoints
The current attachment points for the device.

Constructor Detail

Device

public Device(DeviceManagerImpl deviceManager,
              java.lang.Long deviceKey,
              Entity entity,
              IEntityClass entityClass)
Create a device from an entities

Parameters:
deviceManager - the device manager for this device
deviceKey - the unique identifier for this device object
entity - the initial entity for the device
entityClass - the entity classes associated with the entity

Device

public Device(DeviceManagerImpl deviceManager,
              java.lang.Long deviceKey,
              java.lang.String dhcpClientName,
              java.util.Collection<AttachmentPoint> oldAPs,
              java.util.Collection<AttachmentPoint> attachmentPoints,
              java.util.Collection<Entity> entities,
              IEntityClass entityClass)
Create a device from a set of entities

Parameters:
deviceManager - the device manager for this device
deviceKey - the unique identifier for this device object
entities - the initial entities for the device
entityClass - the entity class associated with the entities

Device

public Device(Device device,
              Entity newEntity,
              int insertionpoint)
Construct a new device consisting of the entities from the old device plus an additional entity. The caller needs to ensure that the additional entity is not already present in the array

Parameters:
device - the old device object
newEntity - the entity to add. newEntity must be have the same entity class as device
if - positive indicates the index in the entities array were the new entity should be inserted. If negative we will compute the correct insertion point
Method Detail

updateAttachmentPoint

protected boolean updateAttachmentPoint()
Update the known attachment points. This method is called whenever topology changes. The method returns true if there's any change to the list of attachment points -- which indicates a possible device move.

Returns:

updateAttachmentPoint

protected boolean updateAttachmentPoint(long sw,
                                        int port,
                                        long lastSeen)
Update the list of attachment points given that a new packet-in was seen from (sw, port) at time (lastSeen). The return value is true if there was any change to the list of attachment points for the device -- which indicates a device move.

Parameters:
sw -
port -
lastSeen -
Returns:

deleteAttachmentPoint

public boolean deleteAttachmentPoint(long sw,
                                     int port)
Delete (sw,port) from the list of list of attachment points and oldAPs.

Parameters:
sw -
port -
Returns:

deleteAttachmentPoint

public boolean deleteAttachmentPoint(long sw)

getOldAP

public SwitchPort[] getOldAP()
Description copied from interface: IDevice
Get all old attachment points associated with the device. this is used in host movement scenario.

Specified by:
getOldAP in interface IDevice
Returns:
an array containing all unique old attachment points for the device

getAttachmentPoints

public SwitchPort[] getAttachmentPoints()
Description copied from interface: IDevice
Get all unique attachment points associated with the device. This will not include any blocked attachment points.

Specified by:
getAttachmentPoints in interface IDevice
Returns:
an array containing all unique attachment points for the device

getAttachmentPoints

public SwitchPort[] getAttachmentPoints(boolean includeError)
Description copied from interface: IDevice
Get all unique attachment points associated with the device.

Specified by:
getAttachmentPoints in interface IDevice
Parameters:
includeError - whether to include blocked attachment points. Blocked attachment points should not be used for forwarding, but could be useful to show to a user
Returns:
an array containing all unique attachment points for the device

getDeviceKey

public java.lang.Long getDeviceKey()
Description copied from interface: IDevice
Get the primary key for this device.

Specified by:
getDeviceKey in interface IDevice
Returns:
the primary key

getMACAddress

public long getMACAddress()
Description copied from interface: IDevice
Get the MAC address of the device as a Long value.

Specified by:
getMACAddress in interface IDevice
Returns:
the MAC address for the device

getMACAddressString

public java.lang.String getMACAddressString()
Description copied from interface: IDevice
Get the MAC address of the device as a String value.

Specified by:
getMACAddressString in interface IDevice
Returns:
the MAC address for the device

getVlanId

public java.lang.Short[] getVlanId()
Description copied from interface: IDevice
Get all unique VLAN IDs for the device. If the device has untagged entities, then the value -1 will be returned.

Specified by:
getVlanId in interface IDevice
Returns:
an array containing all unique VLAN IDs for the device.

getIPv4Addresses

public java.lang.Integer[] getIPv4Addresses()
Description copied from interface: IDevice
Get all unique IPv4 addresses associated with the device.

Specified by:
getIPv4Addresses in interface IDevice
Returns:
an array containing the unique IPv4 addresses for the device.

getSwitchPortVlanIds

public java.lang.Short[] getSwitchPortVlanIds(SwitchPort swp)
Description copied from interface: IDevice
Returns all unique VLAN IDs for the device that were observed on the given switch port

Specified by:
getSwitchPortVlanIds in interface IDevice
Parameters:
swp - the switch port to query
Returns:
an array containing the unique VLAN IDs

getLastSeen

public java.util.Date getLastSeen()
Description copied from interface: IDevice
Get the most recent timestamp for this device

Specified by:
getLastSeen in interface IDevice
Returns:
the last seen timestamp

getEntityClass

public IEntityClass getEntityClass()
Description copied from interface: IDevice
Get the entity class for the device.

Specified by:
getEntityClass in interface IDevice
Returns:
the entity class
See Also:
IEntityClassifierService

getEntities

public Entity[] getEntities()

getDHCPClientName

public java.lang.String getDHCPClientName()

entityIndex

protected int entityIndex(Entity entity)
Check whether the device contains the specified entity

Parameters:
entity - the entity to search for
Returns:
the index of the entity, or <0 if not found

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object