public class BDBQueue extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
BDBQueue.CloseableIterator<T> |
| Constructor and Description |
|---|
BDBQueue(String queueEnvPath,
String queueName,
int cacheSize)
Creates instance of persistent queue.
|
BDBQueue(String queueEnvPath,
String queueName,
int cacheSize,
boolean readOnly,
boolean allowCreate)
Creates instance of persistent queue.
|
| Modifier and Type | Method and Description |
|---|---|
int |
clear() |
void |
close()
Closes this queue and frees up all resources associated to it.
|
String |
getQueueName()
Returns this queue name.
|
boolean |
isEmpty()
Determines if this queue is empty (equivalent to
). |
BDBQueue.CloseableIterator<byte[]> |
iterator()
Returns an iterator over the elements in this queue.
|
static void |
mkdir(File dir,
boolean createDirectoryIfNotExisting)
Asserts that the given directory exists and creates it if necessary.
|
byte[] |
peek()
Retrieves element from the head of this queue.
|
byte[] |
poll()
Retrieves and and removes element from the head of this queue.
|
void |
push(byte[] element)
Pushes element to the tail of this queue.
|
void |
remove()
Removes the eldest element.
|
long |
size()
Returns the size of this queue.
|
public BDBQueue(String queueEnvPath, String queueName, int cacheSize) throws IOException
queueEnvPath - queue database environment directory pathqueueName - descriptive queue namecacheSize - how often to sync the queue to diskIOException - thrown when the given queueEnvPath does not exist and cannot be created.public BDBQueue(String queueEnvPath, String queueName, int cacheSize, boolean readOnly, boolean allowCreate) throws IOException
queueEnvPath - queue database environment directory pathqueueName - descriptive queue namecacheSize - how often to sync the queue to diskreadOnly - if the db shall be accessed readonlyallowCreate - if true, the db environment is created if it does not exist.IOException - thrown when the given queueEnvPath does not exist and cannot be created.public static void mkdir(@Nonnull File dir, boolean createDirectoryIfNotExisting) throws IOException
dir - the directory that shall existcreateDirectoryIfNotExisting - specifies if the directory shall be created if it does not exist.IOException - thrown if the directory could not be created.public byte[] poll()
throws IOException
IOException - in case of disk IO failurepublic BDBQueue.CloseableIterator<byte[]> iterator() throws IOException
IOException - in case of disk IO failurepublic byte[] peek()
throws IOException
IOException - in case of disk IO failurepublic void remove()
throws NoSuchElementException
NoSuchElementExceptionpublic void push(byte[] element)
throws IOException
element - elementIOException - in case of disk IO failurepublic int clear()
public long size()
public boolean isEmpty()
size() == 0).true if this queue is empty, otherwise false.public String getQueueName()
public void close()
Copyright © 2010-2011. All Rights Reserved.