net.floodlightcontroller.core
Class OFSwitchBase.PortManager

java.lang.Object
  extended by net.floodlightcontroller.core.OFSwitchBase.PortManager
Enclosing class:
OFSwitchBase

protected class OFSwitchBase.PortManager
extends java.lang.Object

Manages the ports of this switch. Provides methods to query and update the stored ports. The class ensures that every port name and port number is unique. When updating ports the class checks if port number <-> port name mappings have change due to the update. If a new port P has number and port that are inconsistent with the previous mapping(s) the class will delete all previous ports with name or number of the new port and then add the new port. Port names are stored as-is but they are compared case-insensitive The methods that change the stored ports return a list of PortChangeEvents that represent the changes that have been applied to the port list so that IOFSwitchListeners can be notified about the changes. Implementation notes: - We keep several different representations of the ports to allow for fast lookups - Ports are stored in unchangeable lists. When a port is modified new data structures are allocated. - We use a read-write-lock for synchronization, so multiple readers are allowed.


Constructor Summary
OFSwitchBase.PortManager()
           
 
Method Summary
 OrderedCollection<IOFSwitch.PortChangeEvent> comparePorts(java.util.Collection<ImmutablePort> newPorts)
          Compare the current ports of this switch to the newPorts list and return the changes that would be applied to transfort the current ports to the new ports.
 java.util.List<java.lang.Integer> getEnabledPortNumbers()
           
 java.util.List<ImmutablePort> getEnabledPorts()
           
 ImmutablePort getPort(java.lang.Integer portNumber)
           
 ImmutablePort getPort(java.lang.String name)
           
 java.util.List<ImmutablePort> getPorts()
           
 OrderedCollection<IOFSwitch.PortChangeEvent> getSinglePortChanges(ImmutablePort newPort)
          Given a new or modified port newPort, returns the list of PortChangeEvents to "transform" the current ports stored by this switch to include / represent the new port.
 OrderedCollection<IOFSwitch.PortChangeEvent> handlePortStatusMessage(OFPortStatus ps)
          Handle a OFPortStatus message, update the internal data structures that store ports and return the list of OFChangeEvents.
 OrderedCollection<IOFSwitch.PortChangeEvent> updatePorts(java.util.Collection<ImmutablePort> newPorts)
          Compare the current ports of this switch to the newPorts list and return the changes that would be applied to transform the current ports to the new ports.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OFSwitchBase.PortManager

public OFSwitchBase.PortManager()
Method Detail

handlePortStatusMessage

public OrderedCollection<IOFSwitch.PortChangeEvent> handlePortStatusMessage(OFPortStatus ps)
Handle a OFPortStatus message, update the internal data structures that store ports and return the list of OFChangeEvents. This method will increment error/warn counters and log

Parameters:
ps -
Returns:

getSinglePortChanges

public OrderedCollection<IOFSwitch.PortChangeEvent> getSinglePortChanges(ImmutablePort newPort)
Given a new or modified port newPort, returns the list of PortChangeEvents to "transform" the current ports stored by this switch to include / represent the new port. The ports stored by this switch are NOT updated. This method acquires the readlock and is thread-safe by itself. Most callers will need to acquire the write lock before calling this method though (if the caller wants to update the ports stored by this switch)

Parameters:
newPort - the new or modified port.
Returns:
the list of changes

comparePorts

public OrderedCollection<IOFSwitch.PortChangeEvent> comparePorts(java.util.Collection<ImmutablePort> newPorts)
Compare the current ports of this switch to the newPorts list and return the changes that would be applied to transfort the current ports to the new ports. No internal data structures are updated see #compareAndUpdatePorts(List, boolean)

Parameters:
newPorts - the list of new ports
Returns:
The list of differences between the current ports and newPortList

updatePorts

public OrderedCollection<IOFSwitch.PortChangeEvent> updatePorts(java.util.Collection<ImmutablePort> newPorts)
Compare the current ports of this switch to the newPorts list and return the changes that would be applied to transform the current ports to the new ports. No internal data structures are updated see #compareAndUpdatePorts(List, boolean)

Parameters:
newPorts - the list of new ports
Returns:
The list of differences between the current ports and newPortList

getPort

public ImmutablePort getPort(java.lang.String name)

getPort

public ImmutablePort getPort(java.lang.Integer portNumber)

getPorts

public java.util.List<ImmutablePort> getPorts()

getEnabledPorts

public java.util.List<ImmutablePort> getEnabledPorts()

getEnabledPortNumbers

public java.util.List<java.lang.Integer> getEnabledPortNumbers()