its.element
Class OutputQueue

java.lang.Object
  extended byits.element.OutputQueue
All Implemented Interfaces:
FrameTarget

public class OutputQueue
extends java.lang.Object
implements FrameTarget

Returns ITS frames to the waiting OutputBuffers according to the state in each OutputCookie. Implements the precedence semantics of ITS frames (e.g. that Dictionary has precedence over Data) OutputQueue contains a slot for each of the ITS frame types which holds the most recently received frame of that type. The OutputCookie is owned by the OutputBuffer but is opaque to that class, it contains state maintained by OutputQueue. When an OutputBuffer tries to read a frame from the OutputQueue, the OutputQueue checks the OutputCookie to determine if the OutputBuffer has already seen the frame in the slot. If the OutputBuffer has already processed all frames held by the OutputQueue, the OutputBuffer waits. The OutputQueue implements the precedence of frames types through the order in which the slots are checked: first Schema, then Contents, then Extractor, and finally Data. At each slot, the current frame is sent if the OutputCookie indicates, otherwise OutputQueue moves to the next slot

Author:
Rick Kint

Constructor Summary
OutputQueue()
          creates an empty OutputQueue
 
Method Summary
 void add(ItsFrame newFrame)
          add adds a frame in the appropriate slot and notifies waiting threads
 ItsFrame get(OutputCookie cookie)
          returns the appropriate frame after examining the cookie, it may wait if there is nothing there
 int getTimeout()
           
 void setTimeout(int timeout)
          For each OutputBuffer thread created by the ConnectionDaemon, if the given timeout value (in milliseconds) elapses without a new ItsFrame being added to the OutputQueue, the thread will expire and its socket will be closed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputQueue

public OutputQueue()
creates an empty OutputQueue

Method Detail

add

public void add(ItsFrame newFrame)
add adds a frame in the appropriate slot and notifies waiting threads

Specified by:
add in interface FrameTarget
Parameters:
newFrame - contains the new ItsFrame

get

public ItsFrame get(OutputCookie cookie)
             throws java.lang.InterruptedException,
                    java.io.InterruptedIOException
returns the appropriate frame after examining the cookie, it may wait if there is nothing there

Returns:
ItsFrame
Throws:
java.lang.InterruptedException - if the wait was interrupted
java.io.InterruptedIOException - if the timeout period elapsed during a wait

setTimeout

public void setTimeout(int timeout)
For each OutputBuffer thread created by the ConnectionDaemon, if the given timeout value (in milliseconds) elapses without a new ItsFrame being added to the OutputQueue, the thread will expire and its socket will be closed. This is symmetric with what happens on the client side, in the ClientConnection class. By default, the timeout is 3 minutes.


getTimeout

public int getTimeout()