Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq.io.util
Class MemoryBoundedQueue  view MemoryBoundedQueue download MemoryBoundedQueue.java

java.lang.Object
  extended byorg.activemq.io.util.MemoryBoundedQueue
All Implemented Interfaces:
MemoryBoundedObject
Direct Known Subclasses:
MemoryBoundedPrioritizedQueue

public class MemoryBoundedQueue
extends java.lang.Object
implements MemoryBoundedObject

MemoryBoundedQueue is a queue bounded by memory usage for MemoryManageables

Version:
$Revision: 1.1.1.1 $

Field Summary
protected  boolean closed
           
protected  java.lang.Object inLock
           
private  org.activemq.service.impl.DefaultQueueList internalList
           
private static org.apache.commons.logging.Log log
           
private  MemoryBoundedQueueManager manager
           
private  SynchronizedLong memoryUsedByThisQueue
           
private  java.lang.String name
           
private static int OBJECT_OVERHEAD
           
protected  java.lang.Object outLock
           
protected  boolean stopped
           
protected static int WAIT_TIMEOUT
           
 
Constructor Summary
MemoryBoundedQueue(MemoryBoundedQueueManager manager, java.lang.String name)
          Constructor
 
Method Summary
 void clear()
          remove any MemoryManageables in the queue
 void close()
          close and remove this queue from the MemoryBoundedQueueManager
protected  void decrementMemoryUsed(MemoryManageable packet)
           
 MemoryManageable dequeue()
           
 MemoryManageable dequeue(long timeInMillis)
          Dequeues a MemoryManageable from the head of the queue
 MemoryManageable dequeueNoWait()
          dequeues a MemoryManageable from the head of the queue
 void enqueue(MemoryManageable packet)
          Enqueue a MemoryManageable to this queue
 void enqueueAllFirstNoBlock(java.util.List packets)
          Enqueue an array of packets to the head of the queue with total disregard for memory constraints
 void enqueueFirst(MemoryManageable packet)
          Enqueue a MemoryManageable to the head of the queue
 void enqueueFirstNoBlock(MemoryManageable packet)
          Enqueue a packet to the head of the queue with total disregard for memory constraints
 void enqueueNoBlock(MemoryManageable packet)
          Enqueue a MemoryManageable without checking memory usage limits
 MemoryManageable get(int index)
          retrieve a MemoryManageable at an indexed position in the queue
 java.util.List getContents()
          Retrieve a shallow copy of the contents as a list
 long getLocalMemoryUsedByThisQueue()
           
 java.lang.String getName()
           
protected  void incrementMemoryUsed(MemoryManageable packet)
           
 boolean isEmpty()
           
 boolean isStarted()
           
 boolean remove(MemoryManageable packet)
          Remove a packet from the queue
 MemoryManageable remove(java.lang.Object id)
          Remove a MemoryManageable by it's id
 int size()
           
 void start()
          enable dequeueing
 void stop()
          disable dequeueing
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

OBJECT_OVERHEAD

private static final int OBJECT_OVERHEAD
See Also:
Constant Field Values

WAIT_TIMEOUT

protected static final int WAIT_TIMEOUT
See Also:
Constant Field Values

manager

private final MemoryBoundedQueueManager manager

name

private final java.lang.String name

outLock

protected final java.lang.Object outLock

inLock

protected final java.lang.Object inLock

internalList

private final org.activemq.service.impl.DefaultQueueList internalList

stopped

protected boolean stopped

closed

protected boolean closed

memoryUsedByThisQueue

private SynchronizedLong memoryUsedByThisQueue
Constructor Detail

MemoryBoundedQueue

public MemoryBoundedQueue(MemoryBoundedQueueManager manager,
                          java.lang.String name)
Constructor

Method Detail

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


size

public int size()

getLocalMemoryUsedByThisQueue

public long getLocalMemoryUsedByThisQueue()

close

public void close()
close and remove this queue from the MemoryBoundedQueueManager

Specified by:
close in interface MemoryBoundedObject

enqueueNoBlock

public void enqueueNoBlock(MemoryManageable packet)
Enqueue a MemoryManageable without checking memory usage limits


enqueue

public void enqueue(MemoryManageable packet)
Enqueue a MemoryManageable to this queue


enqueueFirstNoBlock

public void enqueueFirstNoBlock(MemoryManageable packet)
Enqueue a packet to the head of the queue with total disregard for memory constraints


enqueueAllFirstNoBlock

public void enqueueAllFirstNoBlock(java.util.List packets)
Enqueue an array of packets to the head of the queue with total disregard for memory constraints


enqueueFirst

public void enqueueFirst(MemoryManageable packet)
                  throws java.lang.InterruptedException
Enqueue a MemoryManageable to the head of the queue


dequeue

public MemoryManageable dequeue()
                         throws java.lang.InterruptedException

dequeue

public MemoryManageable dequeue(long timeInMillis)
                         throws java.lang.InterruptedException
Dequeues a MemoryManageable from the head of the queue


dequeueNoWait

public MemoryManageable dequeueNoWait()
                               throws java.lang.InterruptedException
dequeues a MemoryManageable from the head of the queue


isStarted

public boolean isStarted()

stop

public void stop()
disable dequeueing


start

public void start()
enable dequeueing


remove

public boolean remove(MemoryManageable packet)
Remove a packet from the queue


remove

public MemoryManageable remove(java.lang.Object id)
Remove a MemoryManageable by it's id


clear

public void clear()
remove any MemoryManageables in the queue


isEmpty

public boolean isEmpty()

get

public MemoryManageable get(int index)
retrieve a MemoryManageable at an indexed position in the queue


getContents

public java.util.List getContents()
Retrieve a shallow copy of the contents as a list


incrementMemoryUsed

protected void incrementMemoryUsed(MemoryManageable packet)

decrementMemoryUsed

protected void decrementMemoryUsed(MemoryManageable packet)

getName

public java.lang.String getName()