Class CounterManagerNotificationManager
- java.lang.Object
-
- org.infinispan.counter.impl.listener.CounterManagerNotificationManager
-
public class CounterManagerNotificationManager extends Object
It manages all the caches events and handles them. Also, it handles the user-specificCounterListener.When a particular key is updated, its update is send to the counter, via
CounterEventGenerator.generate(CounterKey, CounterValue), and the resultCounterEventis used to notify the usersCounterListener.Also listens to topology changes in the cache to update the
WeakCounterpreferred keys, viaTopologyChangeListener.topologyChanged().An user's
CounterListeneris invoked in sequence (i.e. only the next update is invoked when the previous one is handled) but it can be invoked in different thread.- Since:
- 9.2
- Author:
- Pedro Ruivo
-
-
Constructor Summary
Constructors Constructor Description CounterManagerNotificationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidregisterCounter(org.infinispan.util.ByteString counterName, CounterEventGenerator generator, TopologyChangeListener topologyChangeListener)It registers a new counter created locally.voidregisterCounterValueListener()It registers the clustered cache listener if they aren't already registered.voidregisterTopologyListener()It registers the topology cache listener if they aren't already registered.<T extends org.infinispan.counter.api.CounterListener>
org.infinispan.counter.api.Handle<T>registerUserListener(org.infinispan.util.ByteString counterName, T userListener)It registers an user'sCounterListenerfor a specific counter.voidremoveCounter(org.infinispan.util.ByteString counterName)It removes and stops sending notification to the counter.voidsetCache(org.infinispan.Cache<CounterKey,CounterValue> cache)voidstop()voiduseBlockingManager(org.infinispan.util.concurrent.BlockingManager blockingManager)The blockingManager to use where the user'sCounterListeneris invoked.
-
-
-
Method Detail
-
useBlockingManager
public void useBlockingManager(org.infinispan.util.concurrent.BlockingManager blockingManager)
The blockingManager to use where the user'sCounterListeneris invoked.- Parameters:
blockingManager- TheBlockingManagerto use.
-
registerCounter
public void registerCounter(org.infinispan.util.ByteString counterName, CounterEventGenerator generator, TopologyChangeListener topologyChangeListener)It registers a new counter created locally.- Parameters:
counterName- The counter's name.generator- The counter'sCounterEventgenerator.topologyChangeListener- The counter's listener to topology change. It can benull.- Throws:
IllegalStateException- If the counter with that name is already registered.
-
registerUserListener
public <T extends org.infinispan.counter.api.CounterListener> org.infinispan.counter.api.Handle<T> registerUserListener(org.infinispan.util.ByteString counterName, T userListener)It registers an user'sCounterListenerfor a specific counter.- Parameters:
counterName- The counter's name to listen.userListener- TheCounterListenerto be invoked.- Returns:
- The
Handlefor theCounterListener.
-
setCache
public void setCache(org.infinispan.Cache<CounterKey,CounterValue> cache)
-
registerCounterValueListener
public void registerCounterValueListener()
It registers the clustered cache listener if they aren't already registered.This listener receives notification when a counter's value is updated.
-
registerTopologyListener
public void registerTopologyListener()
It registers the topology cache listener if they aren't already registered.
-
stop
public void stop()
-
removeCounter
public void removeCounter(org.infinispan.util.ByteString counterName)
It removes and stops sending notification to the counter.- Parameters:
counterName- The counter's name to remove.
-
-