public class IndexedChronicleQueuePersistor<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 |
|---|
IndexedChronicleQueuePersistor(java.lang.String basePath)
Create an
IndexedChronicleQueuePersistor based on the given base path. |
IndexedChronicleQueuePersistor(java.lang.String basePath,
Codec<Buffer,T,T> codec,
boolean clearOnStart,
boolean deleteOnExit,
net.openhft.chronicle.ChronicleConfig config)
Create an
IndexedChronicleQueuePersistor based on the given base path, encoder and decoder. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the underlying chronicles.
|
Function<java.lang.Long,T> |
get()
Returns a
Function that will 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.
|
Function<T,java.lang.Long> |
offer()
Returns a
Function that will persist the item and return a Long id for the item. |
Supplier<T> |
remove()
Returns a
Supplier that will simply remove the oldest item from the persistence queue. |
long |
size()
Get the number of items persisted right now.
|
public IndexedChronicleQueuePersistor(@Nonnull
java.lang.String basePath)
throws java.io.IOException
IndexedChronicleQueuePersistor based on the given base path.basePath - Directory in which to create the Chronicle.java.io.IOExceptionpublic IndexedChronicleQueuePersistor(@Nonnull
java.lang.String basePath,
@Nonnull
Codec<Buffer,T,T> codec,
boolean clearOnStart,
boolean deleteOnExit,
@Nonnull
net.openhft.chronicle.ChronicleConfig config)
throws java.io.IOException
IndexedChronicleQueuePersistor 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.IOExceptionpublic void close()
close in interface QueuePersistor<T>public long lastId()
QueuePersistorlastId in interface QueuePersistor<T>public long size()
QueuePersistorsize in interface QueuePersistor<T>public boolean hasNext()
QueuePersistorhasNext in interface QueuePersistor<T>true if items can be retrieved from this persistor, false otherwise@Nonnull public Function<T,java.lang.Long> offer()
QueuePersistorFunction that will persist the item and return a Long id for the item.offer in interface QueuePersistor<T>@Nonnull public Function<java.lang.Long,T> get()
QueuePersistorFunction that will return the item with the given id.get in interface QueuePersistor<T>@Nonnull public Supplier<T> remove()
QueuePersistorSupplier that will simply remove the oldest item from the persistence queue.remove in interface QueuePersistor<T>