org.mule.util.queue
Class DualRandomAccessFileQueueStoreDelegate

java.lang.Object
  extended by org.mule.util.queue.AbstractQueueStoreDelegate
      extended by org.mule.util.queue.DualRandomAccessFileQueueStoreDelegate
All Implemented Interfaces:
QueueStoreDelegate, TransactionalQueueStoreDelegate

public class DualRandomAccessFileQueueStoreDelegate
extends AbstractQueueStoreDelegate
implements TransactionalQueueStoreDelegate

TransactionalQueueStoreDelegate implementation using two files for storing the queue data. Entries are stored in the queue file until a certain size in the file. After that size is reached a new file is created and used to store new entries until the previous file queue entries are consumed, in which case the file is cleaned and reused for new entries once the second files gets full.


Field Summary
protected  org.apache.commons.logging.Log logger
           
static int ONE_MEGABYTE
           
 
Constructor Summary
DualRandomAccessFileQueueStoreDelegate(String queueName, String workingDirectory, MuleContext muleContext, int capacity)
           
 
Method Summary
protected  void add(Serializable item)
          Adds an item at the end of the queue
protected  void addFirst(Serializable item)
          Adds an object at the beginning of the queue
 Collection<Serializable> allElements()
           
 void close()
          Releases all resources managed by this queue without removing the queue data.
 boolean contains(Serializable value)
          checks if the given value exists in the queue Used only during recovery phase which means this method does not require great performance
 void dispose()
          Deletes the queue and it's content.
protected  boolean doAddAll(Collection<? extends Serializable> items)
          Adds all the items at the end of the queue
 void doClear()
          Removes all the items in the queue
protected  Serializable getFirst()
          reads the first element in the queue
static File getFirstQueueFile(String queueName, String workingDirectory)
           
static File getSecondQueueFile(String queueName, String workingDirectory)
           
protected  boolean isEmpty()
           
 void remove(Serializable value)
          Remove the specified value from the queue.
protected  Serializable removeFirst()
          removes the first element in the queue
 int size()
           
 
Methods inherited from class org.mule.util.queue.AbstractQueueStoreDelegate
addAll, clear, getSize, offer, peek, poll, putNow, untake
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.util.queue.QueueStoreDelegate
addAll, clear, getSize, offer, peek, poll, putNow, untake
 

Field Detail

ONE_MEGABYTE

public static final int ONE_MEGABYTE
See Also:
Constant Field Values

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

DualRandomAccessFileQueueStoreDelegate

public DualRandomAccessFileQueueStoreDelegate(String queueName,
                                              String workingDirectory,
                                              MuleContext muleContext,
                                              int capacity)
Method Detail

getFirstQueueFile

public static File getFirstQueueFile(String queueName,
                                     String workingDirectory)

getSecondQueueFile

public static File getSecondQueueFile(String queueName,
                                      String workingDirectory)

addFirst

protected void addFirst(Serializable item)
                 throws InterruptedException
Description copied from class: AbstractQueueStoreDelegate
Adds an object at the beginning of the queue

Specified by:
addFirst in class AbstractQueueStoreDelegate
Parameters:
item - object to add
Throws:
InterruptedException

add

protected void add(Serializable item)
Description copied from class: AbstractQueueStoreDelegate
Adds an item at the end of the queue

Specified by:
add in class AbstractQueueStoreDelegate
Parameters:
item - object to add

removeFirst

protected Serializable removeFirst()
                            throws InterruptedException
Description copied from class: AbstractQueueStoreDelegate
removes the first element in the queue

Specified by:
removeFirst in class AbstractQueueStoreDelegate
Returns:
the first element in the queue
Throws:
InterruptedException

getFirst

protected Serializable getFirst()
                         throws InterruptedException
Description copied from class: AbstractQueueStoreDelegate
reads the first element in the queue

Specified by:
getFirst in class AbstractQueueStoreDelegate
Returns:
the fist element in the queue
Throws:
InterruptedException

size

public int size()
Specified by:
size in class AbstractQueueStoreDelegate
Returns:
the number of elements in the queue

isEmpty

protected boolean isEmpty()
Specified by:
isEmpty in class AbstractQueueStoreDelegate
Returns:
true if the queue is empty, false otherwise

doClear

public void doClear()
Description copied from class: AbstractQueueStoreDelegate
Removes all the items in the queue

Specified by:
doClear in class AbstractQueueStoreDelegate

doAddAll

protected boolean doAddAll(Collection<? extends Serializable> items)
Description copied from class: AbstractQueueStoreDelegate
Adds all the items at the end of the queue

Specified by:
doAddAll in class AbstractQueueStoreDelegate
Parameters:
items - objects to add
Returns:
true if it were able to add them all, false otherwise

allElements

public Collection<Serializable> allElements()

remove

public void remove(Serializable value)
Description copied from interface: TransactionalQueueStoreDelegate
Remove the specified value from the queue. Used only during recovery phase which means this method does not require great performance

Specified by:
remove in interface TransactionalQueueStoreDelegate
Parameters:
value - object to be removed

contains

public boolean contains(Serializable value)
Description copied from interface: TransactionalQueueStoreDelegate
checks if the given value exists in the queue Used only during recovery phase which means this method does not require great performance

Specified by:
contains in interface TransactionalQueueStoreDelegate
Parameters:
value - object to check if exists in the queue

close

public void close()
Description copied from interface: TransactionalQueueStoreDelegate
Releases all resources managed by this queue without removing the queue data.

Specified by:
close in interface TransactionalQueueStoreDelegate

dispose

public void dispose()
Description copied from interface: QueueStoreDelegate
Deletes the queue and it's content.

Specified by:
dispose in interface QueueStoreDelegate


Copyright © 2003–2014 MuleSoft, Inc.. All rights reserved.