net.clackrouter.component.base
Class Queue

java.lang.Object
  extended by net.clackrouter.component.base.ClackComponent
      extended by net.clackrouter.component.base.Queue
All Implemented Interfaces:
Alarm
Direct Known Subclasses:
ByteQueue, FlowByteQueue, REDQueue

public class Queue
extends ClackComponent

Base class for any Clack queue.

This class measures queue occupancy in packets and can contain any type of packet. This class provides basic functionality inherited by more advanced queues


Nested Class Summary
 
Nested classes/interfaces inherited from class net.clackrouter.component.base.ClackComponent
ClackComponent.Waiter
 
Field Summary
static int DEFAULT_SIZE
           
protected  int m_max_size
           
protected  java.util.ArrayList m_queue
           
protected  boolean m_recent_drop
           
protected  int m_total_drops
           
protected  ClackOccData mQueueOccData
           
static int NUM_PORTS
           
static int PORT_HEAD
           
static int PORT_TAIL
           
protected  java.util.Date startTime
           
 
Fields inherited from class net.clackrouter.component.base.ClackComponent
componentCell, m_has_error, m_log, m_name, m_num_ports, m_packetcount_in, m_packetcount_out, m_ports, mListeners, mRouter, pendingError, SIGNAL_ERROR_LEN_MSEC, UNIQUE_COUNT, view
 
Constructor Summary
Queue(Router router, java.lang.String name)
           
Queue(Router router, java.lang.String name, int start_size)
           
 
Method Summary
 void acceptPacket(VNSPacket packet, int port_number)
          Enqueues a packet at the tail of the queue, if possible, or drops it if it is already at max occupancy.
 int getMaxOccupancy()
          The max occupancy of the queue
 int getOccupancy()
          The current occupancy of the queue
 javax.swing.JPanel getPropertiesView()
          Method for getting the properties view associated with this component Property views are used to display more detailed information about internal component state.
 ClackOccData getQueueOccData()
          Provides data of queue occupancy vs time for real-time graphs.
 java.util.Properties getSerializableProperties(boolean isTransient)
          Serialize the queue's size for reloading the router
 int getTotalDropped()
          Total number of packets dropped by this queue
 VertexView getView(JGraph graph, CellMapper mapper)
          Override default ClackComponent method that returns a ClackComponentView since queues are rendered differently within a RouterView.
 VNSPacket handlePullRequest(int port_number)
          Removes a packet from the head of the queue, if possible, and returns it.
 void initializeProperties(java.util.Properties props)
          Load the saved size value
 boolean isModifying()
          Reports whether this component modifies packets passed through it This value is used by the static checking algorithm used to make sure port connections are valid.
protected  void queueOccupancyChanged()
          Helper method to update graph and GUI queue when occupancy has been changed.
 boolean recentDropTest()
          Test whether we have just dropped a packet (used by QueueView).
 void setMaxOccupancy(int newMax)
          Set the max occupancy of this queue
protected  void setupPorts(int numports)
          Allocates an array of ClackPort objects to be used by this component
 
Methods inherited from class net.clackrouter.component.base.ClackComponent
createCopy, createInputPullPort, createInputPushPort, createOutputPullPort, createOutputPushPort, error, fireListeners, getColor, getComponentCell, getHierarchicalView, getLog, getName, getNumPorts, getPacketCountIn, getPacketCountOut, getPendingError, getPort, getRouter, getTime, getTypeName, getUniqueCount, hasError, isHierarchical, log, notifyAlarm, poll, registerListener, sendOutPort, setAlarm, setComponentCell, setName, setPendingError, setView, showErrorDialog, signalError, try_repaint, unregisterListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PORT_HEAD

public static int PORT_HEAD

PORT_TAIL

public static int PORT_TAIL

NUM_PORTS

public static int NUM_PORTS

DEFAULT_SIZE

public static int DEFAULT_SIZE

m_max_size

protected int m_max_size

m_total_drops

protected int m_total_drops

m_recent_drop

protected boolean m_recent_drop

startTime

protected java.util.Date startTime

m_queue

protected transient java.util.ArrayList m_queue

mQueueOccData

protected transient ClackOccData mQueueOccData
Constructor Detail

Queue

public Queue(Router router,
             java.lang.String name)

Queue

public Queue(Router router,
             java.lang.String name,
             int start_size)
Method Detail

setupPorts

protected void setupPorts(int numports)
Description copied from class: ClackComponent
Allocates an array of ClackPort objects to be used by this component

Overrides:
setupPorts in class ClackComponent
Parameters:
numports - the number of ports to create

isModifying

public boolean isModifying()
Description copied from class: ClackComponent
Reports whether this component modifies packets passed through it This value is used by the static checking algorithm used to make sure port connections are valid. Sub-classes that do not modify packets should override this method

Overrides:
isModifying in class ClackComponent
Returns:
by default, we assume the component modifies packets

acceptPacket

public void acceptPacket(VNSPacket packet,
                         int port_number)
Enqueues a packet at the tail of the queue, if possible, or drops it if it is already at max occupancy.

Overrides:
acceptPacket in class ClackComponent
Parameters:
packet - The pushed packet
port_number - The number of the port that this packet is arriving on

handlePullRequest

public VNSPacket handlePullRequest(int port_number)
Removes a packet from the head of the queue, if possible, and returns it.

Overrides:
handlePullRequest in class ClackComponent
Parameters:
port_number - The port that a packet is being requested on
Returns:
A packet if available for pull, or null

queueOccupancyChanged

protected void queueOccupancyChanged()
Helper method to update graph and GUI queue when occupancy has been changed.


getOccupancy

public int getOccupancy()
The current occupancy of the queue


getMaxOccupancy

public int getMaxOccupancy()
The max occupancy of the queue


setMaxOccupancy

public void setMaxOccupancy(int newMax)
Set the max occupancy of this queue


getTotalDropped

public int getTotalDropped()
Total number of packets dropped by this queue


recentDropTest

public boolean recentDropTest()
Test whether we have just dropped a packet (used by QueueView).


getQueueOccData

public ClackOccData getQueueOccData()
Provides data of queue occupancy vs time for real-time graphs.


getPropertiesView

public javax.swing.JPanel getPropertiesView()
Description copied from class: ClackComponent
Method for getting the properties view associated with this component Property views are used to display more detailed information about internal component state. This method creates a default property view, and can be overriden to provide custom properties views

Overrides:
getPropertiesView in class ClackComponent
Returns:
this component's property view

getView

public VertexView getView(JGraph graph,
                          CellMapper mapper)
Override default ClackComponent method that returns a ClackComponentView since queues are rendered differently within a RouterView.

Overrides:
getView in class ClackComponent
Parameters:
graph - the Router Graph
mapper - the CellMapper associated with this Router Graph
Returns:
the VertexView for rendering this component

getSerializableProperties

public java.util.Properties getSerializableProperties(boolean isTransient)
Serialize the queue's size for reloading the router

Overrides:
getSerializableProperties in class ClackComponent
Parameters:
isTransient - flag indicating if serialization is transient
Returns:
all property key-value pairs to serialize

initializeProperties

public void initializeProperties(java.util.Properties props)
Load the saved size value

Overrides:
initializeProperties in class ClackComponent
Parameters:
props - all property values serialized for this component