net.floodlightcontroller.core
Class ImmutablePort

java.lang.Object
  extended by net.floodlightcontroller.core.ImmutablePort

public class ImmutablePort
extends java.lang.Object

An immutable version of an OFPhysical port. In addition, it uses EnumSets instead of integer bitmaps to represent OFPortConfig, OFPortState, and OFPortFeature bitmaps. Port names are stored with the original case but equals() and XXXX use case-insentivie comparisions for port names!! TODO: create a Builder so we can easily construct OFPhysicalPorts TODO: should we verify / ensure that the features make sense, i.e., that currentFeatures IsSubsetOf advertisedFeatures IsSubsetOf supportedFeatures

Author:
gregor

Nested Class Summary
static class ImmutablePort.Builder
          A builder class to create ImmutablePort instances TODO: add methods to remove elements from the EnumSets
 
Method Summary
static ImmutablePort create(java.lang.String name, java.lang.Integer portNumber)
           
 boolean equals(java.lang.Object obj)
           
static ImmutablePort fromOFPhysicalPort(OFPhysicalPort p)
           
 java.util.Set<OFPhysicalPort.OFPortFeatures> getAdvertisedFeatures()
           
 java.util.Set<OFPhysicalPort.OFPortConfig> getConfig()
           
 java.util.Set<OFPhysicalPort.OFPortFeatures> getCurrentFeatures()
           
 OFPhysicalPort.OFPortSpeed getCurrentPortSpeed()
           
 byte[] getHardwareAddress()
           
 java.lang.String getName()
           
 java.util.Set<OFPhysicalPort.OFPortFeatures> getPeerFeatures()
           
 int getPortNumber()
           
 OFPhysicalPort.OFPortState getPortState()
          Returns the STP state portion of the OFPortState.
 java.util.Set<OFPhysicalPort.OFPortFeatures> getSupportedFeatures()
           
 int hashCode()
           
static java.util.List<ImmutablePort> immutablePortListOf(java.util.Collection<OFPhysicalPort> ports)
          Convert a Collection of OFPhysicalPorts to a list of ImmutablePorts.
static java.util.List<ImmutablePort> immutablePortListOf(java.util.List<OFPortDescription> portDescriptions)
          Convert a List of OFPortDescription to a list of ImmutablePorts.
 boolean isEnabled()
          Returns true if the port is up, i.e., it's neither administratively down nor link down.
 boolean isLinkDown()
          Returns true if the OFPortState indicates the port is down
static java.util.List<OFPhysicalPort> ofPhysicalPortListOf(java.util.Collection<ImmutablePort> ports)
          Convert a Collection of ImmutablePort to a list of OFPhyscialPorts.
 java.lang.String toBriefString()
          Return a brief String describing this port containing the port number and port name
 OFPhysicalPort toOFPhysicalPort()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

fromOFPhysicalPort

public static ImmutablePort fromOFPhysicalPort(OFPhysicalPort p)

create

public static ImmutablePort create(java.lang.String name,
                                   java.lang.Integer portNumber)

getPortNumber

public int getPortNumber()

getHardwareAddress

public byte[] getHardwareAddress()

getName

public java.lang.String getName()

getConfig

public java.util.Set<OFPhysicalPort.OFPortConfig> getConfig()

isLinkDown

public boolean isLinkDown()
Returns true if the OFPortState indicates the port is down

Returns:

getPortState

public OFPhysicalPort.OFPortState getPortState()
Returns the STP state portion of the OFPortState. The returned enum constant will be one of the four STP states and will have isPortState() return true

Returns:

getCurrentFeatures

public java.util.Set<OFPhysicalPort.OFPortFeatures> getCurrentFeatures()

getAdvertisedFeatures

public java.util.Set<OFPhysicalPort.OFPortFeatures> getAdvertisedFeatures()

getSupportedFeatures

public java.util.Set<OFPhysicalPort.OFPortFeatures> getSupportedFeatures()

getPeerFeatures

public java.util.Set<OFPhysicalPort.OFPortFeatures> getPeerFeatures()

isEnabled

public boolean isEnabled()
Returns true if the port is up, i.e., it's neither administratively down nor link down. It currently does NOT take STP state into consideration

Returns:

getCurrentPortSpeed

public OFPhysicalPort.OFPortSpeed getCurrentPortSpeed()
Returns:
the speed of the port (from currentFeatures) if the port is enabled, otherwise return SPEED_NONE

toOFPhysicalPort

public OFPhysicalPort toOFPhysicalPort()

toBriefString

public java.lang.String toBriefString()
Return a brief String describing this port containing the port number and port name

Returns:

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

immutablePortListOf

public static java.util.List<ImmutablePort> immutablePortListOf(java.util.List<OFPortDescription> portDescriptions)
Convert a List of OFPortDescription to a list of ImmutablePorts. All OFPhysicalPorts within the OFPortDescription must be non-null and valid. No other checks (name / number uniqueness) are performed

Parameters:
portDescriptions -
Returns:
a list of ImmutablePorts. This is list is owned by the caller. The returned list is not thread-safe
Throws:
java.lang.NullPointerException - if any OFPhysicalPort or important fields of any OFPhysicalPort are null
java.lang.IllegalArgumentException

immutablePortListOf

public static java.util.List<ImmutablePort> immutablePortListOf(java.util.Collection<OFPhysicalPort> ports)
Convert a Collection of OFPhysicalPorts to a list of ImmutablePorts. All OFPhysicalPorts in the Collection must be non-null and valid. No other checks (name / number uniqueness) are performed

Parameters:
ports -
Returns:
a list of ImmutablePorts. This is list is owned by the caller. The returned list is not thread-safe
Throws:
java.lang.NullPointerException - if any OFPhysicalPort or important fields of any OFPhysicalPort are null
java.lang.IllegalArgumentException

ofPhysicalPortListOf

public static java.util.List<OFPhysicalPort> ofPhysicalPortListOf(java.util.Collection<ImmutablePort> ports)
Convert a Collection of ImmutablePort to a list of OFPhyscialPorts. All ImmutablePorts in the Collection must be non-null. No other checks (name / number uniqueness) are performed

Parameters:
ports -
Returns:
a list of OFPhysicalPorts. This is list is owned by the caller. The returned list is not thread-safe
Throws:
java.lang.NullPointerException - if any ImmutablePort or the port list is null
java.lang.IllegalArgumentException

toString

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