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 final 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 Classes Modifier and Type Class Description protected static classCacheNotifierImpl.BaseCacheEntryListenerInvocation<K,V>protected classCacheNotifierImpl.CacheInvocationBuilderprotected static classCacheNotifierImpl.ClusteredListenerInvocation<K,V>This class is to be used with cluster listener invocations only when they have included current state.protected classCacheNotifierImpl.DelegatingCacheInvocationBuilder-
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 Constructor Description CacheNotifierImpl()
-
Method Summary
-
Methods inherited from class org.infinispan.notifications.impl.AbstractListenerImpl
canApply, composeStageIfNeeded, findListenerCallbacks, getListeners, hasListener, 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
-
-
-
-
Method Detail
-
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 Log getLog()
- Specified by:
getLogin classAbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
-
getAllowedMethodAnnotations
protected Map<Class<? extends Annotation>,Class<?>> getAllowedMethodAnnotations(Listener l)
- Specified by:
getAllowedMethodAnnotationsin classAbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
-
suspendIfNeeded
protected final Transaction suspendIfNeeded()
- Specified by:
suspendIfNeededin classAbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
-
resumeIfNeeded
protected final void resumeIfNeeded(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>
-
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
public CompletionStage<Void> notifyPartitionStatusChanged(AvailabilityMode mode, boolean pre)
- Specified by:
notifyPartitionStatusChangedin interfaceCacheNotifier<K,V>
-
notifyPersistenceAvailabilityChanged
public CompletionStage<Void> notifyPersistenceAvailabilityChanged(boolean available)
- 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>
-
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
public CompletionStage<Void> addListenerAsync(Object listener)
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
public CompletionStage<Void> addListenerAsync(Object listener, ClassLoader classLoader)
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 & 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>- 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: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>
-
removeListenerAsync
public CompletionStage<Void> removeListenerAsync(Object listener)
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>>
-
-