public class RingbufferMapEventJournalImpl extends Object implements MapEventJournal
Ringbuffer
.
It will add all journal events into a RingbufferContainer
with the provided namespace
and partition ID and allows checking if the map has a configured event journal.
Adapts the EventJournalConfig
to the RingbufferConfig
when creating the ringbuffer.Constructor and Description |
---|
RingbufferMapEventJournalImpl(NodeEngine engine) |
Modifier and Type | Method and Description |
---|---|
void |
cleanup(ObjectNamespace namespace,
int partitionId)
Cleans up the event journal by removing any expired items.
|
void |
destroy(ObjectNamespace namespace,
int partitionId)
Destroys the event journal for the given object and partition ID.
|
EventJournalConfig |
getEventJournalConfig(ObjectNamespace namespace)
Returns the event journal configuration or
null if there is none or the journal is disabled
for the given namespace . |
WaitNotifyKey |
getWaitNotifyKey(ObjectNamespace namespace,
int partitionId)
Return the
WaitNotifyKey for objects waiting and notifying on the event journal. |
boolean |
hasEventJournal(ObjectNamespace namespace)
Returns
true if the object has a configured and enabled event journal. |
void |
isAvailableOrNextSequence(ObjectNamespace namespace,
int partitionId,
long sequence)
Checks if the sequence is of an item that can be read immediately
or is the sequence of the next item to be added into the event journal.
|
boolean |
isNextAvailableSequence(ObjectNamespace namespace,
int partitionId,
long sequence)
Checks if the
sequence is the sequence of the next event to
be added to the event journal. |
long |
newestSequence(ObjectNamespace namespace,
int partitionId)
Returns the sequence of the newest event stored in the event journal.
|
long |
oldestSequence(ObjectNamespace namespace,
int partitionId)
Returns the sequence of the oldest event stored in the event journal.
|
<T> long |
readMany(ObjectNamespace namespace,
int partitionId,
long beginSequence,
ReadResultSetImpl<InternalEventJournalMapEvent,T> resultSet)
Reads events from the journal in batches.
|
RingbufferConfig |
toRingbufferConfig(EventJournalConfig config)
Creates a new
RingbufferConfig for a ringbuffer that will keep
event journal events for a single partition. |
void |
writeAddEvent(EventJournalConfig journalConfig,
ObjectNamespace namespace,
int partitionId,
Data key,
Object value)
Writes an
EntryEventType.ADDED to the event journal. |
void |
writeEvictEvent(EventJournalConfig journalConfig,
ObjectNamespace namespace,
int partitionId,
Data key,
Object value)
Writes an
EntryEventType.EVICTED to the event journal. |
void |
writeRemoveEvent(EventJournalConfig journalConfig,
ObjectNamespace namespace,
int partitionId,
Data key,
Object value)
Writes an
EntryEventType.REMOVED to the event journal. |
void |
writeUpdateEvent(EventJournalConfig journalConfig,
ObjectNamespace namespace,
int partitionId,
Data key,
Object oldValue,
Object newValue)
Writes an
EntryEventType.UPDATED to the event journal. |
public RingbufferMapEventJournalImpl(NodeEngine engine)
public void writeUpdateEvent(EventJournalConfig journalConfig, ObjectNamespace namespace, int partitionId, Data key, Object oldValue, Object newValue)
MapEventJournal
EntryEventType.UPDATED
to the event journal.
If there is no event journal configured for this map, the method will do nothing.
If an event is added to the event journal, all parked operations waiting for
new events on that journal will be unparked.writeUpdateEvent
in interface MapEventJournal
journalConfig
- the event journal config for the map in which the event occurrednamespace
- the map namespacepartitionId
- the entry key partitionkey
- the entry keyoldValue
- the old valuenewValue
- the new valuepublic void writeAddEvent(EventJournalConfig journalConfig, ObjectNamespace namespace, int partitionId, Data key, Object value)
MapEventJournal
EntryEventType.ADDED
to the event journal.
If there is no event journal configured for this map, the method will do nothing.
If an event is added to the event journal, all parked operations waiting for
new events on that journal will be unparked.writeAddEvent
in interface MapEventJournal
journalConfig
- the event journal config for the map in which the event occurrednamespace
- the map namespacepartitionId
- the entry key partitionkey
- the entry keyvalue
- the entry valuepublic void writeRemoveEvent(EventJournalConfig journalConfig, ObjectNamespace namespace, int partitionId, Data key, Object value)
MapEventJournal
EntryEventType.REMOVED
to the event journal.
If there is no event journal configured for this map, the method will do nothing.
If an event is added to the event journal, all parked operations waiting for
new events on that journal will be unparked.writeRemoveEvent
in interface MapEventJournal
journalConfig
- the event journal config for the map in which the event occurrednamespace
- the map namespacepartitionId
- the entry key partitionkey
- the entry keyvalue
- the entry valuepublic void writeEvictEvent(EventJournalConfig journalConfig, ObjectNamespace namespace, int partitionId, Data key, Object value)
MapEventJournal
EntryEventType.EVICTED
to the event journal.
If there is no event journal configured for this map, the method will do nothing.
If an event is added to the event journal, all parked operations waiting for
new events on that journal will be unparked.writeEvictEvent
in interface MapEventJournal
journalConfig
- the event journal config for the map in which the event occurrednamespace
- the map namespacepartitionId
- the entry key partitionkey
- the entry keyvalue
- the entry valuepublic long newestSequence(ObjectNamespace namespace, int partitionId)
EventJournal
newestSequence
in interface EventJournal<InternalEventJournalMapEvent>
namespace
- the object namespacepartitionId
- the partition ID of the event journalpublic long oldestSequence(ObjectNamespace namespace, int partitionId)
EventJournal
oldestSequence
in interface EventJournal<InternalEventJournalMapEvent>
namespace
- the object namespacepartitionId
- the partition ID of the event journalpublic void destroy(ObjectNamespace namespace, int partitionId)
EventJournal
destroy
in interface EventJournal<InternalEventJournalMapEvent>
namespace
- the object namespacepartitionId
- the partition ID of the entries in the journalpublic void isAvailableOrNextSequence(ObjectNamespace namespace, int partitionId, long sequence)
EventJournal
EventJournal.newestSequence(ObjectNamespace, int)
, the caller can use this method
to check the sequence before performing a possibly blocking read.isAvailableOrNextSequence
in interface EventJournal<InternalEventJournalMapEvent>
namespace
- the object namespacepartitionId
- the partition ID of the entries in the journalsequence
- the sequence wanting to be readpublic boolean isNextAvailableSequence(ObjectNamespace namespace, int partitionId, long sequence)
EventJournal
sequence
is the sequence of the next event to
be added to the event journal.isNextAvailableSequence
in interface EventJournal<InternalEventJournalMapEvent>
namespace
- the object namespacepartitionId
- the partition ID of the entries in the journalsequence
- the sequence to be checkedtrue
if the sequence
is one greater
than the sequence of the last event, false
otherwisepublic WaitNotifyKey getWaitNotifyKey(ObjectNamespace namespace, int partitionId)
EventJournal
WaitNotifyKey
for objects waiting and notifying on the event journal.getWaitNotifyKey
in interface EventJournal<InternalEventJournalMapEvent>
namespace
- the object namespacepartitionId
- the partition ID of the entries in the journalpublic <T> long readMany(ObjectNamespace namespace, int partitionId, long beginSequence, ReadResultSetImpl<InternalEventJournalMapEvent,T> resultSet)
EventJournal
ReadResultSetImpl.isMaxSizeReached()
or until the journal is exhausted. The resultSet
allows
filtering and projections on journal items so that the caller
can control which data is returned.
If the set has reached it's max size, the returned sequence one greater than the sequence of the last item in the set. In other cases it means that the set hasn't reached it's full size because we have reached the end of the event journal. In this case the returned sequence is one greater than the sequence of the last stored event.
readMany
in interface EventJournal<InternalEventJournalMapEvent>
T
- the return type of the projected eventsnamespace
- the object namespacepartitionId
- the partition ID of the entries in the journalbeginSequence
- the sequence of the first item to read.resultSet
- the container for read, filtered and projected eventsEventJournal.isAvailableOrNextSequence(ObjectNamespace, int, long)
public void cleanup(ObjectNamespace namespace, int partitionId)
EventJournal
cleanup
in interface EventJournal<InternalEventJournalMapEvent>
namespace
- the object namespacepartitionId
- the partition ID of the entries in the journalpublic boolean hasEventJournal(ObjectNamespace namespace)
MapEventJournal
true
if the object has a configured and enabled event journal.hasEventJournal
in interface EventJournal<InternalEventJournalMapEvent>
hasEventJournal
in interface MapEventJournal
namespace
- the object namespacetrue
if the object has a configured and enabled event journal, false
otherwisepublic EventJournalConfig getEventJournalConfig(ObjectNamespace namespace)
EventJournal
null
if there is none or the journal is disabled
for the given namespace
.
NOTE
If the Cluster.getClusterVersion()
is less
than Versions.V3_9
,
this method will return null
, regardless of whether
the journal is actually enabled by the configuration. This
is because some members might not know how to save journal
events and respond to subscribe/read operations.
getEventJournalConfig
in interface EventJournal<InternalEventJournalMapEvent>
namespace
- the object namespace of the specific distributed objectnull
if the journal is not enabled or availablepublic RingbufferConfig toRingbufferConfig(EventJournalConfig config)
EventJournal
RingbufferConfig
for a ringbuffer that will keep
event journal events for a single partition.toRingbufferConfig
in interface EventJournal<InternalEventJournalMapEvent>
config
- the event journal configCopyright © 2018 Hazelcast, Inc.. All Rights Reserved.