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
public class CacheEvent<K,V> extends MapEvent<K,V>
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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCacheEvent.TransformationStateTransformationState describes how a CacheEvent has been or should betransformed.
-
Field Summary
Fields Modifier and Type Field Description protected static intEXPIREDFlag indicating whether the deletion event is a result of time expiration.protected intm_nFlagsFlags holder for event details such as whether the event is syntheticprotected CacheEvent.TransformationStatem_transformStateThe transformation state for this event.protected static intPRIMINGFlag indicating whether or not the event is a priming event (NearCache).protected static intSYNTHETICFlag 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
Constructors Constructor Description CacheEvent(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetDescription()Get the event's description.CacheEvent.TransformationStategetTransformationState()Return true iff this event istransformable.booleanisExpired()Return true iff this event is caused by an entry eviction due to time limit reached.booleanisPriming()Return true iff this event is caused by a priming listener registration.booleanisSynthetic()Return true iff this event is caused by the cache internal processing such as eviction or loadingbooleanisVersionUpdate()Return true iff this event is caused by a synthetic version update sent by the server to notify clients of the current version.protected booleanshouldDispatch(MapListener listener)Return true if the providedMapListenershould 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 Detail
-
m_nFlags
protected int m_nFlags
Flags holder for event details such as whether the event is synthetic
-
m_transformState
protected CacheEvent.TransformationState m_transformState
The transformation state for this event.
-
SYNTHETIC
protected static final int SYNTHETIC
Flag indicating whether or not the event is synthetic.- See Also:
- Constant Field Values
-
PRIMING
protected static final int PRIMING
Flag indicating whether or not the event is a priming event (NearCache).- See Also:
- Constant Field Values
-
EXPIRED
protected static final int EXPIRED
Flag indicating whether the deletion event is a result of time expiration.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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_UPDATEDorMapEvent.ENTRY_DELETEDoKey- 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_UPDATEDorMapEvent.ENTRY_DELETEDoKey- 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_UPDATEDorMapEvent.ENTRY_DELETEDoKey- 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- thestatedescribing 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_UPDATEDorMapEvent.ENTRY_DELETEDoKey- 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- thestatedescribing 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_UPDATEDorMapEvent.ENTRY_DELETEDoKey- 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- thestatedescribing 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 Detail
-
with
public CacheEvent<K,V> with(int nPartition, long lVersion)
Description copied from class:MapEventReturn a MapEvent that is enriched with the provided partition and version.
-
shouldDispatch
protected boolean shouldDispatch(MapListener listener)
Description copied from class:MapEventReturn true if the providedMapListenershould receive this event.- Overrides:
shouldDispatchin 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
public CacheEvent.TransformationState 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
protected String getDescription()
Get the event's description.- Overrides:
getDescriptionin classMapEvent<K,V>- Returns:
- this event's description
-
-