Class OnHeapRingBufferMessageStore
- All Implemented Interfaces:
MessageStore,AutoCloseable
Each time an element is added to a full message store, the message store automatically removes its head element.
Features:
- Thread-Safe
- Support for maximum capacity.
- No support for compaction.
- No support for indexing of messages.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with default capacity of 100.OnHeapRingBufferMessageStore(int capacity) Creates a new instance with specified capacity. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(MessageStoreEntry entry) Appends the specified element to the end of this list (optional operation).Returns a set containing the channel names of the messages contained in theMessageStorecom.google.common.collect.ImmutableSet<Index>getLatestChannelPosition(String channelName) Returns the latestChannelPositionof the given channel, derived from the messages contained in thisMessageStore.longsize()Returns the number of messages contained in the MessageStore.stream()Returns a Stream of all entries contained in the MessageStore.Returns a Stream of all entries contained in the MessageStore that have are matching the given Index value (optional operation).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.otto.synapse.messagestore.MessageStore
close, getLatestChannelPosition, isCompacting
-
Constructor Details
-
OnHeapRingBufferMessageStore
public OnHeapRingBufferMessageStore()Creates a new instance with default capacity of 100. -
OnHeapRingBufferMessageStore
public OnHeapRingBufferMessageStore(int capacity) Creates a new instance with specified capacity.- Parameters:
capacity- the size of the underlying ring buffer.
-
-
Method Details
-
add
Description copied from interface:MessageStoreAppends the specified element to the end of this list (optional operation).MessageStores that support this operation may place limitations on what elements may be added to this list. In particular, some stores will refuse to add entries for more than a single
channel. MessageStore classes should clearly specify in their documentation any restrictions on what elements may be added.- Specified by:
addin interfaceMessageStore- Parameters:
entry- element to be appended to this message store
-
getChannelNames
Description copied from interface:MessageStoreReturns a set containing the channel names of the messages contained in theMessageStore- Specified by:
getChannelNamesin interfaceMessageStore- Returns:
- set of channel names
-
getIndexes
- Specified by:
getIndexesin interfaceMessageStore
-
getLatestChannelPosition
Description copied from interface:MessageStoreReturns the latestChannelPositionof the given channel, derived from the messages contained in thisMessageStore.The position is calculated by
mergingtheoptional positionsof the messages.Messages without positions will not change the latest ChannelPosition. If no message contains position information, the returned ChannelPosition is
ChannelPosition.fromHorizon()- Specified by:
getLatestChannelPositionin interfaceMessageStore- Parameters:
channelName- the name of the channel- Returns:
- ChannelPosition
-
stream
Description copied from interface:MessageStoreReturns a Stream of all entries contained in the MessageStore.The stream will maintain the insertion order of the entries.
- Specified by:
streamin interfaceMessageStore- Returns:
- Stream of entries
-
stream
Description copied from interface:MessageStoreReturns a Stream of all entries contained in the MessageStore that have are matching the given Index value (optional operation).The stream will maintain the insertion order of the entries.
- Specified by:
streamin interfaceMessageStore- Parameters:
index- the Indexvalue- the value identifying the requested messages in the specified index- Returns:
- stream of message-store entries matching the index or emptyStream, if the index is not known, or if there are no entries
-
size
public long size()Description copied from interface:MessageStoreReturns the number of messages contained in the MessageStore.Primarily used for testing purposes. If the MessageStore can not implement this without major performance impacts (like, for example, having to download and parse huge files from S3), the method is not required to be implemented.
- Specified by:
sizein interfaceMessageStore- Returns:
- number of messages
-