Class RoundRobinListenerNotifier
- java.lang.Object
-
- gov.usgs.util.DefaultConfigurable
-
- gov.usgs.earthquake.distribution.roundrobinnotifier.RoundRobinListenerNotifier
-
- All Implemented Interfaces:
ListenerNotifier,Configurable,java.lang.Runnable
public class RoundRobinListenerNotifier extends DefaultConfigurable implements ListenerNotifier, java.lang.Runnable
Use round-robin queues to notify listeners. This attempts to prevent any one product source+type from blocking processing of notifications from other product source+type.
-
-
Constructor Summary
Constructors Constructor Description RoundRobinListenerNotifier(DefaultNotificationReceiver receiver)Create new RoundRobinListenerNotifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNotificationListener(NotificationListener listener)Add a notification listener.voidnotifyListeners(NotificationEvent event)Notify listeners.protected voidnotifyListeners(NotificationEvent event, java.util.Collection<ListenerNotifierThread> toNotify)Notify a specific list of listeners.voidremoveNotificationListener(NotificationListener listener)Remove a notification listener.protected voidrequeue()Requeue existing notifications at startup.voidrun()Run status/requeue tasks.voidshutdown()Stop the status/requeue thread.voidstartup()Start the status/requeue thread.-
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
-
RoundRobinListenerNotifier
public RoundRobinListenerNotifier(DefaultNotificationReceiver receiver)
Create new RoundRobinListenerNotifier.- Parameters:
receiver- the receiver using this notifier.
-
-
Method Detail
-
startup
public void startup() throws java.lang.ExceptionStart the status/requeue thread.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin classDefaultConfigurable- Throws:
java.lang.Exception- if exceptions occur while starting.
-
shutdown
public void shutdown()
Stop the status/requeue thread.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultConfigurable
-
addNotificationListener
public void addNotificationListener(NotificationListener listener) throws java.lang.Exception
Add a notification listener.- Specified by:
addNotificationListenerin interfaceListenerNotifier- Parameters:
listener- NotificationListener- Throws:
java.lang.Exception- if error occurs
-
removeNotificationListener
public void removeNotificationListener(NotificationListener listener) throws java.lang.Exception
Remove a notification listener.- Specified by:
removeNotificationListenerin interfaceListenerNotifier- Parameters:
listener- NotificationListener- Throws:
java.lang.Exception- if error occurs
-
notifyListeners
public void notifyListeners(NotificationEvent event) throws java.lang.Exception
Notify listeners.- Specified by:
notifyListenersin interfaceListenerNotifier- Parameters:
event- NotificationEvent- Throws:
java.lang.Exception- if error occurs
-
notifyListeners
protected void notifyListeners(NotificationEvent event, java.util.Collection<ListenerNotifierThread> toNotify) throws java.lang.Exception
Notify a specific list of listeners. Used during renotification to only notify listeners that have an index.- Parameters:
event- notification.toNotify- list of listeners to notify.- Throws:
java.lang.Exception- if error occurs
-
run
public void run()
Run status/requeue tasks.- Specified by:
runin interfacejava.lang.Runnable
-
requeue
protected void requeue() throws java.lang.ExceptionRequeue existing notifications at startup.- Throws:
java.lang.Exception- if error occurs
-
-