public class MapEventPublisherImpl extends Object implements MapEventPublisher
Modifier and Type | Field and Description |
---|---|
protected EventService |
eventService |
protected FilteringStrategy |
filteringStrategy |
static HazelcastProperty |
LISTENER_WITH_PREDICATE_PRODUCES_NATURAL_EVENT_TYPES
When
true , enables processing of entry events for listeners with predicates to fit with "query cache" concept:
for example when the original event indicates an update from an old value that does not match the predicate to a new value
that does match, then the entry listener will be notified with an ADDED event. |
protected MapServiceContext |
mapServiceContext |
protected NodeEngine |
nodeEngine |
protected IPartitionService |
partitionService |
protected QueryCacheEventPublisher |
queryCacheEventPublisher |
protected SerializationService |
serializationService |
Constructor and Description |
---|
MapEventPublisherImpl(MapServiceContext mapServiceContext) |
Modifier and Type | Method and Description |
---|---|
void |
addEventToQueryCache(Object eventData)
Notifies
QueryCache subscribers directly, without publishing an event to
other map listeners. |
protected Collection<EventRegistration> |
getRegistrations(String mapName)
Return all listener registrations for the map with
mapName . |
boolean |
hasEventListener(String mapName)
Returns
true if there is at least one listener registered for the specified mapName . |
void |
hintMapEvent(Address caller,
String mapName,
EntryEventType eventType,
int numberOfEntriesAffected,
int partitionId)
Only gives a hint which indicates that a map-wide operation has just been executed on this partition.
|
protected void |
postPublishEvent(Collection<EntryEventData> eventDataIncludingValues,
Collection<EntryEventData> eventDataExcludingValues)
Hook for actions to perform after any of
publishEvent(com.hazelcast.nio.Address, java.lang.String, com.hazelcast.core.EntryEventType, com.hazelcast.nio.serialization.Data, java.lang.Object, java.lang.Object) methods is executed and if there
were any registrations for the event. |
void |
publishEvent(Address caller,
String mapName,
EntryEventType eventType,
Data dataKey,
Object dataOldValue,
Object dataValue)
Publish an event to the event subsystem.
|
void |
publishEvent(Address caller,
String mapName,
EntryEventType eventType,
Data dataKey,
Object oldValue,
Object value,
Object mergingValue)
Publish an event to the event subsystem.
|
protected void |
publishEventInternal(Collection<EventRegistration> registrations,
Object eventData,
int orderKey) |
void |
publishLoadedOrAdded(Address caller,
String mapName,
Data dataKey,
Object dataOldValue,
Object dataValue)
This method tries to publish events after a load happened in a backward
compatible manner by choosing one of the two ways below:
- As ADD events if listener implements only
EntryAddedListener but not EntryLoadedListener , this is for the
backward compatibility. |
void |
publishMapEvent(Address caller,
String mapName,
EntryEventType eventType,
int numberOfEntriesAffected) |
void |
publishMapPartitionLostEvent(Address caller,
String mapName,
int partitionId) |
protected void |
publishWanEvent(String mapName,
ReplicationEventObject event)
Publishes the
event to the WanReplicationPublisher configured for this map. |
void |
publishWanRemove(String mapName,
Data key)
Notifies the WAN subsystem of a map entry removal on a replica owner.
|
void |
publishWanUpdate(String mapName,
EntryView<Data,Data> entryView,
boolean hasLoadProvenance)
Notifies the WAN subsystem of a map update on a replica owner.
|
public static final HazelcastProperty LISTENER_WITH_PREDICATE_PRODUCES_NATURAL_EVENT_TYPES
true
, enables processing of entry events for listeners with predicates to fit with "query cache" concept:
for example when the original event indicates an update from an old value that does not match the predicate to a new value
that does match, then the entry listener will be notified with an ADDED event.
This affects only map listeners with predicates and the way entry updates are handled. Put/remove operations are not
affected, neither are listeners without predicates.
Default value is false
, to maintain compatible behavior with previous Hazelcast versions.protected final NodeEngine nodeEngine
protected final EventService eventService
protected final IPartitionService partitionService
protected final MapServiceContext mapServiceContext
protected final FilteringStrategy filteringStrategy
protected final SerializationService serializationService
protected final QueryCacheEventPublisher queryCacheEventPublisher
public MapEventPublisherImpl(MapServiceContext mapServiceContext)
public void publishWanUpdate(String mapName, EntryView<Data,Data> entryView, boolean hasLoadProvenance)
MapEventPublisher
publishWanUpdate
in interface MapEventPublisher
mapName
- the map nameentryView
- the updated entryhasLoadProvenance
- true
to indicate the provenance of
update is a load from map-loader, otherwise
set false
public void publishWanRemove(String mapName, Data key)
MapEventPublisher
publishWanRemove
in interface MapEventPublisher
mapName
- the map namekey
- the key of the removed entryprotected void publishWanEvent(String mapName, ReplicationEventObject event)
event
to the WanReplicationPublisher
configured for this map.mapName
- the map nameevent
- the eventpublic void publishMapEvent(Address caller, String mapName, EntryEventType eventType, int numberOfEntriesAffected)
publishMapEvent
in interface MapEventPublisher
public void publishEvent(Address caller, String mapName, EntryEventType eventType, Data dataKey, Object dataOldValue, Object dataValue)
MapEventPublisher
publishEvent
in interface MapEventPublisher
caller
- the address of the caller that caused the eventmapName
- the map nameeventType
- the event typedataKey
- the key of the event map entrydataOldValue
- the old value of the map entrydataValue
- the new value of the map entrypublic void publishEvent(Address caller, String mapName, EntryEventType eventType, Data dataKey, Object oldValue, Object value, Object mergingValue)
MapEventPublisher
publishEvent
in interface MapEventPublisher
caller
- the address of the caller that caused the eventmapName
- the map nameeventType
- the event typedataKey
- the key of the event map entryoldValue
- the old value of the map entryvalue
- the new value of the map entrymergingValue
- the value used when performing a merge operation in case of a EntryEventType.MERGED
event.
This value together with the old value produced the new value.public void publishLoadedOrAdded(Address caller, String mapName, Data dataKey, Object dataOldValue, Object dataValue)
MapEventPublisher
EntryAddedListener
but not EntryLoadedListener
, this is for the
backward compatibility. Old listener implementation will continue
to receive ADD events after loads happened.
- As LOAD events if listener implements EntryLoadedListener
publishLoadedOrAdded
in interface MapEventPublisher
caller
- the address of the caller that caused the eventmapName
- the map namedataKey
- the key of the event map entrydataOldValue
- the old value of the map entrydataValue
- the new value of the map entryprotected void postPublishEvent(Collection<EntryEventData> eventDataIncludingValues, Collection<EntryEventData> eventDataExcludingValues)
publishEvent(com.hazelcast.nio.Address, java.lang.String, com.hazelcast.core.EntryEventType, com.hazelcast.nio.serialization.Data, java.lang.Object, java.lang.Object)
methods is executed and if there
were any registrations for the event.
This method will be invoked once per unique EntryEventData
generated by publishEvent
,
regardless of the number of registrations on which the event is published.eventDataIncludingValues
- the event data including all of the entry values (old, new, merging)eventDataExcludingValues
- the event data without entry valuespublic void publishMapPartitionLostEvent(Address caller, String mapName, int partitionId)
publishMapPartitionLostEvent
in interface MapEventPublisher
public void hintMapEvent(Address caller, String mapName, EntryEventType eventType, int numberOfEntriesAffected, int partitionId)
MapEventPublisher
hintMapEvent
in interface MapEventPublisher
public void addEventToQueryCache(Object eventData)
MapEventPublisher
QueryCache
subscribers directly, without publishing an event to
other map listeners. This is necessary in certain cases, such as when loading entries into a map.addEventToQueryCache
in interface MapEventPublisher
eventData
- the event to publish to query cachespublic boolean hasEventListener(String mapName)
MapEventPublisher
true
if there is at least one listener registered for the specified mapName
.hasEventListener
in interface MapEventPublisher
protected Collection<EventRegistration> getRegistrations(String mapName)
mapName
.mapName
- the map nameprotected void publishEventInternal(Collection<EventRegistration> registrations, Object eventData, int orderKey)
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.