Class CacheNotifierImpl<K,V>
java.lang.Object
org.infinispan.notifications.impl.AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
org.infinispan.notifications.cachelistener.CacheNotifierImpl<K,V>
- All Implemented Interfaces:
CacheNotifier<K,
,V> ClusterCacheNotifier<K,
,V> ClassLoaderAwareFilteringListenable<K,
,V> ClassLoaderAwareListenable
,DataConversionAwareListenable<K,
,V> FilteringListenable<K,
,V> Listenable
public class CacheNotifierImpl<K,V>
extends AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
implements ClusterCacheNotifier<K,V>
Helper class that handles all notifications to registered listeners.
- Since:
- 4.0
- Author:
- Manik Surtani (manik AT infinispan DOT org), Mircea.Markus@jboss.com, William Burns, anistor@redhat.com
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
protected class
protected class
This class is to be used with cluster listener invocations only when they have included current state.protected class
Nested classes/interfaces inherited from class org.infinispan.notifications.impl.AbstractListenerImpl
AbstractListenerImpl.AbstractInvocationBuilder, AbstractListenerImpl.ListenerInvocationImpl<A>
-
Field Summary
Fields inherited from class org.infinispan.notifications.impl.AbstractListenerImpl
asyncProcessor, listenersMap
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<C> CompletionStage<Void>
addFilteredListenerAsync
(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) Asynchronous version ofFilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)
<C> CompletionStage<Void>
addFilteredListenerAsync
(ListenerHolder listenerHolder, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) addListenerAsync
(Object listener) Asynchronous version ofListenable.addListener(Object)
addListenerAsync
(Object listener, ClassLoader classLoader) Asynchronous version ofClassLoaderAwareListenable.addListener(Object, ClassLoader)
<C> CompletionStage<Void>
addListenerAsync
(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter) Asynchronous version ofFilteringListenable.addListener(Object, CacheEventFilter, CacheEventConverter)
<C> CompletionStage<Void>
addListenerAsync
(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, ClassLoader classLoader) Adds the listener using the provided filter converter and class loader.<C> CompletionStage<Void>
addListenerAsync
(ListenerHolder listenerHolder, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, ClassLoader classLoader) <C> CompletionStage<Void>
addStorageFormatFilteredListenerAsync
(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) protected boolean
protected Map<Class<? extends Annotation>,
Class<?>> getListenerCollectionForAnnotation
(Class<? extends Annotation> annotation) protected org.infinispan.util.logging.Log
getLog()
boolean
isNotificationAllowed
(FlagAffectedCommand cmd, List<CacheEntryListenerInvocation<K, V>> listeners) notifyCacheEntriesEvicted
(Collection<Map.Entry<K, V>> entries, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntriesEvictedEvent
event.notifyCacheEntryActivated
(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryActivatedEvent
event.notifyCacheEntryCreated
(K key, V value, Metadata metadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryCreatedEvent
event.notifyCacheEntryExpired
(K key, V value, Metadata metadata, InvocationContext ctx) Notifies all registered listeners of a CacheEntryExpired event.notifyCacheEntryInvalidated
(K key, V value, Metadata metadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryInvalidatedEvent
event.notifyCacheEntryLoaded
(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryLoadedEvent
event.notifyCacheEntryModified
(K key, V value, Metadata metadata, V previousValue, Metadata previousMetadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryModifiedEvent
event.notifyCacheEntryPassivated
(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryPassivatedEvent
event.notifyCacheEntryRemoved
(K key, V previousValue, Metadata previousMetadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryRemovedEvent
event.notifyCacheEntryVisited
(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryVisitedEvent
event.notifyClusterListeners
(Collection<ClusterEvent<K, V>> events, UUID uuid) Method that is invoked on the node that has the given cluster listener that when registered generated the given listenerId.notifyDataRehashed
(ConsistentHash oldCH, ConsistentHash newCH, ConsistentHash unionCH, int newTopologyId, boolean pre) notifyPartitionStatusChanged
(AvailabilityMode mode, boolean pre) notifyPersistenceAvailabilityChanged
(boolean available) notifyTopologyChanged
(CacheTopology oldTopology, CacheTopology newTopology, int newTopologyId, boolean pre) notifyTransactionCompleted
(GlobalTransaction transaction, boolean successful, InvocationContext ctx) Notifies all registered listeners of a transaction completion event.notifyTransactionRegistered
(GlobalTransaction globalTransaction, boolean isOriginLocal) Notifies all registered listeners of a transaction registration event.removeListenerAsync
(Object listener) Asynchronous version ofListenable.removeListener(Object)
protected Set<CacheEntryListenerInvocation<K,
V>> removeListenerInvocation
(Class<? extends Annotation> annotation, Object listener) protected final void
resumeIfNeeded
(javax.transaction.Transaction transaction) This method is invoked so that this node can send the details required for a new node to be bootstrapped with the existing cluster listeners that are already installed.void
start()
void
stop()
Removes all listeners from the notifierprotected final javax.transaction.Transaction
Methods inherited from class org.infinispan.notifications.impl.AbstractListenerImpl
canApply, composeStageIfNeeded, findListenerCallbacks, getListeners, handleException, hasListener, invokeListeners, removeListenerFromMaps, resumeOnCPU, testListenerClassValidity, testListenerMethodValidity, validateAndAddFilterListenerInvocations, validateAndAddListenerInvocations
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.infinispan.notifications.cachelistener.CacheNotifier
hasListener
Methods inherited from interface org.infinispan.notifications.ClassLoaderAwareFilteringListenable
addListener
Methods inherited from interface org.infinispan.notifications.ClassLoaderAwareListenable
addListener
Methods inherited from interface org.infinispan.notifications.DataConversionAwareListenable
addFilteredListener, addListener
Methods inherited from interface org.infinispan.notifications.FilteringListenable
addFilteredListener, addListener, addStorageFormatFilteredListener
Methods inherited from interface org.infinispan.notifications.Listenable
addListener, getListeners, removeListener
-
Constructor Details
-
CacheNotifierImpl
public CacheNotifierImpl()
-
-
Method Details
-
start
public void start() -
stop
public void stop()Description copied from class:AbstractListenerImpl
Removes all listeners from the notifier- Overrides:
stop
in classAbstractListenerImpl<Event<K,
V>, CacheEntryListenerInvocation<K, V>>
-
getLog
protected org.infinispan.util.logging.Log getLog()- Specified by:
getLog
in classAbstractListenerImpl<Event<K,
V>, CacheEntryListenerInvocation<K, V>>
-
getAllowedMethodAnnotations
- Specified by:
getAllowedMethodAnnotations
in classAbstractListenerImpl<Event<K,
V>, CacheEntryListenerInvocation<K, V>>
-
suspendIfNeeded
protected final javax.transaction.Transaction suspendIfNeeded()- Specified by:
suspendIfNeeded
in classAbstractListenerImpl<Event<K,
V>, CacheEntryListenerInvocation<K, V>>
-
resumeIfNeeded
protected final void resumeIfNeeded(javax.transaction.Transaction transaction) - Specified by:
resumeIfNeeded
in classAbstractListenerImpl<Event<K,
V>, CacheEntryListenerInvocation<K, V>>
-
notifyCacheEntryCreated
public CompletionStage<Void> notifyCacheEntryCreated(K key, V value, Metadata metadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifier
Notifies all registered listeners of aCacheEntryCreatedEvent
event.- Specified by:
notifyCacheEntryCreated
in interfaceCacheNotifier<K,
V>
-
notifyCacheEntryModified
public CompletionStage<Void> notifyCacheEntryModified(K key, V value, Metadata metadata, V previousValue, Metadata previousMetadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifier
Notifies all registered listeners of aCacheEntryModifiedEvent
event.- Specified by:
notifyCacheEntryModified
in interfaceCacheNotifier<K,
V>
-
notifyCacheEntryRemoved
public CompletionStage<Void> notifyCacheEntryRemoved(K key, V previousValue, Metadata previousMetadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifier
Notifies all registered listeners of aCacheEntryRemovedEvent
event.- Specified by:
notifyCacheEntryRemoved
in interfaceCacheNotifier<K,
V>
-
notifyCacheEntryVisited
public CompletionStage<Void> notifyCacheEntryVisited(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifier
Notifies all registered listeners of aCacheEntryVisitedEvent
event.- Specified by:
notifyCacheEntryVisited
in interfaceCacheNotifier<K,
V>
-
notifyCacheEntriesEvicted
public CompletionStage<Void> notifyCacheEntriesEvicted(Collection<Map.Entry<K, V>> entries, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifier
Notifies all registered listeners of aCacheEntriesEvictedEvent
event.- Specified by:
notifyCacheEntriesEvicted
in interfaceCacheNotifier<K,
V>
-
notifyCacheEntryExpired
public CompletionStage<Void> notifyCacheEntryExpired(K key, V value, Metadata metadata, InvocationContext ctx) Description copied from interface:CacheNotifier
Notifies all registered listeners of a CacheEntryExpired event.- Specified by:
notifyCacheEntryExpired
in interfaceCacheNotifier<K,
V>
-
notifyCacheEntryInvalidated
public CompletionStage<Void> notifyCacheEntryInvalidated(K key, V value, Metadata metadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifier
Notifies all registered listeners of aCacheEntryInvalidatedEvent
event.- Specified by:
notifyCacheEntryInvalidated
in interfaceCacheNotifier<K,
V>
-
notifyCacheEntryLoaded
public CompletionStage<Void> notifyCacheEntryLoaded(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifier
Notifies all registered listeners of aCacheEntryLoadedEvent
event.- Specified by:
notifyCacheEntryLoaded
in interfaceCacheNotifier<K,
V>
-
notifyCacheEntryActivated
public CompletionStage<Void> notifyCacheEntryActivated(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifier
Notifies all registered listeners of aCacheEntryActivatedEvent
event.- Specified by:
notifyCacheEntryActivated
in interfaceCacheNotifier<K,
V>
-
notifyCacheEntryPassivated
public CompletionStage<Void> notifyCacheEntryPassivated(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifier
Notifies all registered listeners of aCacheEntryPassivatedEvent
event.- Specified by:
notifyCacheEntryPassivated
in interfaceCacheNotifier<K,
V>
-
notifyTransactionCompleted
public CompletionStage<Void> notifyTransactionCompleted(GlobalTransaction transaction, boolean successful, InvocationContext ctx) Description copied from interface:CacheNotifier
Notifies all registered listeners of a transaction completion event.- Specified by:
notifyTransactionCompleted
in interfaceCacheNotifier<K,
V> - Parameters:
transaction
- the transaction that has just completedsuccessful
- if true, the transaction committed. If false, this is a rollback event
-
notifyTransactionRegistered
public CompletionStage<Void> notifyTransactionRegistered(GlobalTransaction globalTransaction, boolean isOriginLocal) Description copied from interface:CacheNotifier
Notifies all registered listeners of a transaction registration event.- Specified by:
notifyTransactionRegistered
in interfaceCacheNotifier<K,
V>
-
notifyDataRehashed
public CompletionStage<Void> notifyDataRehashed(ConsistentHash oldCH, ConsistentHash newCH, ConsistentHash unionCH, int newTopologyId, boolean pre) - Specified by:
notifyDataRehashed
in interfaceCacheNotifier<K,
V>
-
notifyTopologyChanged
public CompletionStage<Void> notifyTopologyChanged(CacheTopology oldTopology, CacheTopology newTopology, int newTopologyId, boolean pre) - Specified by:
notifyTopologyChanged
in interfaceCacheNotifier<K,
V>
-
notifyPartitionStatusChanged
- Specified by:
notifyPartitionStatusChanged
in interfaceCacheNotifier<K,
V>
-
notifyPersistenceAvailabilityChanged
- Specified by:
notifyPersistenceAvailabilityChanged
in interfaceCacheNotifier<K,
V>
-
notifyClusterListeners
public CompletionStage<Void> notifyClusterListeners(Collection<ClusterEvent<K, V>> events, UUID uuid) Description copied from interface:ClusterCacheNotifier
Method that is invoked on the node that has the given cluster listener that when registered generated the given listenerId. Note this will notify only cluster listeners and regular listeners are not notified of the events. Will fire the events in the order of the iteration of the collection.- Specified by:
notifyClusterListeners
in interfaceClusterCacheNotifier<K,
V>
-
retrieveClusterListenerCallablesToInstall
public Collection<ClusterListenerReplicateCallable<K,V>> retrieveClusterListenerCallablesToInstall()Description copied from interface:ClusterCacheNotifier
This method is invoked so that this node can send the details required for a new node to be bootstrapped with the existing cluster listeners that are already installed.- Specified by:
retrieveClusterListenerCallablesToInstall
in interfaceClusterCacheNotifier<K,
V> - Returns:
- A collection of callables that should be invoked on the new node to properly install cluster listener information
-
isNotificationAllowed
public boolean isNotificationAllowed(FlagAffectedCommand cmd, List<CacheEntryListenerInvocation<K, V>> listeners) -
addListenerAsync
Description copied from interface:Listenable
Asynchronous version ofListenable.addListener(Object)
- Specified by:
addListenerAsync
in interfaceListenable
- Parameters:
listener
- listener to add, must not be null- Returns:
- CompletionStage that when complete the listener is fully installed
-
addListenerAsync
Description copied from interface:ClassLoaderAwareListenable
Asynchronous version ofClassLoaderAwareListenable.addListener(Object, ClassLoader)
- Specified by:
addListenerAsync
in interfaceClassLoaderAwareListenable
- Parameters:
listener
- listener to add, must not be nullclassLoader
- classloader, must not be null- Returns:
- CompletionStage that when complete the listener is fully installed
-
addListenerAsync
public <C> CompletionStage<Void> addListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, ClassLoader classLoader) Adds the listener using the provided filter converter and class loader. The provided builder is used to add additional configuration including (clustered, onlyPrimary & identifier) which can be used after this method is completed to see what values were used in the addition of this listener- Specified by:
addListenerAsync
in interfaceClassLoaderAwareFilteringListenable<K,
V>
-
getListenerCollectionForAnnotation
public List<CacheEntryListenerInvocation<K,V>> getListenerCollectionForAnnotation(Class<? extends Annotation> annotation) - Overrides:
getListenerCollectionForAnnotation
in classAbstractListenerImpl<Event<K,
V>, CacheEntryListenerInvocation<K, V>>
-
addListenerAsync
public <C> CompletionStage<Void> addListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter) Description copied from interface:FilteringListenable
Asynchronous version ofFilteringListenable.addListener(Object, CacheEventFilter, CacheEventConverter)
- Specified by:
addListenerAsync
in interfaceFilteringListenable<K,
V> - Parameters:
listener
- listener to add, must not be null- Returns:
- CompletionStage that when complete the listener is fully installed
-
addFilteredListenerAsync
public <C> CompletionStage<Void> addFilteredListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) Description copied from interface:FilteringListenable
Asynchronous version ofFilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)
- Specified by:
addFilteredListenerAsync
in interfaceFilteringListenable<K,
V>
-
addStorageFormatFilteredListenerAsync
public <C> CompletionStage<Void> addStorageFormatFilteredListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) Description copied from interface:FilteringListenable
Asynchronous version ofFilteringListenable.addStorageFormatFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)
- Specified by:
addStorageFormatFilteredListenerAsync
in interfaceFilteringListenable<K,
V>
-
addListenerAsync
public <C> CompletionStage<Void> addListenerAsync(ListenerHolder listenerHolder, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, ClassLoader classLoader) - Specified by:
addListenerAsync
in interfaceDataConversionAwareListenable<K,
V>
-
addFilteredListenerAsync
public <C> CompletionStage<Void> addFilteredListenerAsync(ListenerHolder listenerHolder, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) - Specified by:
addFilteredListenerAsync
in interfaceDataConversionAwareListenable<K,
V>
-
clusterListenerOnPrimaryOnly
protected boolean clusterListenerOnPrimaryOnly() -
removeListenerAsync
Description copied from interface:Listenable
Asynchronous version ofListenable.removeListener(Object)
- Specified by:
removeListenerAsync
in interfaceListenable
- Specified by:
removeListenerAsync
in classAbstractListenerImpl<Event<K,
V>, CacheEntryListenerInvocation<K, V>> - Parameters:
listener
- listener to remove, must not be null- Returns:
- CompletionStage that when complete the listener is fully removed
-
removeListenerInvocation
protected Set<CacheEntryListenerInvocation<K,V>> removeListenerInvocation(Class<? extends Annotation> annotation, Object listener) - Overrides:
removeListenerInvocation
in classAbstractListenerImpl<Event<K,
V>, CacheEntryListenerInvocation<K, V>>
-