cgl.narada.util
Class DataQueue

java.lang.Object
  extended by cgl.narada.util.DataQueue

public class DataQueue
extends Object

A message queue. Each message is an array of bytes. By default, the queue size will grow infinitely.

Version:
1.0

Constructor Summary
DataQueue()
           
 
Method Summary
 void addAll(byte[] data)
          This method is used by HTTP Transport threads.
 void addData(byte[] data)
          ------------------------------------------------------------
 void dispose()
          ------------------------------------------------------------
 int getMaxQueueSize()
          ------------------------------------------------------------
 int getNumMessages()
          ------------------------------------------------------------
 int getQueueSize()
          ------------------------------------------------------------
 byte[] removeAll()
          This method is used by HTTP Transport threads, which buffers messages until it reaches a certain size; then just send all in the buffer in one HTTP post.
 cgl.narada.util.DataRecord[] removeAll2()
           
 byte[] removeData()
          ------------------------------------------------------------ Remove a piece of data from the data queue.
 byte[] removeData(long waitTime)
          ------------------------------------------------------------ Will block until new data segment is available.
 void setMaxQueueSize(int size)
          ------------------------------------------------------------ Sets the maximum # of bytes the queu can handle before blocking on add.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataQueue

public DataQueue()
Method Detail

addAll

public void addAll(byte[] data)
This method is used by HTTP Transport threads. It assumes that data added consists of one or more messages, each of them led by the message length. Added by Hongbin


removeAll

public byte[] removeAll()
This method is used by HTTP Transport threads, which buffers messages until it reaches a certain size; then just send all in the buffer in one HTTP post. Note byte array it returns includes length for each message. Added by Hongbin


removeAll2

public cgl.narada.util.DataRecord[] removeAll2()

setMaxQueueSize

public void setMaxQueueSize(int size)
------------------------------------------------------------ Sets the maximum # of bytes the queu can handle before blocking on add. 0 is infinite.


getMaxQueueSize

public int getMaxQueueSize()
------------------------------------------------------------


getQueueSize

public int getQueueSize()
------------------------------------------------------------


getNumMessages

public int getNumMessages()
------------------------------------------------------------


removeData

public byte[] removeData()
------------------------------------------------------------ Remove a piece of data from the data queue. Wait infinitely for it.


removeData

public byte[] removeData(long waitTime)
------------------------------------------------------------ Will block until new data segment is available.

Parameters:
waitTime - wait this number of milliseconds. If nothing appears then return null.

addData

public void addData(byte[] data)
------------------------------------------------------------


dispose

public void dispose()
------------------------------------------------------------



For comments and suggestions please send e-mail to The NaradaBrokering Project