Package com.tangosol.net.cache
Class CacheEvent<K,V>
java.lang.Object
java.util.EventObject
com.tangosol.util.MapEvent<K,V>
com.tangosol.net.cache.CacheEvent<K,V>
- All Implemented Interfaces:
PortableObject
,Serializable
- Direct Known Subclasses:
AbstractKeyBasedMap.DeferredCacheEvent
,ConverterCollections.ConverterMapEvent
,MapListenerSupport.FilterEvent
,OverflowMap.HistoricCacheEvent
An extension of the MapEvent which allows to differentiate between client
driven (natural) events and cache internal (synthetic) events.
Consider a client code calling a remove() method for a cache. Quite naturally it causes a corresponding ENTRY_DELETED event. However, the same event could be as well caused by the client code calling put() forcing an entry eviction. Alternatively, the put() method called by a client code naturally causes either ENTRY_INSERTED or ENTRY_UPDATED event. However, the same event could be as well caused by a client call to a get() method that in turn forces an entry insertion by a cache loader.
- Since:
- Coherence 2.3
- Author:
- gg 2003.09.12
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
TransformationState describes how a CacheEvent has been or should betransformed
. -
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
Flag indicating whether the deletion event is a result of time expiration.protected int
Flags holder for event details such as whether the event is syntheticprotected CacheEvent.TransformationState
The transformation state for this event.protected static final int
Flag indicating whether or not the event is a priming event (NearCache).protected static final int
Flag indicating whether or not the event is synthetic.Fields inherited from class com.tangosol.util.MapEvent
ENTRY_DELETED, ENTRY_INSERTED, ENTRY_UPDATED, m_key, m_nId, m_nPartition, m_nVersion, m_valueNew, m_valueOld
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionCacheEvent
(ObservableMap<K, V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic) Constructs a new CacheEvent.CacheEvent
(ObservableMap<K, V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic, boolean fPriming) Constructs a new CacheEvent.CacheEvent
(ObservableMap<K, V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic, CacheEvent.TransformationState transformState) Constructs a new CacheEvent.CacheEvent
(ObservableMap<K, V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic, CacheEvent.TransformationState transformState, boolean fPriming) Constructs a new CacheEvent.CacheEvent
(ObservableMap<K, V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic, CacheEvent.TransformationState transformState, boolean fPriming, boolean fExpired) Constructs a new CacheEvent. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
Get the event's description.Return true iff this event istransformable
.boolean
Return true iff this event is caused by an entry eviction due to time limit reached.boolean
Return true iff this event is caused by a priming listener registration.boolean
Return true iff this event is caused by the cache internal processing such as eviction or loadingboolean
Return true iff this event is caused by a synthetic version update sent by the server to notify clients of the current version.protected boolean
shouldDispatch
(MapListener listener) Return true if the providedMapListener
should receive this event.CacheEvent
<K, V> with
(int nPartition, long lVersion) Return a MapEvent that is enriched with the provided partition and version.Methods inherited from class com.tangosol.util.MapEvent
dispatch, dispatch, dispatch, getDescription, getId, getKey, getMap, getNewEntry, getNewValue, getOldEntry, getOldValue, getPartition, getVersion, isDelete, isInsert, isUpdate, readExternal, toString, writeExternal
Methods inherited from class java.util.EventObject
getSource
-
Field Details
-
m_nFlags
protected int m_nFlagsFlags holder for event details such as whether the event is synthetic -
m_transformState
The transformation state for this event. -
SYNTHETIC
protected static final int SYNTHETICFlag indicating whether or not the event is synthetic.- See Also:
-
PRIMING
protected static final int PRIMINGFlag indicating whether or not the event is a priming event (NearCache).- See Also:
-
EXPIRED
protected static final int EXPIREDFlag indicating whether the deletion event is a result of time expiration.- See Also:
-
-
Constructor Details
-
CacheEvent
public CacheEvent(ObservableMap<K, V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic) Constructs a new CacheEvent.- Parameters:
map
- the ObservableMap object that fired the eventnId
- this event's id, one ofMapEvent.ENTRY_INSERTED
,MapEvent.ENTRY_UPDATED
orMapEvent.ENTRY_DELETED
oKey
- the key into the mapoValueOld
- the old value (for update and delete events)oValueNew
- the new value (for insert and update events)fSynthetic
- true iff the event is caused by the cache internal processing such as eviction or loading
-
CacheEvent
public CacheEvent(ObservableMap<K, V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic, boolean fPriming) Constructs a new CacheEvent.- Parameters:
map
- the ObservableMap object that fired the eventnId
- this event's id, one ofMapEvent.ENTRY_INSERTED
,MapEvent.ENTRY_UPDATED
orMapEvent.ENTRY_DELETED
oKey
- the key into the mapoValueOld
- the old value (for update and delete events)oValueNew
- the new value (for insert and update events)fSynthetic
- true iff the event is caused by the cache internal processing such as eviction or loadingfPriming
- a flag indicating whether or not the event is a priming event
-
CacheEvent
public CacheEvent(ObservableMap<K, V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic, CacheEvent.TransformationState transformState) Constructs a new CacheEvent.- Parameters:
map
- the ObservableMap object that fired the eventnId
- this event's id, one ofMapEvent.ENTRY_INSERTED
,MapEvent.ENTRY_UPDATED
orMapEvent.ENTRY_DELETED
oKey
- the key into the mapoValueOld
- the old value (for update and delete events)oValueNew
- the new value (for insert and update events)fSynthetic
- true iff the event is caused by the cache internal processing such as eviction or loadingtransformState
- thestate
describing how this event has been or should be transformed
-
CacheEvent
public CacheEvent(ObservableMap<K, V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic, CacheEvent.TransformationState transformState, boolean fPriming) Constructs a new CacheEvent.- Parameters:
map
- the ObservableMap object that fired the eventnId
- this event's id, one ofMapEvent.ENTRY_INSERTED
,MapEvent.ENTRY_UPDATED
orMapEvent.ENTRY_DELETED
oKey
- the key into the mapoValueOld
- the old value (for update and delete events)oValueNew
- the new value (for insert and update events)fSynthetic
- true iff the event is caused by the cache internal processing such as eviction or loadingtransformState
- thestate
describing how this event has been or should be transformedfPriming
- a flag indicating whether or not the event is a priming event
-
CacheEvent
public CacheEvent(ObservableMap<K, V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic, CacheEvent.TransformationState transformState, boolean fPriming, boolean fExpired) Constructs a new CacheEvent.- Parameters:
map
- the ObservableMap object that fired the eventnId
- this event's id, one ofMapEvent.ENTRY_INSERTED
,MapEvent.ENTRY_UPDATED
orMapEvent.ENTRY_DELETED
oKey
- the key into the mapoValueOld
- the old value (for update and delete events)oValueNew
- the new value (for insert and update events)fSynthetic
- true iff the event is caused by the cache internal processing such as eviction or loadingtransformState
- thestate
describing how this event has been or should be transformedfPriming
- a flag indicating whether or not the event is a priming eventfExpired
- true iff the event results from an eviction due to time- Since:
- 22.06
-
-
Method Details
-
with
Description copied from class:MapEvent
Return a MapEvent that is enriched with the provided partition and version. -
shouldDispatch
Description copied from class:MapEvent
Return true if the providedMapListener
should receive this event.- Overrides:
shouldDispatch
in classMapEvent<K,
V> - Parameters:
listener
- the MapListener to dispatch this event to- Returns:
- true if the provided MapListener should receive the event
-
isSynthetic
public boolean isSynthetic()Return true iff this event is caused by the cache internal processing such as eviction or loading- Returns:
- true iff this event is caused by the cache internal processing
-
isExpired
public boolean isExpired()Return true iff this event is caused by an entry eviction due to time limit reached. In this case the event will also be synthetic (seeisSynthetic()
)- Returns:
- true iff this event results from a timed eviction
- Since:
- 22.06
-
isPriming
public boolean isPriming()Return true iff this event is caused by a priming listener registration.- Returns:
- true iff this event is caused by a priming listener registration
-
isVersionUpdate
public boolean isVersionUpdate()Return true iff this event is caused by a synthetic version update sent by the server to notify clients of the current version.- Returns:
- true iff this event is caused by a synthetic version update
-
getTransformationState
Return true iff this event istransformable
. Non-transformable events will not be delivered to MapEventTransformer listeners.- Returns:
- true iff this event is transformable
-
getDescription
Get the event's description.- Overrides:
getDescription
in classMapEvent<K,
V> - Returns:
- this event's description
-