public class ChronicleQueuePersistor<T> extends Object implements QueuePersistor<T>
QueuePersistor
implementation that uses a Java
Chronicle IndexedChronicle to persist items in the queue.Constructor and Description |
---|
ChronicleQueuePersistor(String basePath)
Create an
ChronicleQueuePersistor based on the given base path. |
ChronicleQueuePersistor(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(Long id)
Return the item with the given id.
|
boolean |
hasNext()
Are there more items waiting to be returned?
|
Iterator<T> |
iterator() |
long |
lastId()
Get the value of the last item to have been persisted.
|
Long |
offer(T t)
Persist and return the last Long id of the item.
|
Long |
offerAll(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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public ChronicleQueuePersistor(@Nonnull String basePath) throws IOException
ChronicleQueuePersistor
based on the given base path.basePath
- Directory in which to create the Chronicle.IOException
public ChronicleQueuePersistor(@Nonnull String basePath, @Nonnull Codec<Buffer,T,T> codec, boolean clearOnStart, boolean deleteOnExit, @Nonnull net.openhft.chronicle.ChronicleQueueBuilder config) throws 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.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 Long offer(@Nonnull T t)
QueuePersistor
offer
in interface QueuePersistor<T>
t
- element to persistpublic Long offerAll(@Nonnull Collection<T> t)
QueuePersistor
offerAll
in interface QueuePersistor<T>
t
- element to persistpublic T get(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>
Copyright © 2017. All rights reserved.