public class BigQueue extends Object implements Closeable
| Constructor and Description |
|---|
BigQueue(String queueDir,
String queueName)
A big, fast and persistent queue implementation, use default back data
page size, see
BigArray.DEFAULT_DATA_PAGE_SIZE |
BigQueue(String queueDir,
String queueName,
int pageSize)
A big, fast and persistent queue implementation.
|
| Modifier and Type | Method and Description |
|---|---|
void |
applyForEach(ItemIterator iterator) |
void |
close() |
byte[] |
dequeue()
Retrieves and removes the front of a queue
|
com.google.common.util.concurrent.ListenableFuture<byte[]> |
dequeueAsync()
Retrieves a Future which will complete if new Items where enqued.
|
List<byte[]> |
dequeueMulti(int max)
Retrieves and removes the fronts of a queue upto given total number /
total size whichever is smaller
|
void |
enqueue(byte[] data)
Adds an item at the back of a queue
|
void |
flush()
Force to persist current state of the queue,
normally, you don't need to flush explicitly since: 1.) BigQueue will
automatically flush a cached page when it is replaced out, 2.) BigQueue
uses memory mapped file technology internally, and the OS will flush the
changes even your process crashes,
call this periodically only if you need transactional reliability and you
are aware of the cost to performance.
|
void |
gc()
Delete all used data files to free disk space.
|
boolean |
isEmpty()
Determines whether a queue is empty
|
byte[] |
peek()
Retrieves the item at the front of a queue
|
com.google.common.util.concurrent.ListenableFuture<byte[]> |
peekAsync()
Retrieves the item at the front of a queue asynchronously.
|
List<byte[]> |
peekMulti(int max)
Retrieves the items at the front of a queue
|
void |
removeAll()
Removes all items of a queue, this will empty the queue and delete all
back data files.
|
long |
size()
Total number of items available in the queue.
|
public BigQueue(String queueDir, String queueName)
BigArray.DEFAULT_DATA_PAGE_SIZEqueueDir - the directory to store queue dataqueueName - the name of the queue, will be appended as last part of the
queue directorypublic BigQueue(String queueDir, String queueName, int pageSize)
queueDir - the directory to store queue dataqueueName - the name of the queue, will be appended as last part of the
queue directorypageSize - the back data file size per page in bytes, see minimum allowed
BigArray.MINIMUM_DATA_PAGE_SIZEpublic boolean isEmpty()
public void enqueue(byte[] data)
data - to be enqueued datapublic byte[] dequeue()
public List<byte[]> dequeueMulti(int max)
max - the maximum to deququepublic com.google.common.util.concurrent.ListenableFuture<byte[]> dequeueAsync()
public void removeAll()
public byte[] peek()
public List<byte[]> peekMulti(int max)
max - the maximum elements to peekpublic com.google.common.util.concurrent.ListenableFuture<byte[]> peekAsync()
public void applyForEach(ItemIterator iterator)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void gc()
public void flush()
public long size()
Copyright © 2016. All rights reserved.