Package com.github.ddth.queue.impl
Class AbstractInmemEphemeralQueue<ID,DATA>
- java.lang.Object
-
- com.github.ddth.queue.impl.AbstractQueue<ID,DATA>
-
- com.github.ddth.queue.impl.AbstractEphemeralSupportQueue<ID,DATA>
-
- com.github.ddth.queue.impl.AbstractInmemEphemeralQueue<ID,DATA>
-
- All Implemented Interfaces:
IQueue<ID,DATA>,AutoCloseable
- Direct Known Subclasses:
DisruptorQueue,InmemQueue
public abstract class AbstractInmemEphemeralQueue<ID,DATA> extends AbstractEphemeralSupportQueue<ID,DATA>
Abstract queue implementation that uses in-memory ephemeral storage.- Since:
- 1.0.0
- Author:
- Thanh Nguyen
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.github.ddth.queue.impl.AbstractQueue
AbstractQueue.PutToQueueCase
-
-
Field Summary
-
Fields inherited from interface com.github.ddth.queue.IQueue
SIZE_NOT_SUPPORTED
-
-
Constructor Summary
Constructors Constructor Description AbstractInmemEphemeralQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoPutToEphemeralStorage(IQueueMessage<ID,DATA> msg)protected voiddoRemoveFromEphemeralStorage(IQueueMessage<ID,DATA> msg)protected voidensureEphemeralSize()intephemeralSize()Get number of items currently in ephemeral storage.Collection<IQueueMessage<ID,DATA>>getOrphanMessages(long thresholdTimestampMs)Get all orphan messages (messages that were left in ephemeral storage for a long time).protected voidinitEphemeralStorage(int hintSize)AbstractInmemEphemeralQueue<ID,DATA>setEphemeralDisabled(boolean ephemeralDisabled)Disable/Enable ephemeral storage.-
Methods inherited from class com.github.ddth.queue.impl.AbstractEphemeralSupportQueue
getEphemeralDisabled, getEphemeralMaxSize, isEphemeralDisabled, setEphemeralMaxSize
-
Methods inherited from class com.github.ddth.queue.impl.AbstractQueue
close, createMessage, createMessage, createMessage, deserialize, deserialize, destroy, doPutToQueue, getMessageFactory, getQueueName, getSerDeser, init, queue, requeue, requeueSilent, serialize, setMessageFactory, setQueueName, setSerDeser
-
-
-
-
Method Detail
-
setEphemeralDisabled
public AbstractInmemEphemeralQueue<ID,DATA> setEphemeralDisabled(boolean ephemeralDisabled)
Description copied from class:AbstractEphemeralSupportQueueDisable/Enable ephemeral storage.- Overrides:
setEphemeralDisabledin classAbstractEphemeralSupportQueue<ID,DATA>- Parameters:
ephemeralDisabled-trueto disable ephemeral storage,falseotherwise.- Returns:
-
initEphemeralStorage
protected void initEphemeralStorage(int hintSize)
-
doRemoveFromEphemeralStorage
protected void doRemoveFromEphemeralStorage(IQueueMessage<ID,DATA> msg)
-
ensureEphemeralSize
protected void ensureEphemeralSize()
-
doPutToEphemeralStorage
protected void doPutToEphemeralStorage(IQueueMessage<ID,DATA> msg)
-
getOrphanMessages
public Collection<IQueueMessage<ID,DATA>> getOrphanMessages(long thresholdTimestampMs)
Get all orphan messages (messages that were left in ephemeral storage for a long time).- Parameters:
thresholdTimestampMs- message is orphan ifmessage's timestampMillis + thresholdTimestampMs < now. Which meansgetOrphanMessages(10000)will return orphan messages that have stayed in ephemeral storage for more than 10000 milliseconds.- Returns:
nullor empty collection if there is no orphan message
-
ephemeralSize
public int ephemeralSize()
Get number of items currently in ephemeral storage.Note: ephemeral storage implementation is optional, depends on implementation.
- Returns:
- negative number if ephemeral size can not be queried
-
-