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:
  • Field Details

    • 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:
    • PRIMING

      protected static final int PRIMING
      Flag indicating whether or not the event is a priming event (NearCache).
      See Also:
    • EXPIRED

      protected static final int EXPIRED
      Flag 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 event
      nId - this event's id, one of MapEvent.ENTRY_INSERTED, MapEvent.ENTRY_UPDATED or MapEvent.ENTRY_DELETED
      oKey - the key into the map
      oValueOld - 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 event
      nId - this event's id, one of MapEvent.ENTRY_INSERTED, MapEvent.ENTRY_UPDATED or MapEvent.ENTRY_DELETED
      oKey - the key into the map
      oValueOld - 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
      fPriming - 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 event
      nId - this event's id, one of MapEvent.ENTRY_INSERTED, MapEvent.ENTRY_UPDATED or MapEvent.ENTRY_DELETED
      oKey - the key into the map
      oValueOld - 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
      transformState - the state 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 event
      nId - this event's id, one of MapEvent.ENTRY_INSERTED, MapEvent.ENTRY_UPDATED or MapEvent.ENTRY_DELETED
      oKey - the key into the map
      oValueOld - 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
      transformState - the state describing how this event has been or should be transformed
      fPriming - 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 event
      nId - this event's id, one of MapEvent.ENTRY_INSERTED, MapEvent.ENTRY_UPDATED or MapEvent.ENTRY_DELETED
      oKey - the key into the map
      oValueOld - 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
      transformState - the state describing how this event has been or should be transformed
      fPriming - a flag indicating whether or not the event is a priming event
      fExpired - true iff the event results from an eviction due to time
      Since:
      22.06
  • Method Details

    • with

      public CacheEvent<K,V> with(int nPartition, long lVersion)
      Description copied from class: MapEvent
      Return a MapEvent that is enriched with the provided partition and version.
      Overrides:
      with in class MapEvent<K,V>
      Parameters:
      nPartition - the partition this MapEvent
      lVersion - the version that caused this change
      Returns:
      a MapEvent that is enriched with the provided partition and version
    • shouldDispatch

      protected boolean shouldDispatch(MapListener listener)
      Description copied from class: MapEvent
      Return true if the provided MapListener should receive this event.
      Overrides:
      shouldDispatch in class MapEvent<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 (see isSynthetic())
      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 is transformable. 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:
      getDescription in class MapEvent<K,V>
      Returns:
      this event's description