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
@NotThreadSafe
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 org.infinispan.notifications.cachelistener.event.Event
Event.Type
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
static <K,
V> EventImpl <K, V> createEvent
(Cache<K, V> cache, Event.Type type) boolean
The mode the current cluster is in.getCache()
Retrieves entries being evicted.getKey()
Retrieves the metadata associated with the entry.int
Retrieves the new value of the entry being modified.Regardless of whether isPre() is true or is false, 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.int
hashCode()
boolean
boolean
This will be true if the write command that caused this had to be retried again due to a topology change.boolean
Indicates whether the cache entry modification event is the result of the cache entry being created.boolean
boolean
boolean
isPre()
boolean
void
void
setAvailable
(boolean available) void
setCommandRetried
(boolean commandRetried) void
setCreated
(boolean created) void
setCurrentState
(boolean currentState) void
setEntries
(Map<? extends K, ? extends V> entries) void
void
setMetadata
(Metadata metadata) void
setNewTopologyId
(int newTopologyId) void
setNewValue
(V newValue) void
setOldMetadata
(Metadata metadata) void
setOldValue
(V oldValue) void
setOriginLocal
(boolean originLocal) void
setPre
(boolean pre) void
setReadConsistentHashAtEnd
(ConsistentHash readConsistentHashAtEnd) void
setReadConsistentHashAtStart
(ConsistentHash readConsistentHashAtStart) void
void
setTransactionId
(GlobalTransaction transaction) Deprecated, for removal: This API element is subject to removal in a future version.Since 12.0, will be removed in 15.0void
setTransactionSuccessful
(boolean transactionSuccessful) void
setUnionConsistentHash
(ConsistentHash unionConsistentHash) void
void
setWriteConsistentHashAtEnd
(ConsistentHash writeConsistentHashAtEnd) void
setWriteConsistentHashAtStart
(ConsistentHash writeConsistentHashAtStart) toString()
-
Constructor Details
-
EventImpl
public EventImpl()
-
-
Method Details
-
createEvent
-
getType
-
isPre
public boolean isPre() -
getCache
-
getKey
- Specified by:
getKey
in interfaceCacheEntryEvent<K,
V> - Returns:
- the key to the affected cache entry.
-
getGlobalTransaction
- Specified by:
getGlobalTransaction
in 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:
getSource
in 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:
isOriginLocal
in 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:
isTransactionSuccessful
in interfaceTransactionCompletedEvent<K,
V> - Returns:
- if true, the transaction completed by committing successfully. If false, 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:CacheEntryEvent
Retrieves the metadata associated with the entry.- Specified by:
getMetadata
in interfaceCacheEntryEvent<K,
V> - Returns:
- the metadata of the cache entry
-
isCurrentState
public boolean isCurrentState()- Specified by:
isCurrentState
in 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:CacheEntryModifiedEvent
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 interfaceCacheEntryModifiedEvent<K,
V> - Specified by:
getOldMetadata
in interfaceCacheEntryRemovedEvent<K,
V> - Returns:
- the metadata of the entry being deleted, regardless of isPre() value
-
getValue
Description copied from interface:CacheEntryActivatedEvent
Retrieves the value of the entry being activated.- Specified by:
getValue
in interfaceCacheEntryActivatedEvent<K,
V> - Specified by:
getValue
in interfaceCacheEntryCreatedEvent<K,
V> - Specified by:
getValue
in interfaceCacheEntryEvent<K,
V> - Specified by:
getValue
in interfaceCacheEntryExpiredEvent<K,
V> - Specified by:
getValue
in interfaceCacheEntryInvalidatedEvent<K,
V> - Specified by:
getValue
in interfaceCacheEntryLoadedEvent<K,
V> - Specified by:
getValue
in interfaceCacheEntryModifiedEvent<K,
V> - Specified by:
getValue
in interfaceCacheEntryPassivatedEvent<K,
V> - Specified by:
getValue
in interfaceCacheEntryRemovedEvent<K,
V> - Specified by:
getValue
in interfaceCacheEntryVisitedEvent<K,
V> - Returns:
- the value of the activated entry
-
setCommandRetried
public void setCommandRetried(boolean commandRetried) -
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 interfaceCacheEntryCreatedEvent<K,
V> - Specified by:
isCommandRetried
in interfaceCacheEntryModifiedEvent<K,
V> - Specified by:
isCommandRetried
in interfaceCacheEntryRemovedEvent<K,
V> - Returns:
- Whether the command that caused this event was retried
-
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 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:CacheEntryModifiedEvent
Retrieves the new value of the entry being modified.- Specified by:
getNewValue
in interfaceCacheEntryModifiedEvent<K,
V> - Returns:
- the new value of the entry, regardless of whether isPre() is true or false.
-
getOldValue
Description copied from interface:CacheEntryModifiedEvent
Retrieves the old value of the entry being modified.- Specified by:
getOldValue
in interfaceCacheEntryModifiedEvent<K,
V> - Specified by:
getOldValue
in 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:
isAvailable
in interfacePersistenceAvailabilityChangedEvent<K,
V> - Returns:
- true if the
PersistenceManager
is available.
-
setAvailable
public void setAvailable(boolean available) -
equals
-
hashCode
public int hashCode() -
toString
-
getMembersAtStart
- Specified by:
getMembersAtStart
in interfaceDataRehashedEvent<K,
V> - Returns:
- Retrieves the list of members before rehashing started.
-
getMembersAtEnd
- Specified by:
getMembersAtEnd
in interfaceDataRehashedEvent<K,
V> - Returns:
- Retrieves the list of members after rehashing ended.
-
getConsistentHashAtStart
- Specified by:
getConsistentHashAtStart
in interfaceDataRehashedEvent<K,
V> - Specified by:
getConsistentHashAtStart
in interfaceTopologyChangedEvent<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:
getConsistentHashAtEnd
in interfaceDataRehashedEvent<K,
V> - Specified by:
getConsistentHashAtEnd
in interfaceTopologyChangedEvent<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:
getReadConsistentHashAtStart
in interfaceTopologyChangedEvent<K,
V>
-
getWriteConsistentHashAtStart
- Specified by:
getWriteConsistentHashAtStart
in interfaceTopologyChangedEvent<K,
V>
-
getReadConsistentHashAtEnd
- Specified by:
getReadConsistentHashAtEnd
in interfaceTopologyChangedEvent<K,
V>
-
getWriteConsistentHashAtEnd
- Specified by:
getWriteConsistentHashAtEnd
in interfaceTopologyChangedEvent<K,
V>
-
getUnionConsistentHash
- Specified by:
getUnionConsistentHash
in interfaceDataRehashedEvent<K,
V> - Returns:
- The union of the current and future consistent hashes.
-
getNewTopologyId
public int getNewTopologyId()- Specified by:
getNewTopologyId
in interfaceDataRehashedEvent<K,
V> - Specified by:
getNewTopologyId
in interfaceTopologyChangedEvent<K,
V> - Returns:
- Retrieves the new topology id after rehashing was triggered.
-
getAvailabilityMode
Description copied from interface:PartitionStatusChangedEvent
The mode the current cluster is in. This determines which operations can be ran in the cluster.- Specified by:
getAvailabilityMode
in interfacePartitionStatusChangedEvent<K,
V> - Returns:
- the mode
-
setAvailabilityMode
-
getEntries
Description copied from interface:CacheEntriesEvictedEvent
Retrieves entries being evicted.- Specified by:
getEntries
in interfaceCacheEntriesEvictedEvent<K,
V> - Returns:
- A map containing the key/value pairs of the cache entries being evicted.
-
clone
-