public class RingbufferCacheEventJournalImpl extends Object implements CacheEventJournal
Ringbuffer
.
It will add all journal events into a RingbufferContainer
with the provided namespace
and partition ID and allows checking if the cache has a configured event journal.
Adapts the EventJournalConfig
to the RingbufferConfig
when creating the ringbuffer.Constructor and Description |
---|
RingbufferCacheEventJournalImpl(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) |
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<InternalEventJournalCacheEvent,T> resultSet)
Reads events from the journal in batches.
|
protected Data |
toData(Object val) |
RingbufferConfig |
toRingbufferConfig(EventJournalConfig config) |
void |
writeCreatedEvent(ObjectNamespace namespace,
int partitionId,
Data key,
Object value)
Writes an
CacheEventType.CREATED to the event journal. |
void |
writeEvictEvent(ObjectNamespace namespace,
int partitionId,
Data key,
Object value)
Writes an
CacheEventType.EVICTED to the event journal. |
void |
writeExpiredEvent(ObjectNamespace namespace,
int partitionId,
Data key,
Object value)
Writes an
CacheEventType.EXPIRED to the event journal. |
void |
writeRemoveEvent(ObjectNamespace namespace,
int partitionId,
Data key,
Object value)
Writes an
CacheEventType.REMOVED to the event journal. |
void |
writeUpdateEvent(ObjectNamespace namespace,
int partitionId,
Data key,
Object oldValue,
Object newValue)
Writes an
CacheEventType.UPDATED to the event journal. |
public RingbufferCacheEventJournalImpl(NodeEngine engine)
public void writeUpdateEvent(ObjectNamespace namespace, int partitionId, Data key, Object oldValue, Object newValue)
CacheEventJournal
CacheEventType.UPDATED
to the event journal.
If there is no event journal configured for this cache, 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 CacheEventJournal
namespace
- the cache namespace, containing the full prefixed cache namepartitionId
- the entry key partitionkey
- the entry keyoldValue
- the old valuenewValue
- the new valuepublic void writeCreatedEvent(ObjectNamespace namespace, int partitionId, Data key, Object value)
CacheEventJournal
CacheEventType.CREATED
to the event journal.
If there is no event journal configured for this cache, 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.writeCreatedEvent
in interface CacheEventJournal
namespace
- the cache namespace, containing the full prefixed cache namepartitionId
- the entry key partitionkey
- the entry keyvalue
- the entry valuepublic void writeRemoveEvent(ObjectNamespace namespace, int partitionId, Data key, Object value)
CacheEventJournal
CacheEventType.REMOVED
to the event journal.
If there is no event journal configured for this cache, 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 CacheEventJournal
namespace
- the cache namespace, containing the full prefixed cache namepartitionId
- the entry key partitionkey
- the entry keyvalue
- the entry valuepublic void writeEvictEvent(ObjectNamespace namespace, int partitionId, Data key, Object value)
CacheEventJournal
CacheEventType.EVICTED
to the event journal.
If there is no event journal configured for this cache, 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 CacheEventJournal
namespace
- the cache namespace, containing the full prefixed cache namepartitionId
- the entry key partitionkey
- the entry keyvalue
- the entry valuepublic void writeExpiredEvent(ObjectNamespace namespace, int partitionId, Data key, Object value)
CacheEventJournal
CacheEventType.EXPIRED
to the event journal.
If there is no event journal configured for this cache, 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.writeExpiredEvent
in interface CacheEventJournal
namespace
- the cache namespace, containing the full prefixed cache namepartitionId
- the entry key partitionkey
- the entry keyvalue
- the entry valuepublic long newestSequence(ObjectNamespace namespace, int partitionId)
EventJournal
newestSequence
in interface EventJournal<InternalEventJournalCacheEvent>
namespace
- the object namespacepartitionId
- the partition ID of the event journalpublic long oldestSequence(ObjectNamespace namespace, int partitionId)
EventJournal
oldestSequence
in interface EventJournal<InternalEventJournalCacheEvent>
namespace
- the object namespacepartitionId
- the partition ID of the event journalpublic void destroy(ObjectNamespace namespace, int partitionId)
EventJournal
destroy
in interface EventJournal<InternalEventJournalCacheEvent>
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<InternalEventJournalCacheEvent>
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<InternalEventJournalCacheEvent>
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<InternalEventJournalCacheEvent>
namespace
- the object namespacepartitionId
- the partition ID of the entries in the journalpublic <T> long readMany(ObjectNamespace namespace, int partitionId, long beginSequence, ReadResultSetImpl<InternalEventJournalCacheEvent,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<InternalEventJournalCacheEvent>
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<InternalEventJournalCacheEvent>
namespace
- the object namespacepartitionId
- the partition ID of the entries in the journalpublic boolean hasEventJournal(ObjectNamespace namespace)
true
if the object has a configured and enabled event journal.
NOTE: The cache config should have already been created in the cache service before
invoking this method.hasEventJournal
in interface EventJournal<InternalEventJournalCacheEvent>
namespace
- the cache namespace, containing the full prefixed cache nametrue
if the object has a configured and enabled event journal, false
otherwisepublic EventJournalConfig getEventJournalConfig(ObjectNamespace namespace)
getEventJournalConfig
in interface EventJournal<InternalEventJournalCacheEvent>
public RingbufferConfig toRingbufferConfig(EventJournalConfig config)
toRingbufferConfig
in interface EventJournal<InternalEventJournalCacheEvent>
Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.