DRCL J-Sim API

drcl.inet.core.queue
Class PriorityQueue

java.lang.Object
  extended bydrcl.DrclObj
      extended bydrcl.comp.Component
          extended bydrcl.comp.queue.ActiveQueue
              extended bydrcl.inet.core.Queue
                  extended bydrcl.inet.core.queue.PriorityQueue
All Implemented Interfaces:
java.lang.Cloneable, InetConstants, InetCoreConstants, ObjectCloneable, ObjectDuplicable, PktClassifier, java.io.Serializable
Direct Known Subclasses:
PreemptPriorityQueue

public class PriorityQueue
extends Queue
implements PktClassifier

PriorityQueue is an m-level queue. m is configurable. Specifically, it consists of m FIFO queues, each associated with a queue logic. The level-0 queue has the highest priority while the level-(m-1) queue has the lowest. It uses a PktClassifier to classify the incoming packets into m levels. When a packet arrives, the packet is classified into one of the m level and is put in that FIFO queue if the corresponding queue logic permits. The component treats a packet as lowest priority if no level of queue is found for the packet.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class drcl.comp.Component
Component.Locks
 
Field Summary
static java.lang.String EVENT_QSIZE_PORT_ID
          Name of the port that exports the instant queue size change events.
 
Fields inherited from class drcl.comp.queue.ActiveQueue
OUTPUT_PORT_ID
 
Fields inherited from class drcl.comp.Component
FLAG_COMPONENT_NOTIFICATION, FLAG_DEBUG_ENABLED, FLAG_DIRECT_OUTPUT_ENABLED, FLAG_ENABLED, FLAG_ERROR_ENABLED, FLAG_EVENT_ENABLED, FLAG_GARBAGE_DISPLAY_ENABLED, FLAG_GARBAGE_ENABLED, FLAG_PORT_NOTIFICATION, FLAG_STARTED, FLAG_STOPPED, FLAG_TRACE_ENABLED, FLAG_UNDEFINED_START, id, infoPort, locks, name, parent, PortGroup_DEFAULT_GROUP, PortGroup_EVENT, PortGroup_SERVICE, Root, Trace_DATA, Trace_SEND
 
Fields inherited from interface drcl.inet.core.InetCoreConstants
CONFIG_PORT_ID, PULL_PORT_ID
 
Fields inherited from interface drcl.inet.InetConstants
BYTE_MODE, DEFAULT_BANDWIDTH, DEFAULT_BUFFER_SIZE, DEFAULT_MTU, EVENT_ID_CHANGED_PORT_ID, EVENT_IDENTITY_ADDED, EVENT_IDENTITY_REMOVED, EVENT_IF_NEIGHBOR_DOWN, EVENT_IF_NEIGHBOR_UP, EVENT_IF_PORT_ID, EVENT_LINK_BROKEN, EVENT_LINK_BROKEN_PORT_ID, EVENT_MCAST_HOST_PORT_ID, EVENT_PKT_ARRIVAL, EVENT_PKT_ARRIVAL_PORT_ID, EVENT_RT_ENTRY_ADDED, EVENT_RT_ENTRY_MODIFIED, EVENT_RT_ENTRY_REMOVED, EVENT_RT_MCAST_CHANGED_PORT_ID, EVENT_RT_UCAST_CHANGED_PORT_ID, EVENT_VIF_NEIGHBOR_DOWN, EVENT_VIF_NEIGHBOR_UP, EVENT_VIF_PORT_ID, HOST_ENTRY_EXT, ID_CSL, ID_TRACE_RT, MCAST_QUERY_PORT_ID, PACKET_MODE, PID_AODV, PID_DV, PID_DVMRP, PID_HELLO, PID_IGMP, PID_OSPF, PID_RSVP, PID_TCP, PID_TRACE_RT, PID_UDP, SERVICE_CONFIGSW_PORT_ID, SERVICE_ID_PORT_ID, SERVICE_IF_PORT_ID, SERVICE_MCAST_PORT_ID, SERVICE_RT_PORT_ID, UCAST_QUERY_PORT_ID
 
Constructor Summary
PriorityQueue()
           
PriorityQueue(java.lang.String id_)
           
 
Method Summary
 int classify(Packet p_)
          Implements PktClassifier.classify(drcl.net.Packet).
 java.lang.Object dequeue()
          Dequeues and returns the first object in the queue.
 void duplicate(java.lang.Object source_)
          Duplicates the content of source_, including ID, name, child components and connections among them, to this component.
 java.lang.Object enqueue(java.lang.Object obj_)
          Enqueues the object at the end of the queue
 java.lang.Object firstElement()
          Retrieves but not dequeue the first object in the queue.
 int getCapacity()
          Returns the capacity of the queue.
 QLogic getQLogic(int level_)
           
 Queue getQueue(int level_)
           
 int getSize()
          Returns the current size of the queue.
 java.lang.String info(java.lang.String prefix_)
           
 boolean isDropHeadEnabled()
           
 boolean isEmpty()
          Return true if the queue is empty.
 boolean isFull()
          Return true if the queue is full.
 java.lang.Object lastElement()
          Retrieves but not remove the last object in the queue.
 java.lang.Object peekAt(int pos_)
          Retrieves but not remove the object at the position specified.
 void reset()
          Resets the component for being used anew.
 void setCapacity(int capacity_)
          Sets the capacity of the queue.
 void setClassifier(PktClassifier pc_)
           
 void setDropHeadEnabled(boolean enabled_)
           
 void setLevels(int nlevels_)
           
 void setQLogic(int level_, QLogic qlogic_)
           
 
Methods inherited from class drcl.inet.core.Queue
getMode, setMode
 
Methods inherited from class drcl.comp.queue.ActiveQueue
enqueueAt, getAvailableSize, increaseEnqueCount, info, retrieveAt
 
Methods inherited from class drcl.comp.Component
addComponent, addComponent, addEventPort, addEventPort, addForkPort, addPort, addPort, addPort, addPort, addPort, addPort, addPort, addPort, addServerPort, addServerPort, cancelFork, connect, containsComponent, containsComponent, containsPort, debug, disconnectAll, disconnectAllPeers, disconnectAllPorts, drop, drop, error, error, expose, exposeEventPorts, exposePort, exposePort, exposePort, exposePort, exposePort, findAvailable, findAvailable, findAvailable, fork, forkAt, getAllComponents, getAllPorts, getAllPorts, getAllWiresInside, getAllWiresInsideOut, getAllWiresOut, getComponent, getComponentFlag, getComponentFlag, getContract, getContractHT, getContractHT, getDebugFlagsInBinary, getDebugLevelNames, getID, getName, getParent, getPort, getPort, getRoot, getTime, iduplicate, isAncestorOf, isContainer, isDebugEnabled, isDebugEnabledAt, isDirectlyRelatedTo, isDirectOutputEnabled, isEnabled, isErrorNoticeEnabled, isEventExportEnabled, isGarbageDisplayEnabled, isGarbageEnabled, isPortRemovable, isStarted, isStopped, isTraceEnabled, lock, notify, notifyAll, operate, reboot, removeAll, removeAllComponents, removeAllPorts, removeAllPorts, removeComponent, removeComponent, removePort, removePort, removePort, resume, run, sduplicate, send, sendAt, setComponentFlag, setComponentFlag, setDebugEnabled, setDebugEnabled, setDebugEnabledAt, setDebugEnabledAt, setDebugEnabledAt, setDirectOutputEnabled, setDirectOutputEnabled, setEnabled, setErrorNoticeEnabled, setErrorNoticeEnabled, setEventExportEnabled, setEventExportEnabled, setExecutionBoundary, setGarbageDisplayEnabled, setGarbageDisplayEnabled, setGarbageEnabled, setGarbageEnabled, setID, setID, setName, setPort, setPort, setTraceEnabled, setTraceEnabled, sleepFor, sleepUntil, stop, toString, unexpose, unlock, useLocalForkManager, useLocalForkManager, wait
 
Methods inherited from class drcl.DrclObj
clone
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EVENT_QSIZE_PORT_ID

public static final java.lang.String EVENT_QSIZE_PORT_ID
Name of the port that exports the instant queue size change events.

See Also:
Constant Field Values
Constructor Detail

PriorityQueue

public PriorityQueue()

PriorityQueue

public PriorityQueue(java.lang.String id_)
Method Detail

classify

public int classify(Packet p_)
Implements PktClassifier.classify(drcl.net.Packet). It simply return (1 - the first bit of the ToS field of the INET header) so CONTROL packets have higher priority than DATA packets.

Specified by:
classify in interface PktClassifier

setClassifier

public void setClassifier(PktClassifier pc_)

reset

public void reset()
Description copied from class: Component
Resets the component for being used anew. All the internal variables must be set to the initial state. All the ports and child components are reset as well.

Overrides:
reset in class Queue

duplicate

public void duplicate(java.lang.Object source_)
Description copied from class: Component
Duplicates the content of source_, including ID, name, child components and connections among them, to this component. Subclasses need to override this method to copy its own variables.

Specified by:
duplicate in interface ObjectDuplicable
Overrides:
duplicate in class Queue

info

public java.lang.String info(java.lang.String prefix_)
Overrides:
info in class Queue

getQueue

public Queue getQueue(int level_)

setQLogic

public void setQLogic(int level_,
                      QLogic qlogic_)
Parameters:
level_ - level index of the queue logic.

setLevels

public void setLevels(int nlevels_)

getQLogic

public QLogic getQLogic(int level_)

enqueue

public java.lang.Object enqueue(java.lang.Object obj_)
Enqueues the object at the end of the queue

Specified by:
enqueue in class ActiveQueue
Returns:
the object being dropped due to the enqueue; null otherwise.

dequeue

public java.lang.Object dequeue()
Dequeues and returns the first object in the queue.

Specified by:
dequeue in class ActiveQueue
Returns:
the object dequeued; null if queue is empty.

peekAt

public java.lang.Object peekAt(int pos_)
Retrieves but not remove the object at the position specified.

Overrides:
peekAt in class ActiveQueue
Returns:
the object; null if position is not valid.

firstElement

public java.lang.Object firstElement()
Retrieves but not dequeue the first object in the queue.

Overrides:
firstElement in class ActiveQueue
Returns:
the object; null if queue is empty.

lastElement

public java.lang.Object lastElement()
Retrieves but not remove the last object in the queue.

Overrides:
lastElement in class ActiveQueue
Returns:
the object; null if queue is empty.

isFull

public boolean isFull()
Return true if the queue is full.

Specified by:
isFull in class ActiveQueue

isEmpty

public boolean isEmpty()
Return true if the queue is empty.

Specified by:
isEmpty in class ActiveQueue

setCapacity

public void setCapacity(int capacity_)
Sets the capacity of the queue.

Specified by:
setCapacity in class Queue
Parameters:
capacity_ - the new capacity.

getCapacity

public int getCapacity()
Returns the capacity of the queue.

Specified by:
getCapacity in class Queue

getSize

public int getSize()
Returns the current size of the queue.

Specified by:
getSize in class Queue

setDropHeadEnabled

public void setDropHeadEnabled(boolean enabled_)

isDropHeadEnabled

public boolean isDropHeadEnabled()

DRCL J-Sim API

Copyright © 1998-2003 Distributed Real-time Computing Lab (DRCL). All Rights Reserved.     ~ To J-Sim Home ~