Class CounterManagerNotificationManager
java.lang.Object
org.infinispan.counter.impl.listener.CounterManagerNotificationManager
It manages all the caches events and handles them. Also, it handles the user-specific
CounterListener.
When a particular key is updated, its update is send to the counter, via CounterEventGenerator.generate(CounterKey, CounterValue), and the result CounterEvent is used to notify the
users CounterListener.
Also listens to topology changes in the cache to update the WeakCounter preferred keys, via TopologyChangeListener.topologyChanged().
An user's CounterListener is 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidinject(org.infinispan.util.concurrent.BlockingManager blockingManager) voidregisterCounter(org.infinispan.util.ByteString counterName, CounterEventGenerator generator, TopologyChangeListener topologyChangeListener) It registers a new counter created locally.registerCounterValueListener(org.infinispan.Cache<? extends CounterKey, CounterValue> cache) It registers the clustered cache listener if they aren't already registered.registerTopologyListener(org.infinispan.Cache<? extends CounterKey, CounterValue> cache) 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 a user'sCounterListenerfor a specific counter.voidremoveCounter(org.infinispan.util.ByteString counterName) It removes and stops sending notification to the counter.voidstop()
-
Constructor Details
-
CounterManagerNotificationManager
public CounterManagerNotificationManager()
-
-
Method Details
-
inject
public void inject(org.infinispan.util.concurrent.BlockingManager blockingManager) -
stop
public void stop() -
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 a user'sCounterListenerfor a specific counter.- Parameters:
counterName- The counter's name to listen.userListener- TheCounterListenerto be invoked.- Returns:
- The
Handlefor theCounterListener.
-
registerCounterValueListener
public CompletionStage<Void> registerCounterValueListener(org.infinispan.Cache<? extends CounterKey, CounterValue> cache) It registers the clustered cache listener if they aren't already registered.This listener receives notification when a counter's value is updated.
- Parameters:
cache- TheCacheto listen to cluster events.
-
registerTopologyListener
public CompletionStage<Void> registerTopologyListener(org.infinispan.Cache<? extends CounterKey, CounterValue> cache) It registers the topology cache listener if they aren't already registered.- Parameters:
cache- TheCacheto listen to cluster events.
-
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.
-