Interface EntryEvent<K,​V>

  • All Superinterfaces:
    CacheEvent<K,​V>
    All Known Subinterfaces:
    TimestampedEntryEvent

    public interface EntryEvent<K,​V>
    extends CacheEvent<K,​V>
    Contains information about an event affecting an entry, including its identity and the the circumstances of the event. It is passed in to CacheListener, CapacityController, and CacheWriter.

    If this event originated from a region stored off heap then this event can only be used as long as the notification method that obtained it has not returned. For example in your implementation of CacheListener.afterUpdate(EntryEvent) the event parameter is only valid until your afterUpdate method returns. It is not safe to store instances of this class and use them later when using off heap storage. Attempts to access off-heap data from this event after it has expired will result in an IllegalStateException.

    Since:
    GemFire 3.0
    See Also:
    CacheListener, CacheWriter, RegionEvent
    • Method Detail

      • getKey

        K getKey()
        Returns the key.
        Returns:
        the key
      • getOldValue

        V getOldValue()
        Returns the value in the cache prior to this event. The old value may be obtained lazily in some contexts for performance reasons. When passed to an event handler after an event occurs, this value reflects the value that was in the cache in this VM, not necessarily the value that was in the cache VM that initiated the operation. In certain scenarios the old value may no longer be available in which case null is returned. This can happen for disk regions when the old value is on disk only.
        Returns:
        the old value in the cache prior to this event. If the entry did not exist, was invalid, or was not available, then null is returned.
        Throws:
        java.lang.IllegalStateException - if off-heap and called after the method that was passed this EntryEvent returns.
        SerializationException - if an error occurs deserializing the old value
        CopyException - if copy-on-read is set to true and the old value cannot be copied.
        CacheClosedException - if the old value must be retrieved from disk or off-heap and the cache is closed.
      • getSerializedOldValue

        SerializedCacheValue<V> getSerializedOldValue()
        Returns the serialized form of the value in the cache before this event.
        Returns:
        the serialized form of the value in the cache before this event
        Throws:
        java.lang.IllegalStateException - if off-heap and called after the method that was passed this EntryEvent returns.
        Since:
        GemFire 5.5
      • getNewValue

        V getNewValue()
        Returns the value in the cache after this event.
        Returns:
        the value in the cache after this event
        Throws:
        java.lang.IllegalStateException - if off-heap and called after the method that was passed this EntryEvent returns.
      • getSerializedNewValue

        SerializedCacheValue<V> getSerializedNewValue()
        Returns the serialized form of the value in the cache after this event.
        Returns:
        the serialized form of the value in the cache after this event
        Throws:
        java.lang.IllegalStateException - if off-heap and called after the method that was passed this EntryEvent returns.
        Since:
        GemFire 5.5
      • getTransactionId

        TransactionId getTransactionId()
        Gets the TransactionId for this EntryEvent.
        Returns:
        the ID of the transaction that performed the operation that generated this event; null if no transaction involved.
        Since:
        GemFire 4.0
      • hasClientOrigin

        boolean hasClientOrigin()
        Returns true if this event originated on a client.
        Returns:
        true if this event originated on a client.
        Since:
        GemFire 5.7
      • isOldValueAvailable

        boolean isOldValueAvailable()
        Returns true if the old value is "available". Not available means that an old value existed but it could not be obtained or it was deemed too expensive to obtain. Note that getOldValue() will return null when this method returns false.
        Returns:
        whether the old value is "available"
        Since:
        GemFire 6.0