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 voidqueueNotification(NotificationListener listener, NotificationEvent event)voidshutdown()Stop any processing/background threads.voidstartup()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:
queueNotificationin classExecutorListenerNotifier- Parameters:
listener- NotificationListenerevent- NotificationEvent
-
shutdown
public void shutdown() throws java.lang.ExceptionDescription copied from class:DefaultConfigurableStop any processing/background threads.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classExecutorListenerNotifier- Throws:
java.lang.Exception- if exceptions occur while starting.
-
startup
public void startup() throws java.lang.ExceptionDescription copied from class:DefaultConfigurableStart any processing/background threads.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin classExecutorListenerNotifier- Throws:
java.lang.Exception- if exceptions occur while starting.
-
-