|
OSMQ v2.0.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectosmq.mque.MQue
A thread-safe, byte-oriented FIFO (first-in first-out) queue that holds byte array and/or String elements. An instance can have one or more writing threads, but limited to only one reader.
This class is an alternative to an OS pipe, since a Queue can hold any number of objects, limted only by its implementation.
The implementation includes the following aggreagate classes:
1) a MemoryFifo (memory-resident) and
2) a DiskFifo (file-resident)
The MQue uses the MemoryFifo exclusively until a user-definable threshold capacity is reached. It then utilizes the DiskFifo to hold the excess entries.
A MemoryFifo is instantiated in an opened state. with a DiskFifo being created only if/when necessary.
Basic Algorithms Read priority is
1) putback element
2) disk
3) memory
Always write to the MemoryFifo, with a test before the write to determine whether memory is full. If it is full, the memory elements are appended to the DiskFifo.
Constructor Summary | |
MQue()
|
|
MQue(java.lang.String name)
|
|
MQue(java.lang.String name,
long startcount)
|
Method Summary | |
void |
clear()
Clears the queue of all elements. |
void |
clearHighestSize()
Clears the highest count. |
void |
close()
Halts all writes, resulting in a QueueException being thrown on any subsequent calls to the Queue object's write methods. |
boolean |
flushToPullCount(long count)
Empty records from the queue until the pulled count equals a specific value |
long |
getBytesWritten()
Returns the cumulative length (in bytes) of all elements that have been written to the queue. |
long |
getEventCount()
Returns the number of element read events. |
java.lang.String |
getInstanceName()
Returns a name associated with this MQue instance. |
int |
getMaxThreshold()
Returns the maximum capacity threshold (element count). |
int |
getPagingThreshold()
Returns the paging threshold (in elements). |
long |
getPullCount()
Returns the number of elements that have been read from the queue since it was instantiated. |
long |
getPushCount()
Returns the number of elements that have been written to the queue since it was instantiated. |
long |
highestSize()
Returns the highest queue count (elements on the queue) since the queue was instantiated or since the max count was cleared. |
boolean |
isClosed()
Returns true if the queue has been closed. |
boolean |
isEmpty()
Returns true if the queue size (element count) is zero. |
boolean |
isHaltReads()
Returns true if the queue is in a read halt state. |
boolean |
isHaltWrites()
Returns true if the queue is in a write halt state. |
boolean |
isOpen()
Returns true if the queue is in an opened state. |
byte[] |
nextElement()
Returns the next element from the queue. |
void |
open()
Reopens a queue that has been closed. |
void |
putBack(byte[] o)
Returns an element that was pulled from the queue. |
byte[] |
readBytes()
Returns the next element in the queue as a byte array. |
byte[] |
readBytesNoWait()
Returns the next element in the queue as a byte array. |
java.lang.String |
readString()
Returns the next element on the queue as a String. |
java.lang.String |
readStringNoWait()
Returns the next element on the queue as a String. |
void |
setHaltWrites(boolean halt)
Sets the write halt mode. |
void |
setInstanceName(java.lang.String instancename)
Sets a name associated with this MQue instance. |
void |
setMaxThreshold(int threshold)
Sets the maximum capacity threshold. |
void |
setPagingThreshold(int v)
Sets the element count threshold, where overflow elements are paged to disk. |
long |
size()
Returns the number of elements currently on the queue. |
java.lang.String |
toString()
|
void |
writeAllFromQue(MQue f)
Pulls elements from another queue, writing them to this queue. |
void |
writeBytes(byte[] s)
Creates a duplicate copy of the byte array and writes it to the queue. |
void |
writeBytesNoDuplicate(byte[] s)
Writes the byte array to the queue without duplicating it. |
void |
writeString(java.lang.String s)
Writes a String to the queue. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public MQue()
public MQue(java.lang.String name)
public MQue(java.lang.String name, long startcount)
Method Detail |
public java.lang.String getInstanceName()
public void setInstanceName(java.lang.String instancename)
public java.lang.String toString()
public final long getBytesWritten()
public void writeString(java.lang.String s) throws java.io.IOException
java.io.IOException
- if queue is in a closed state,
if the queue is in a write-halt state, or
if the total number of elements in the queue would
exceed the max allowable count.public void writeBytes(byte[] s) throws java.io.IOException
writeBytes
in interface Writable
java.io.IOException
- if queue is in a closed state,
if the queue is in a write-halt state, or
if the total number of elements in the queue would
exceed the max allowable count.public void writeBytesNoDuplicate(byte[] s) throws java.io.IOException
java.io.IOException
- if queue is in a closed state,
if the queue is in a write-halt state, or
if the total number of elements in the queue would
exceed the max allowable count.public byte[] readBytesNoWait() throws java.io.IOException
java.io.IOException
- if queue is in a closed state and the
queue is empty.public byte[] readBytes() throws java.io.IOException
java.io.IOException
- if queue is in a closed state and the
queue is empty.public boolean flushToPullCount(long count) throws java.io.IOException
java.io.IOException
public void clear() throws java.io.IOException
java.io.IOException
public boolean isOpen()
public boolean isClosed()
public void open()
public void close()
public void writeAllFromQue(MQue f) throws java.io.IOException
java.io.IOException
public java.lang.String readStringNoWait() throws java.io.IOException
java.io.IOException
- if queue is in a closed state and the
queue is empty.public java.lang.String readString() throws java.io.IOException
java.io.IOException
- if queue is in a closed state and the
queue is empty.public void putBack(byte[] o) throws java.io.IOException
java.io.IOException
- if no read has been performed since the
last occurance of a putBack(), or if the queue is closed.public boolean isEmpty()
public byte[] nextElement()
readBytes()
public long size()
public long highestSize()
clearHighestSize()
public void clearHighestSize()
highestSize()
public long getPushCount()
public long getPullCount()
public boolean isHaltWrites()
public void setHaltWrites(boolean halt)
public boolean isHaltReads()
public void setPagingThreshold(int v)
getPagingThreshold()
public int getPagingThreshold()
setPagingThreshold(int)
public void setMaxThreshold(int threshold)
public int getMaxThreshold()
public long getEventCount()
getEventCount
in interface EventCounter
|
(c) 2000 - 2003 MQue Systems All Rights Reserved |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |