Class ClusterEvent<K,V>

java.lang.Object
org.infinispan.notifications.cachelistener.cluster.ClusterEvent<K,V>
All Implemented Interfaces:
CacheEntryCreatedEvent<K,V>, CacheEntryEvent<K,V>, CacheEntryExpiredEvent<K,V>, CacheEntryModifiedEvent<K,V>, CacheEntryRemovedEvent<K,V>, Event<K,V>, TransactionalEvent<K,V>

public class ClusterEvent<K,V> extends Object implements CacheEntryCreatedEvent<K,V>, CacheEntryRemovedEvent<K,V>, CacheEntryModifiedEvent<K,V>, CacheEntryExpiredEvent<K,V>
This is an event designed for use with cluster listeners solely. This is the event that is serialized across the wire when sending the event back to the node where the cluster listener is registered. You should only create a ClusterEvent through the use of the fromEvent(CacheEntryEvent) method.
Since:
7.0
Author:
wburns
  • Method Details

    • fromEvent

      public static <K, V> ClusterEvent<K,V> fromEvent(CacheEntryEvent<K,V> event)
    • getValue

      public V getValue()
      Description copied from interface: CacheEntryCreatedEvent
      Retrieves the value of the entry being created.
      Specified by:
      getValue in interface CacheEntryCreatedEvent<K,V>
      Specified by:
      getValue in interface CacheEntryEvent<K,V>
      Specified by:
      getValue in interface CacheEntryExpiredEvent<K,V>
      Specified by:
      getValue in interface CacheEntryModifiedEvent<K,V>
      Specified by:
      getValue in interface CacheEntryRemovedEvent<K,V>
      Returns:
      null if Event.isPre() is true, or the value being created if Event.isPre() is false.
    • getNewValue

      public V getNewValue()
      Description copied from interface: CacheEntryModifiedEvent
      Retrieves the new value of the entry being modified.

      Specified by:
      getNewValue in interface CacheEntryModifiedEvent<K,V>
      Returns:
      the new value of the entry, regardless of whether isPre() is true or false.
    • getMetadata

      public Metadata getMetadata()
      Description copied from interface: CacheEntryEvent
      Retrieves the metadata associated with the entry.
      Specified by:
      getMetadata in interface CacheEntryEvent<K,V>
      Returns:
      the metadata of the cache entry
    • getOldMetadata

      public Metadata getOldMetadata()
      Description copied from interface: CacheEntryRemovedEvent
      Regardless of whether isPre() is true or is false, this method returns the metadata of the entry being deleted. This method is useful for situations where cache listeners need to know what the old value being deleted is when getting isPre() is false callbacks.
      Specified by:
      getOldMetadata in interface CacheEntryModifiedEvent<K,V>
      Specified by:
      getOldMetadata in interface CacheEntryRemovedEvent<K,V>
      Returns:
      the metadata of the entry being deleted, regardless of isPre() value
    • isCommandRetried

      public boolean isCommandRetried()
      Description copied from interface: CacheEntryCreatedEvent
      This will be true if the write command that caused this had to be retried again due to a topology change. This could be a sign that this event has been duplicated or another event was dropped and replaced (eg: ModifiedEvent replaced CreateEvent)
      Specified by:
      isCommandRetried in interface CacheEntryCreatedEvent<K,V>
      Specified by:
      isCommandRetried in interface CacheEntryModifiedEvent<K,V>
      Specified by:
      isCommandRetried in interface CacheEntryRemovedEvent<K,V>
      Returns:
      Whether the command that caused this event was retried
    • getOldValue

      public V getOldValue()
      Description copied from interface: CacheEntryRemovedEvent
      Regardless of whether isPre() is true or is false, this method returns the value of the entry being deleted. This method is useful for situations where cache listeners need to know what the old value being deleted is when getting isPre() is false callbacks.
      Specified by:
      getOldValue in interface CacheEntryModifiedEvent<K,V>
      Specified by:
      getOldValue in interface CacheEntryRemovedEvent<K,V>
      Returns:
      the value of the entry being deleted, regardless of isPre() value
    • isCreated

      public boolean isCreated()
      Description copied from interface: CacheEntryModifiedEvent
      Indicates whether the cache entry modification event is the result of the cache entry being created. This method helps determine if the cache entry was created when event.isPre() is false.
      Specified by:
      isCreated in interface CacheEntryModifiedEvent<K,V>
      Returns:
      true if the event is the result of the entry being created, otherwise it returns false indicating that the event was the result of a cache entry being updated
    • getKey

      public K getKey()
      Specified by:
      getKey in interface CacheEntryEvent<K,V>
      Returns:
      the key to the affected cache entry.
    • getGlobalTransaction

      public GlobalTransaction getGlobalTransaction()
      Specified by:
      getGlobalTransaction in interface TransactionalEvent<K,V>
      Returns:
      the Transaction associated with the current call. May be null if the current call is outside the scope of a transaction.
    • isOriginLocal

      public boolean isOriginLocal()
      Specified by:
      isOriginLocal in interface TransactionalEvent<K,V>
      Returns:
      true if the call originated on the local cache instance; false if originated from a remote one.
    • getType

      public Event.Type getType()
      Specified by:
      getType in interface Event<K,V>
      Returns:
      the type of event represented by this instance.
    • isPre

      public boolean isPre()
      Specified by:
      isPre in interface Event<K,V>
      Returns:
      true if the notification is before the event has occurred, false if after the event has occurred.
    • getCache

      public Cache<K,V> getCache()
      Specified by:
      getCache in interface Event<K,V>
      Returns:
      a handle to the cache instance that generated this notification.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object