Package gov.usgs.earthquake.distribution
Class FutureListenerNotifier
- java.lang.Object
-
- gov.usgs.util.DefaultConfigurable
-
- gov.usgs.earthquake.distribution.ExecutorListenerNotifier
-
- gov.usgs.earthquake.distribution.FutureListenerNotifier
-
- All Implemented Interfaces:
ListenerNotifier
,Configurable
public class FutureListenerNotifier extends ExecutorListenerNotifier
FutureListenerNotifier is similar to ExecutorListenerNotifier, but uses Futures with an ExecutorService to implement timeouts instead of Timers. backgroundService is an unbounded executor, but will execute only as many threads are allowed by listener executors since listener executors submit tasks to the backgroundService and wait on the future. This ends up being more efficient because the threads where jobs execute are cached, instead of a new Timer thread created for each task.
-
-
Field Summary
-
Fields inherited from class gov.usgs.earthquake.distribution.ExecutorListenerNotifier
acceptBeforeQueuing, notificationListeners, retryTimer, throttleStartThreshold, throttleStopThreshold, throttleWaitInterval
-
-
Constructor Summary
Constructors Constructor Description FutureListenerNotifier(DefaultNotificationReceiver receiver)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
queueNotification(NotificationListener listener, NotificationEvent event)
void
shutdown()
Stop any processing/background threads.void
startup()
Start any processing/background threads.-
Methods inherited from class gov.usgs.earthquake.distribution.ExecutorListenerNotifier
addNotificationListener, getExecutors, getMaxQueueSize, getReceiver, getStatus, getThrottleStartThreshold, getThrottleStopThreshold, getThrottleWaitInterval, notifyListeners, notifyListeners, removeNotificationListener, setReceiver, setThrottleStartThreshold, setThrottleStopThreshold, setThrottleWaitInterval, throttleQueues, throttleQueues
-
Methods inherited from class gov.usgs.util.DefaultConfigurable
configure, getName, setName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.usgs.util.Configurable
configure, getName, setName
-
-
-
-
Constructor Detail
-
FutureListenerNotifier
public FutureListenerNotifier(DefaultNotificationReceiver receiver)
Constructor- Parameters:
receiver
- DefaultNotificationReceiver
-
-
Method Detail
-
queueNotification
protected void queueNotification(NotificationListener listener, NotificationEvent event)
- Overrides:
queueNotification
in classExecutorListenerNotifier
- Parameters:
listener
- NotificationListenerevent
- NotificationEvent
-
shutdown
public void shutdown() throws java.lang.Exception
Description copied from class:DefaultConfigurable
Stop any processing/background threads.- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in classExecutorListenerNotifier
- Throws:
java.lang.Exception
- if exceptions occur while starting.
-
startup
public void startup() throws java.lang.Exception
Description copied from class:DefaultConfigurable
Start any processing/background threads.- Specified by:
startup
in interfaceConfigurable
- Overrides:
startup
in classExecutorListenerNotifier
- Throws:
java.lang.Exception
- if exceptions occur while starting.
-
-