public class DisruptorQueue extends Object implements IQueue, Closeable, AutoCloseable
IQueue using LMAX Disruptor library.
Implementation:
RingBuffer to be the queue storage.ConcurrentMap as ephemeral storage.https://lmax-exchange.github.io/disruptor/| Constructor and Description |
|---|
DisruptorQueue() |
DisruptorQueue(int ringSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
destroy()
Destroy method.
|
int |
ephemeralSize()
Gets ephemeral-storage's number of items.
|
void |
finish(IQueueMessage msg)
Called when finish processing the message to cleanup ephemeral storage.
|
boolean |
getEphemeralDisabled()
Is ephemeral storage disabled?
|
Collection<IQueueMessage> |
getOrphanMessages(long thresholdTimestampMs)
Gets all orphan messages (messages that were left in ephemeral storage
for a long time).
|
protected int |
getRingSize()
Gets size of the ring buffer.
|
DisruptorQueue |
init()
Init method.
|
boolean |
isEphemeralDisabled()
Is ephemeral storage disabled?
|
boolean |
moveFromEphemeralToQueueStorage(IQueueMessage _msg)
Moves a message from ephemeral back to queue storage.
|
protected void |
publish(IQueueMessage value,
long seq)
Publishes (commits) the ring's sequence.
|
protected boolean |
putToRingBuffer(IQueueMessage msg)
Puts a message to the ring buffer.
|
boolean |
queue(IQueueMessage _msg)
Queues a message.
|
int |
queueSize()
Gets queue's number of items.
|
boolean |
requeue(IQueueMessage _msg)
Re-queues a message.
|
boolean |
requeueSilent(IQueueMessage msg)
Silently re-queues a message.
|
DisruptorQueue |
setEphemeralDisabled(boolean ephemeralDisabled)
Disables/Enables ephemeral storage.
|
DisruptorQueue |
setRingSize(int ringSize)
Sets size of the ring buffer, must be power of 2.
|
IQueueMessage |
take()
Takes a message out of queue.
|
protected IQueueMessage |
takeFromRingBuffer()
Takes a message from the ring buffer.
|
protected void |
updatePublishedSequence()
Updates the published sequence number after a message has been
successfully taken from queue.
|
public DisruptorQueue()
public DisruptorQueue(int ringSize)
public boolean getEphemeralDisabled()
public boolean isEphemeralDisabled()
public DisruptorQueue setEphemeralDisabled(boolean ephemeralDisabled)
ephemeralDisabled - true to disable ephemeral storage, false
otherwise.protected int getRingSize()
public DisruptorQueue setRingSize(int ringSize)
ringSize - public DisruptorQueue init()
public void destroy()
public void close()
close in interface Closeableclose in interface AutoCloseableprotected void publish(IQueueMessage value, long seq)
value - seq - protected boolean putToRingBuffer(IQueueMessage msg)
msg - true if successful, false otherwise (the ring
buffer is fullpublic boolean queue(IQueueMessage _msg)
Implementation flow:
public boolean requeue(IQueueMessage _msg)
Implementation flow:
Note: ephemeral storage implementation is optional, depends on implementation.
public boolean requeueSilent(IQueueMessage msg)
Implementation flow:
Note: ephemeral storage implementation is optional, depends on implementation.
requeueSilent in interface IQueuepublic void finish(IQueueMessage msg)
Implementation flow:
Note: ephemeral storage implementation is optional, depends on implementation.
protected void updatePublishedSequence()
protected IQueueMessage takeFromRingBuffer()
null if the ring buffer is emptypublic IQueueMessage take()
Implementation flow:
Note: ephemeral storage implementation is optional, depends on implementation.
public Collection<IQueueMessage> getOrphanMessages(long thresholdTimestampMs)
getOrphanMessages in interface IQueuethresholdTimestampMs - public boolean moveFromEphemeralToQueueStorage(IQueueMessage _msg)
Implementation flow:
moveFromEphemeralToQueueStorage in interface IQueuetrue if a move has been made, false otherwise
(e.g. the message didn't exist in ephemeral storage)public int queueSize()
public int ephemeralSize()
Note: ephemeral storage implementation is optional, depends on implementation.
ephemeralSize in interface IQueueCopyright © 2016 DDTH. All rights reserved.