xmlBlaster 2.1.0 API

org.xmlBlaster.util.queue
Class BlockingQueueWrapper

java.lang.Object
  extended by org.xmlBlaster.util.queue.BlockingQueueWrapper
All Implemented Interfaces:
I_StorageSizeListener

public class BlockingQueueWrapper
extends java.lang.Object
implements I_StorageSizeListener

BlockingQueueWrapper is a wrapper to I_Queue which can be used to perform a blocking peek on an I_Queue.

Author:
Michele Laghi

Nested Class Summary
static interface BlockingQueueWrapper.I_BlockingQueueCb
           
 
Field Summary
private  boolean isRegistered
           
private static java.util.logging.Logger log
           
private  long pollInterval
           
private  I_Queue queue
           
private  boolean waiting
           
 
Constructor Summary
BlockingQueueWrapper()
           
BlockingQueueWrapper(long pollInterval)
          Constructor
 
Method Summary
 java.util.List<I_Entry> blockingPeek(int numOfEntries, long timeout)
           
 java.util.List<I_Entry> blockingPeekLowest(int numOfEntries, long timeout, I_QueueEntry limitEntry)
           
 java.util.List<I_Entry> blockingPeekSamePriority(int numOfEntries, long timeout)
           
 java.util.List<I_Entry> blockingPeekWithPriority(int numOfEntries, long timeout, int minPrio, int maxPrio)
           
private  java.util.List<I_Entry> blockingQueueOperation(int numOfEntries, long timeout, int minPrio, int maxPrio, I_QueueEntry limitEntry, BlockingQueueWrapper.I_BlockingQueueCb cb)
          Blocks until at least numOfEntries are found in the queue, or the timeout has occured.
 java.util.List<I_Entry> blockingTakeLowest(int numOfEntries, long timeout, I_QueueEntry limitEntry)
           
 java.util.List<I_Entry> blockingTakeWithPriority(int numOfEntries, long timeout, int minPrio, int maxPrio)
           
 void changed(I_Storage storage, long numEntries, long numBytes, boolean isShutdown)
          Enforced by I_StorageSizeListener.
 void clear()
           
 I_Queue getQueue()
           
 void init(I_Queue queue_)
           
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

pollInterval

private long pollInterval

queue

private I_Queue queue

isRegistered

private boolean isRegistered

waiting

private boolean waiting
Constructor Detail

BlockingQueueWrapper

public BlockingQueueWrapper(long pollInterval)
Constructor

Parameters:
pollInterval - time in milliseconds to wait before a check about the queue size is done.

BlockingQueueWrapper

public BlockingQueueWrapper()
Method Detail

init

public void init(I_Queue queue_)
          throws XmlBlasterException
Throws:
XmlBlasterException

clear

public void clear()

getQueue

public I_Queue getQueue()
Returns:
null after shutdown

shutdown

public void shutdown()

changed

public void changed(I_Storage storage,
                    long numEntries,
                    long numBytes,
                    boolean isShutdown)
Enforced by I_StorageSizeListener.

Specified by:
changed in interface I_StorageSizeListener
Parameters:
queue -
numEntries -
numBytes -
isShutdown -

blockingQueueOperation

private final java.util.List<I_Entry> blockingQueueOperation(int numOfEntries,
                                                             long timeout,
                                                             int minPrio,
                                                             int maxPrio,
                                                             I_QueueEntry limitEntry,
                                                             BlockingQueueWrapper.I_BlockingQueueCb cb)
                                                      throws XmlBlasterException
Blocks until at least numOfEntries are found in the queue, or the timeout has occured. This method can return partial results, i.e. if the requested amout of entries is 10 and the number of entries in the queue is 4 when the timeout occurs, then the four entries found are returned. This method works best if the queue performs its puts without inhibiting queueSizeEvents (the second argument in the put method), since the put would be intercepted directly. However even if the putter decides to inhibit this event, this method will poll according to what specified in the constructor and will work anyway (possibly with a slight offset after the put has occured).

Parameters:
numOfEntries - the number of entries to return (or the maximum number of entries if the timeout occurs).
timeout - The timeout in milliseconds to wait until to return, timeout=0: no blocking, timeout<0:Infinite blocking
Returns:
The ArrayList containing the I_Entry entries of the queue found.
Throws:
XmlBlasterException - if the queue is null or if the backend queue throws an Exception.

blockingPeek

public java.util.List<I_Entry> blockingPeek(int numOfEntries,
                                            long timeout)
                                     throws XmlBlasterException
Throws:
XmlBlasterException

blockingTakeLowest

public java.util.List<I_Entry> blockingTakeLowest(int numOfEntries,
                                                  long timeout,
                                                  I_QueueEntry limitEntry)
                                           throws XmlBlasterException
Throws:
XmlBlasterException

blockingPeekLowest

public java.util.List<I_Entry> blockingPeekLowest(int numOfEntries,
                                                  long timeout,
                                                  I_QueueEntry limitEntry)
                                           throws XmlBlasterException
Throws:
XmlBlasterException

blockingTakeWithPriority

public java.util.List<I_Entry> blockingTakeWithPriority(int numOfEntries,
                                                        long timeout,
                                                        int minPrio,
                                                        int maxPrio)
                                                 throws XmlBlasterException
Throws:
XmlBlasterException

blockingPeekWithPriority

public java.util.List<I_Entry> blockingPeekWithPriority(int numOfEntries,
                                                        long timeout,
                                                        int minPrio,
                                                        int maxPrio)
                                                 throws XmlBlasterException
Throws:
XmlBlasterException

blockingPeekSamePriority

public java.util.List<I_Entry> blockingPeekSamePriority(int numOfEntries,
                                                        long timeout)
                                                 throws XmlBlasterException
Throws:
XmlBlasterException

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.