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
Constructors Constructor Description EventImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EventImpl<K,V>
clone()
static <K,V>
EventImpl<K,V>createEvent(Cache<K,V> cache, Event.Type type)
boolean
equals(Object o)
AvailabilityMode
getAvailabilityMode()
The mode the current cluster is in.Cache<K,V>
getCache()
ConsistentHash
getConsistentHashAtEnd()
ConsistentHash
getConsistentHashAtStart()
Map<? extends K,? extends V>
getEntries()
Retrieves entries being evicted.GlobalTransaction
getGlobalTransaction()
K
getKey()
Collection<Address>
getMembersAtEnd()
Collection<Address>
getMembersAtStart()
Metadata
getMetadata()
Retrieves the metadata associated with the entry.int
getNewTopologyId()
Metadata
getOldMetadata()
V
getOldValue()
Regardless of whether isPre() is true or is false, this method returns the value of the entry being deleted.ConsistentHash
getReadConsistentHashAtEnd()
ConsistentHash
getReadConsistentHashAtStart()
Event.Type
getType()
ConsistentHash
getUnionConsistentHash()
V
getValue()
Retrieves the value of the entry being activated.ConsistentHash
getWriteConsistentHashAtEnd()
ConsistentHash
getWriteConsistentHashAtStart()
int
hashCode()
boolean
isAvailable()
boolean
isCommandRetried()
This will be true if the write command that caused this had to be retried again due to a topology change.boolean
isCreated()
Indicates whether the cache entry modification event is the result of the cache entry being created.boolean
isCurrentState()
boolean
isOriginLocal()
boolean
isPre()
boolean
isTransactionSuccessful()
void
setAvailabilityMode(AvailabilityMode mode)
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
setKey(K key)
void
setMetadata(Metadata metadata)
void
setNewTopologyId(int newTopologyId)
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
setTransactionId(GlobalTransaction transaction)
void
setTransactionSuccessful(boolean transactionSuccessful)
void
setUnionConsistentHash(ConsistentHash unionConsistentHash)
void
setValue(V value)
void
setWriteConsistentHashAtEnd(ConsistentHash writeConsistentHashAtEnd)
void
setWriteConsistentHashAtStart(ConsistentHash writeConsistentHashAtStart)
String
toString()
-
-
-
Method Detail
-
createEvent
public static <K,V> EventImpl<K,V> createEvent(Cache<K,V> cache, Event.Type type)
-
getType
public Event.Type getType()
-
isPre
public boolean isPre()
-
getKey
public K getKey()
- Specified by:
getKey
in interfaceCacheEntryEvent<K,V>
- Returns:
- the key to the affected cache entry.
-
getGlobalTransaction
public GlobalTransaction 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.
-
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
public void setKey(K key)
-
setTransactionId
public void setTransactionId(GlobalTransaction transaction)
-
setOriginLocal
public void setOriginLocal(boolean originLocal)
-
setTransactionSuccessful
public void setTransactionSuccessful(boolean transactionSuccessful)
-
setReadConsistentHashAtStart
public void setReadConsistentHashAtStart(ConsistentHash readConsistentHashAtStart)
-
setWriteConsistentHashAtStart
public void setWriteConsistentHashAtStart(ConsistentHash writeConsistentHashAtStart)
-
setReadConsistentHashAtEnd
public void setReadConsistentHashAtEnd(ConsistentHash readConsistentHashAtEnd)
-
setWriteConsistentHashAtEnd
public void setWriteConsistentHashAtEnd(ConsistentHash writeConsistentHashAtEnd)
-
setUnionConsistentHash
public void setUnionConsistentHash(ConsistentHash unionConsistentHash)
-
setNewTopologyId
public void setNewTopologyId(int newTopologyId)
-
setMetadata
public void setMetadata(Metadata metadata)
-
getMetadata
public Metadata 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
public void setOldMetadata(Metadata metadata)
-
getOldMetadata
public Metadata getOldMetadata()
-
getValue
public V 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
-
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 interfaceCacheEntryRemovedEvent<K,V>
- Returns:
- the value of the entry being deleted, regardless of isPre() value
-
setValue
public void setValue(V value)
-
setCreated
public void setCreated(boolean created)
-
setOldValue
public void setOldValue(V oldValue)
-
isAvailable
public boolean isAvailable()
- Specified by:
isAvailable
in interfacePersistenceAvailabilityChangedEvent<K,V>
- Returns:
- true if the
PersistenceManager
is available.
-
setAvailable
public void setAvailable(boolean available)
-
getMembersAtStart
public Collection<Address> getMembersAtStart()
- Specified by:
getMembersAtStart
in interfaceDataRehashedEvent<K,V>
- Returns:
- Retrieves the list of members before rehashing started.
-
getMembersAtEnd
public Collection<Address> getMembersAtEnd()
- Specified by:
getMembersAtEnd
in interfaceDataRehashedEvent<K,V>
- Returns:
- Retrieves the list of members after rehashing ended.
-
getConsistentHashAtStart
public ConsistentHash 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
public ConsistentHash 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
public ConsistentHash getReadConsistentHashAtStart()
- Specified by:
getReadConsistentHashAtStart
in interfaceTopologyChangedEvent<K,V>
-
getWriteConsistentHashAtStart
public ConsistentHash getWriteConsistentHashAtStart()
- Specified by:
getWriteConsistentHashAtStart
in interfaceTopologyChangedEvent<K,V>
-
getReadConsistentHashAtEnd
public ConsistentHash getReadConsistentHashAtEnd()
- Specified by:
getReadConsistentHashAtEnd
in interfaceTopologyChangedEvent<K,V>
-
getWriteConsistentHashAtEnd
public ConsistentHash getWriteConsistentHashAtEnd()
- Specified by:
getWriteConsistentHashAtEnd
in interfaceTopologyChangedEvent<K,V>
-
getUnionConsistentHash
public ConsistentHash 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
public AvailabilityMode 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
public void setAvailabilityMode(AvailabilityMode mode)
-
getEntries
public Map<? extends K,? extends V> 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.
-
-