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)booleanequals(Object o)AvailabilityModegetAvailabilityMode()The mode the current cluster is in.Cache<K,V>getCache()ConsistentHashgetConsistentHashAtEnd()ConsistentHashgetConsistentHashAtStart()Map<? extends K,? extends V>getEntries()Retrieves entries being evicted.GlobalTransactiongetGlobalTransaction()KgetKey()Collection<Address>getMembersAtEnd()Collection<Address>getMembersAtStart()MetadatagetMetadata()Retrieves the metadata associated with the entry.intgetNewTopologyId()MetadatagetOldMetadata()VgetOldValue()Regardless of whether isPre() is true or is false, this method returns the value of the entry being deleted.ConsistentHashgetReadConsistentHashAtEnd()ConsistentHashgetReadConsistentHashAtStart()Event.TypegetType()ConsistentHashgetUnionConsistentHash()VgetValue()Retrieves the value of the entry being activated.ConsistentHashgetWriteConsistentHashAtEnd()ConsistentHashgetWriteConsistentHashAtStart()inthashCode()booleanisAvailable()booleanisCommandRetried()This will be true if the write command that caused this had to be retried again due to a topology change.booleanisCreated()Indicates whether the cache entry modification event is the result of the cache entry being created.booleanisCurrentState()booleanisOriginLocal()booleanisPre()booleanisTransactionSuccessful()voidsetAvailabilityMode(AvailabilityMode mode)voidsetAvailable(boolean available)voidsetCommandRetried(boolean commandRetried)voidsetCreated(boolean created)voidsetCurrentState(boolean currentState)voidsetEntries(Map<? extends K,? extends V> entries)voidsetKey(K key)voidsetMetadata(Metadata metadata)voidsetNewTopologyId(int newTopologyId)voidsetOldMetadata(Metadata metadata)voidsetOldValue(V oldValue)voidsetOriginLocal(boolean originLocal)voidsetPre(boolean pre)voidsetReadConsistentHashAtEnd(ConsistentHash readConsistentHashAtEnd)voidsetReadConsistentHashAtStart(ConsistentHash readConsistentHashAtStart)voidsetTransactionId(GlobalTransaction transaction)voidsetTransactionSuccessful(boolean transactionSuccessful)voidsetUnionConsistentHash(ConsistentHash unionConsistentHash)voidsetValue(V value)voidsetWriteConsistentHashAtEnd(ConsistentHash writeConsistentHashAtEnd)voidsetWriteConsistentHashAtStart(ConsistentHash writeConsistentHashAtStart)StringtoString()
-
-
-
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:
getKeyin interfaceCacheEntryEvent<K,V>- Returns:
- the key to the affected cache entry.
-
getGlobalTransaction
public GlobalTransaction 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.
-
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. 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: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
public void setOldMetadata(Metadata metadata)
-
getOldMetadata
public Metadata getOldMetadata()
-
getValue
public V 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 when event.isPre() is false.- 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
-
getOldValue
public V getOldValue()
Description copied from interface:CacheEntryRemovedEventRegardless 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:
getOldValuein 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:
isAvailablein interfacePersistenceAvailabilityChangedEvent<K,V>- Returns:
- true if the
PersistenceManageris available.
-
setAvailable
public void setAvailable(boolean available)
-
getMembersAtStart
public Collection<Address> getMembersAtStart()
- Specified by:
getMembersAtStartin interfaceDataRehashedEvent<K,V>- Returns:
- Retrieves the list of members before rehashing started.
-
getMembersAtEnd
public Collection<Address> getMembersAtEnd()
- Specified by:
getMembersAtEndin interfaceDataRehashedEvent<K,V>- Returns:
- Retrieves the list of members after rehashing ended.
-
getConsistentHashAtStart
public ConsistentHash getConsistentHashAtStart()
- Specified by:
getConsistentHashAtStartin interfaceDataRehashedEvent<K,V>- Specified by:
getConsistentHashAtStartin 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:
getConsistentHashAtEndin interfaceDataRehashedEvent<K,V>- Specified by:
getConsistentHashAtEndin 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:
getReadConsistentHashAtStartin interfaceTopologyChangedEvent<K,V>
-
getWriteConsistentHashAtStart
public ConsistentHash getWriteConsistentHashAtStart()
- Specified by:
getWriteConsistentHashAtStartin interfaceTopologyChangedEvent<K,V>
-
getReadConsistentHashAtEnd
public ConsistentHash getReadConsistentHashAtEnd()
- Specified by:
getReadConsistentHashAtEndin interfaceTopologyChangedEvent<K,V>
-
getWriteConsistentHashAtEnd
public ConsistentHash getWriteConsistentHashAtEnd()
- Specified by:
getWriteConsistentHashAtEndin interfaceTopologyChangedEvent<K,V>
-
getUnionConsistentHash
public ConsistentHash getUnionConsistentHash()
- Specified by:
getUnionConsistentHashin interfaceDataRehashedEvent<K,V>- Returns:
- The union of the current and future consistent hashes.
-
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
public AvailabilityMode 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
public void setAvailabilityMode(AvailabilityMode mode)
-
getEntries
public Map<? extends K,? extends V> 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.
-
-