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 static classprotected classprotected classThis class is to be used with cluster listener invocations only when they have included current state.protected classNested classes/interfaces inherited from class AbstractListenerImpl
AbstractListenerImpl.AbstractInvocationBuilder, AbstractListenerImpl.ListenerInvocationImpl<A> -
Field Summary
Fields inherited from class 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 booleanprotected Map<Class<? extends Annotation>, Class<?>> getListenerCollectionForAnnotation(Class<? extends Annotation> annotation) protected org.infinispan.util.logging.LoggetLog()booleanisNotificationAllowed(FlagAffectedCommand cmd, List<CacheEntryListenerInvocation<K, V>> listeners) notifyCacheEntriesEvicted(Collection<Map.Entry<K, V>> entries, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntriesEvictedEventevent.notifyCacheEntryActivated(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryActivatedEventevent.notifyCacheEntryCreated(K key, V value, Metadata metadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryCreatedEventevent.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 aCacheEntryInvalidatedEventevent.notifyCacheEntryLoaded(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryLoadedEventevent.notifyCacheEntryModified(K key, V value, Metadata metadata, V previousValue, Metadata previousMetadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryModifiedEventevent.notifyCacheEntryPassivated(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryPassivatedEventevent.notifyCacheEntryRemoved(K key, V previousValue, Metadata previousMetadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryRemovedEventevent.notifyCacheEntryVisited(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Notifies all registered listeners of aCacheEntryVisitedEventevent.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 voidresumeIfNeeded(jakarta.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.voidstart()voidstop()Removes all listeners from the notifierprotected final jakarta.transaction.TransactionMethods inherited from class AbstractListenerImpl
canApply, composeStageIfNeeded, findListenerCallbacks, getListeners, handleException, hasListener, hasListeners, invokeListeners, removeListenerFromMaps, resumeOnCPU, testListenerClassValidity, testListenerMethodValidity, validateAndAddFilterListenerInvocations, validateAndAddListenerInvocationsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CacheNotifier
getListeners, hasListener, hasListenersMethods inherited from interface ClassLoaderAwareFilteringListenable
addListenerMethods inherited from interface ClassLoaderAwareListenable
addListenerMethods inherited from interface DataConversionAwareListenable
addFilteredListener, addListenerMethods inherited from interface FilteringListenable
addFilteredListener, addListener, addStorageFormatFilteredListenerMethods inherited from interface Listenable
addListener, removeListener
-
Constructor Details
-
CacheNotifierImpl
public CacheNotifierImpl()
-
-
Method Details
-
start
public void start() -
stop
public void stop()Description copied from class:AbstractListenerImplRemoves all listeners from the notifier- Overrides:
stopin classAbstractListenerImpl<Event<K,V>, CacheEntryListenerInvocation<K, V>>
-
getLog
protected org.infinispan.util.logging.Log getLog()- Specified by:
getLogin classAbstractListenerImpl<Event<K,V>, CacheEntryListenerInvocation<K, V>>
-
getAllowedMethodAnnotations
- Specified by:
getAllowedMethodAnnotationsin classAbstractListenerImpl<Event<K,V>, CacheEntryListenerInvocation<K, V>>
-
suspendIfNeeded
protected final jakarta.transaction.Transaction suspendIfNeeded()- Specified by:
suspendIfNeededin classAbstractListenerImpl<Event<K,V>, CacheEntryListenerInvocation<K, V>>
-
resumeIfNeeded
protected final void resumeIfNeeded(jakarta.transaction.Transaction transaction) - Specified by:
resumeIfNeededin 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:CacheNotifierNotifies all registered listeners of aCacheEntryCreatedEventevent.- Specified by:
notifyCacheEntryCreatedin 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:CacheNotifierNotifies all registered listeners of aCacheEntryModifiedEventevent.- Specified by:
notifyCacheEntryModifiedin interfaceCacheNotifier<K,V>
-
notifyCacheEntryRemoved
public CompletionStage<Void> notifyCacheEntryRemoved(K key, V previousValue, Metadata previousMetadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifierNotifies all registered listeners of aCacheEntryRemovedEventevent.- Specified by:
notifyCacheEntryRemovedin interfaceCacheNotifier<K,V>
-
notifyCacheEntryVisited
public CompletionStage<Void> notifyCacheEntryVisited(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifierNotifies all registered listeners of aCacheEntryVisitedEventevent.- Specified by:
notifyCacheEntryVisitedin interfaceCacheNotifier<K,V>
-
notifyCacheEntriesEvicted
public CompletionStage<Void> notifyCacheEntriesEvicted(Collection<Map.Entry<K, V>> entries, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifierNotifies all registered listeners of aCacheEntriesEvictedEventevent.- Specified by:
notifyCacheEntriesEvictedin interfaceCacheNotifier<K,V>
-
notifyCacheEntryExpired
public CompletionStage<Void> notifyCacheEntryExpired(K key, V value, Metadata metadata, InvocationContext ctx) Description copied from interface:CacheNotifierNotifies all registered listeners of a CacheEntryExpired event.- Specified by:
notifyCacheEntryExpiredin interfaceCacheNotifier<K,V>
-
notifyCacheEntryInvalidated
public CompletionStage<Void> notifyCacheEntryInvalidated(K key, V value, Metadata metadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifierNotifies all registered listeners of aCacheEntryInvalidatedEventevent.- Specified by:
notifyCacheEntryInvalidatedin interfaceCacheNotifier<K,V>
-
notifyCacheEntryLoaded
public CompletionStage<Void> notifyCacheEntryLoaded(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifierNotifies all registered listeners of aCacheEntryLoadedEventevent.- Specified by:
notifyCacheEntryLoadedin interfaceCacheNotifier<K,V>
-
notifyCacheEntryActivated
public CompletionStage<Void> notifyCacheEntryActivated(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifierNotifies all registered listeners of aCacheEntryActivatedEventevent.- Specified by:
notifyCacheEntryActivatedin interfaceCacheNotifier<K,V>
-
notifyCacheEntryPassivated
public CompletionStage<Void> notifyCacheEntryPassivated(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) Description copied from interface:CacheNotifierNotifies all registered listeners of aCacheEntryPassivatedEventevent.- Specified by:
notifyCacheEntryPassivatedin interfaceCacheNotifier<K,V>
-
notifyTransactionCompleted
public CompletionStage<Void> notifyTransactionCompleted(GlobalTransaction transaction, boolean successful, InvocationContext ctx) Description copied from interface:CacheNotifierNotifies all registered listeners of a transaction completion event.- Specified by:
notifyTransactionCompletedin 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:CacheNotifierNotifies all registered listeners of a transaction registration event.- Specified by:
notifyTransactionRegisteredin interfaceCacheNotifier<K,V> - Parameters:
globalTransaction-
-
notifyDataRehashed
public CompletionStage<Void> notifyDataRehashed(ConsistentHash oldCH, ConsistentHash newCH, ConsistentHash unionCH, int newTopologyId, boolean pre) - Specified by:
notifyDataRehashedin interfaceCacheNotifier<K,V>
-
notifyTopologyChanged
public CompletionStage<Void> notifyTopologyChanged(CacheTopology oldTopology, CacheTopology newTopology, int newTopologyId, boolean pre) - Specified by:
notifyTopologyChangedin interfaceCacheNotifier<K,V>
-
notifyPartitionStatusChanged
- Specified by:
notifyPartitionStatusChangedin interfaceCacheNotifier<K,V>
-
notifyPersistenceAvailabilityChanged
- Specified by:
notifyPersistenceAvailabilityChangedin interfaceCacheNotifier<K,V>
-
notifyClusterListeners
public CompletionStage<Void> notifyClusterListeners(Collection<ClusterEvent<K, V>> events, UUID uuid) Description copied from interface:ClusterCacheNotifierMethod 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:
notifyClusterListenersin interfaceClusterCacheNotifier<K,V> - Parameters:
events-uuid-
-
retrieveClusterListenerCallablesToInstall
public Collection<ClusterListenerReplicateCallable<K,V>> retrieveClusterListenerCallablesToInstall()Description copied from interface:ClusterCacheNotifierThis 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:
retrieveClusterListenerCallablesToInstallin 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:ListenableAsynchronous version ofListenable.addListener(Object)- Specified by:
addListenerAsyncin 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:ClassLoaderAwareListenableAsynchronous version ofClassLoaderAwareListenable.addListener(Object, ClassLoader)- Specified by:
addListenerAsyncin 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 and identifier) which can be used after this method is completed to see what values were used in the addition of this listener- Specified by:
addListenerAsyncin interfaceClassLoaderAwareFilteringListenable<K,V>
-
getListenerCollectionForAnnotation
public List<CacheEntryListenerInvocation<K,V>> getListenerCollectionForAnnotation(Class<? extends Annotation> annotation) - Overrides:
getListenerCollectionForAnnotationin 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:FilteringListenableAsynchronous version ofFilteringListenable.addListener(Object, CacheEventFilter, CacheEventConverter)- Specified by:
addListenerAsyncin interfaceFilteringListenable<K,V> - Type Parameters:
C-- Parameters:
listener- listener to add, must not be nullfilter-converter-- 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:FilteringListenableAsynchronous version ofFilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)- Specified by:
addFilteredListenerAsyncin 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:FilteringListenableAsynchronous version ofFilteringListenable.addStorageFormatFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)- Specified by:
addStorageFormatFilteredListenerAsyncin 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:
addListenerAsyncin 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:
addFilteredListenerAsyncin interfaceDataConversionAwareListenable<K,V>
-
clusterListenerOnPrimaryOnly
protected boolean clusterListenerOnPrimaryOnly() -
removeListenerAsync
Description copied from interface:ListenableAsynchronous version ofListenable.removeListener(Object)- Specified by:
removeListenerAsyncin interfaceListenable- Specified by:
removeListenerAsyncin 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:
removeListenerInvocationin classAbstractListenerImpl<Event<K,V>, CacheEntryListenerInvocation<K, V>>
-