public class ChronicleQueuePersistor<T> extends java.lang.Object implements QueuePersistor<T>
QueuePersistor
implementation that uses a Java
Chronicle IndexedChronicle to persist items in the queue.Constructor and Description |
---|
ChronicleQueuePersistor(java.lang.String basePath)
Create an
ChronicleQueuePersistor based on the given base path. |
ChronicleQueuePersistor(java.lang.String basePath,
Codec<Buffer,T,T> codec,
boolean clearOnStart,
boolean deleteOnExit,
net.openhft.chronicle.ChronicleQueueBuilder config)
Create an
ChronicleQueuePersistor based on the given base path, encoder and decoder. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the underlying chronicles.
|
Codec<Buffer,T,T> |
codec() |
T |
get(java.lang.Long id)
Return the item with the given id.
|
boolean |
hasNext()
Are there more items waiting to be returned?
|
java.util.Iterator<T> |
iterator() |
long |
lastId()
Get the value of the last item to have been persisted.
|
java.lang.Long |
offer(T t)
Persist and return the last Long id of the item.
|
java.lang.Long |
offerAll(java.util.Collection<T> t)
Persist N items in batch and return a Long id of the last item.
|
net.openhft.chronicle.ExcerptTailer |
reader() |
T |
remove()
Remove the oldest item from the persistence queue.
|
long |
size()
Get the number of items persisted right now.
|
public ChronicleQueuePersistor(@Nonnull java.lang.String basePath) throws java.io.IOException
ChronicleQueuePersistor
based on the given base path.basePath
- Directory in which to create the Chronicle.java.io.IOException
public ChronicleQueuePersistor(@Nonnull java.lang.String basePath, @Nonnull Codec<Buffer,T,T> codec, boolean clearOnStart, boolean deleteOnExit, @Nonnull net.openhft.chronicle.ChronicleQueueBuilder config) throws java.io.IOException
ChronicleQueuePersistor
based on the given base path, encoder and decoder. Optionally,
passing false to clearOnStart
skips clearing the Chronicle on start for appending.basePath
- Directory in which to create the Chronicle.codec
- Codec to turn objects into Buffers
and visa-versa.clearOnStart
- Whether or not to clear the Chronicle on start.deleteOnExit
- Whether or not to delete the Chronicle when the program exits.config
- ChronicleConfig to use.java.io.IOException
public void close()
close
in interface QueuePersistor<T>
public long lastId()
QueuePersistor
lastId
in interface QueuePersistor<T>
public long size()
QueuePersistor
size
in interface QueuePersistor<T>
public boolean hasNext()
QueuePersistor
hasNext
in interface QueuePersistor<T>
true
if items can be retrieved from this persistor, false
otherwisepublic java.lang.Long offer(@Nonnull T t)
QueuePersistor
offer
in interface QueuePersistor<T>
t
- element to persistpublic java.lang.Long offerAll(@Nonnull java.util.Collection<T> t)
QueuePersistor
offerAll
in interface QueuePersistor<T>
t
- element to persistpublic T get(java.lang.Long id)
QueuePersistor
get
in interface QueuePersistor<T>
id
- the given index to lookuppublic net.openhft.chronicle.ExcerptTailer reader()
public T remove()
QueuePersistor
remove
in interface QueuePersistor<T>