Class EventImpl<K,V>
java.lang.Object
org.infinispan.notifications.cachelistener.event.impl.EventImpl<K,V>
- All Implemented Interfaces:
Cloneable, CacheEntriesEvictedEvent, CacheEntryActivatedEvent, CacheEntryCreatedEvent, CacheEntryEvent, CacheEntryExpiredEvent, CacheEntryInvalidatedEvent, CacheEntryLoadedEvent, CacheEntryModifiedEvent, CacheEntryPassivatedEvent, CacheEntryRemovedEvent, CacheEntryVisitedEvent, DataRehashedEvent, Event, PartitionStatusChangedEvent, PersistenceAvailabilityChangedEvent, TopologyChangedEvent, TransactionalEvent, TransactionCompletedEvent, TransactionRegisteredEvent
public class EventImpl<K,V>
extends Object
implements CacheEntryActivatedEvent, CacheEntryCreatedEvent, CacheEntriesEvictedEvent, CacheEntryLoadedEvent, CacheEntryModifiedEvent, CacheEntryPassivatedEvent, CacheEntryRemovedEvent, CacheEntryVisitedEvent, TransactionCompletedEvent, TransactionRegisteredEvent, CacheEntryInvalidatedEvent, DataRehashedEvent, TopologyChangedEvent, CacheEntryExpiredEvent, PartitionStatusChangedEvent, PersistenceAvailabilityChangedEvent, Cloneable
Basic implementation of an event that covers all event types.
- Since:
- 4.0
- Author:
- Manik Surtani
-
Nested Class Summary
Nested classes/interfaces inherited from interface Event
Event.Type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()static <K,V> EventImpl <K, V> createEvent(Cache<K, V> cache, Event.Type type) booleanThe mode the current cluster is in.getCache()Retrieves entries being evicted.getKey()Retrieves the metadata associated with the entry.intRetrieves the new value of the entry being modified.Regardless of whetherisPre()istrueor isfalse, this method returns the metadata of the entry being deleted.Retrieves the old value of the entry being modified.getType()getValue()Retrieves the value of the entry being activated.inthashCode()booleanbooleanThis will be true if the write command that caused this had to be retried again due to a topology change.booleanIndicates whether the cache entry modification event is the result of the cache entry being created.booleanbooleanbooleanisPre()booleanvoidvoidsetAvailable(boolean available) voidsetCommandRetried(boolean commandRetried) voidsetCreated(boolean created) voidsetCurrentState(boolean currentState) voidsetEntries(Map<? extends K, ? extends V> entries) voidvoidsetMetadata(Metadata metadata) voidsetNewTopologyId(int newTopologyId) voidsetNewValue(V newValue) voidsetOldMetadata(Metadata metadata) voidsetOldValue(V oldValue) voidsetOriginLocal(boolean originLocal) voidsetPre(boolean pre) voidsetReadConsistentHashAtEnd(ConsistentHash readConsistentHashAtEnd) voidsetReadConsistentHashAtStart(ConsistentHash readConsistentHashAtStart) voidvoidsetTransactionId(GlobalTransaction transaction) Deprecated, for removal: This API element is subject to removal in a future version.Since 12.0, will be removed in 15.0voidsetTransactionSuccessful(boolean transactionSuccessful) voidsetUnionConsistentHash(ConsistentHash unionConsistentHash) voidvoidsetWriteConsistentHashAtEnd(ConsistentHash writeConsistentHashAtEnd) voidsetWriteConsistentHashAtStart(ConsistentHash writeConsistentHashAtStart) toString()
-
Constructor Details
-
EventImpl
public EventImpl()
-
-
Method Details
-
createEvent
-
getType
-
isPre
-
getCache
-
getKey
- Specified by:
getKeyin interfaceCacheEntryEvent<K,V> - Returns:
- the key to the affected cache entry.
-
getGlobalTransaction
- Specified by:
getGlobalTransactionin interfaceTransactionalEvent<K,V> - Returns:
- the Transaction associated with the current call. May be null if the current call is outside the scope of a transaction.
-
getSource
- Specified by:
getSourcein interfaceCacheEntryEvent<K,V> - Returns:
- an identifier of the transaction or cache invocation that triggered the event.
In a transactional cache, it is the same as
TransactionalEvent.getGlobalTransaction(). In a non-transactional cache, it is an internal object that identifies the cache invocation.
-
isOriginLocal
public boolean isOriginLocal()- Specified by:
isOriginLocalin interfaceTransactionalEvent<K,V> - Returns:
- true if the call originated on the local cache instance; false if originated from a remote one.
-
isTransactionSuccessful
public boolean isTransactionSuccessful()- Specified by:
isTransactionSuccessfulin interfaceTransactionCompletedEvent<K,V> - Returns:
- if
true, the transaction completed by committing successfully. Iffalse, the transaction completed with a rollback.
-
setPre
public void setPre(boolean pre) -
setKey
-
setTransactionId
Deprecated, for removal: This API element is subject to removal in a future version.Since 12.0, will be removed in 15.0 -
setSource
- Parameters:
source- An identifier of the transaction or cache invocation that triggered the event. In a transactional cache, it is the same asgetGlobalTransaction(). In a non-transactional cache, it is an internal object that identifies the cache invocation.
-
setOriginLocal
public void setOriginLocal(boolean originLocal) -
setTransactionSuccessful
public void setTransactionSuccessful(boolean transactionSuccessful) -
setReadConsistentHashAtStart
-
setWriteConsistentHashAtStart
-
setReadConsistentHashAtEnd
-
setWriteConsistentHashAtEnd
-
setUnionConsistentHash
-
setNewTopologyId
public void setNewTopologyId(int newTopologyId) -
setMetadata
-
getMetadata
Description copied from interface:CacheEntryEventRetrieves the metadata associated with the entry.- Specified by:
getMetadatain interfaceCacheEntryEvent<K,V> - Returns:
- the metadata of the cache entry
-
isCurrentState
public boolean isCurrentState()- Specified by:
isCurrentStatein interfaceCacheEntryEvent<K,V> - Returns:
- True if this event is generated from an existing entry as the listener
has
Listener.includeCurrentState()set totrue.
-
setCurrentState
public void setCurrentState(boolean currentState) -
setOldMetadata
-
getOldMetadata
Description copied from interface:CacheEntryModifiedEventRegardless of whetherisPre()istrueor isfalse, 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 gettingisPre()isfalsecallbacks.- Specified by:
getOldMetadatain interfaceCacheEntryModifiedEvent<K,V> - Specified by:
getOldMetadatain interfaceCacheEntryRemovedEvent<K,V> - Returns:
- the metadata of the entry being deleted, regardless of
isPre()value
-
getValue
Description copied from interface:CacheEntryActivatedEventRetrieves the value of the entry being activated.- Specified by:
getValuein interfaceCacheEntryActivatedEvent<K,V> - Specified by:
getValuein interfaceCacheEntryCreatedEvent<K,V> - Specified by:
getValuein interfaceCacheEntryEvent<K,V> - Specified by:
getValuein interfaceCacheEntryExpiredEvent<K,V> - Specified by:
getValuein interfaceCacheEntryInvalidatedEvent<K,V> - Specified by:
getValuein interfaceCacheEntryLoadedEvent<K,V> - Specified by:
getValuein interfaceCacheEntryModifiedEvent<K,V> - Specified by:
getValuein interfaceCacheEntryPassivatedEvent<K,V> - Specified by:
getValuein interfaceCacheEntryRemovedEvent<K,V> - Specified by:
getValuein interfaceCacheEntryVisitedEvent<K,V> - Returns:
- the value of the activated entry
-
setCommandRetried
public void setCommandRetried(boolean commandRetried) -
isCommandRetried
public boolean isCommandRetried()Description copied from interface:CacheEntryCreatedEventThis 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:
isCommandRetriedin interfaceCacheEntryCreatedEvent<K,V> - Specified by:
isCommandRetriedin interfaceCacheEntryModifiedEvent<K,V> - Specified by:
isCommandRetriedin interfaceCacheEntryRemovedEvent<K,V> - Returns:
- Whether the command that caused this event was retried
-
isCreated
public boolean isCreated()Description copied from interface:CacheEntryModifiedEventIndicates 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 whenevent.isPre()isfalse.- Specified by:
isCreatedin interfaceCacheEntryModifiedEvent<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
-
getNewValue
Description copied from interface:CacheEntryModifiedEventRetrieves the new value of the entry being modified.- Specified by:
getNewValuein interfaceCacheEntryModifiedEvent<K,V> - Returns:
- the new value of the entry, regardless of whether isPre() is true or false.
-
getOldValue
Description copied from interface:CacheEntryModifiedEventRetrieves the old value of the entry being modified.- Specified by:
getOldValuein interfaceCacheEntryModifiedEvent<K,V> - Specified by:
getOldValuein interfaceCacheEntryRemovedEvent<K,V> - Returns:
- the previous value of the entry, regardless of whether isPre() is true or false.
-
setValue
-
setEntries
-
setCreated
public void setCreated(boolean created) -
setNewValue
-
setOldValue
-
isAvailable
public boolean isAvailable()- Specified by:
isAvailablein interfacePersistenceAvailabilityChangedEvent<K,V> - Returns:
- true if the
PersistenceManageris available.
-
setAvailable
public void setAvailable(boolean available) -
equals
-
hashCode
-
toString
-
getMembersAtStart
- Specified by:
getMembersAtStartin interfaceDataRehashedEvent<K,V> - Returns:
- Retrieves the list of members before rehashing started.
-
getMembersAtEnd
- Specified by:
getMembersAtEndin interfaceDataRehashedEvent<K,V> - Returns:
- Retrieves the list of members after rehashing ended.
-
getConsistentHashAtStart
- Specified by:
getConsistentHashAtStartin interfaceDataRehashedEvent<K,V> - Returns:
- The current consistent hash that was installed prior to the rehash. It is used both for reading and writing before the rebalance.
-
getConsistentHashAtEnd
- Specified by:
getConsistentHashAtEndin interfaceDataRehashedEvent<K,V> - Returns:
- The consistent hash that will be installed after the rebalance. It will be used both for reading and writing once the rebalance is complete.
-
getReadConsistentHashAtStart
- Specified by:
getReadConsistentHashAtStartin interfaceTopologyChangedEvent<K,V>
-
getWriteConsistentHashAtStart
- Specified by:
getWriteConsistentHashAtStartin interfaceTopologyChangedEvent<K,V>
-
getReadConsistentHashAtEnd
- Specified by:
getReadConsistentHashAtEndin interfaceTopologyChangedEvent<K,V>
-
getWriteConsistentHashAtEnd
- Specified by:
getWriteConsistentHashAtEndin interfaceTopologyChangedEvent<K,V>
-
getNewTopologyId
public int getNewTopologyId()- Specified by:
getNewTopologyIdin interfaceDataRehashedEvent<K,V> - Specified by:
getNewTopologyIdin interfaceTopologyChangedEvent<K,V> - Returns:
- Retrieves the new topology id after rehashing was triggered.
-
getAvailabilityMode
Description copied from interface:PartitionStatusChangedEventThe mode the current cluster is in. This determines which operations can be ran in the cluster.- Specified by:
getAvailabilityModein interfacePartitionStatusChangedEvent<K,V> - Returns:
- the mode
-
setAvailabilityMode
-
getEntries
Description copied from interface:CacheEntriesEvictedEventRetrieves entries being evicted.- Specified by:
getEntriesin interfaceCacheEntriesEvictedEvent<K,V> - Returns:
- A map containing the key/value pairs of the cache entries being evicted.
-
clone
-