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 void
addNotificationListener(NotificationListener listener)
Add a notification listener.void
notifyListeners(NotificationEvent event)
Notify listeners.protected void
notifyListeners(NotificationEvent event, java.util.Collection<ListenerNotifierThread> toNotify)
Notify a specific list of listeners.void
removeNotificationListener(NotificationListener listener)
Remove a notification listener.protected void
requeue()
Requeue existing notifications at startup.void
run()
Run status/requeue tasks.void
shutdown()
Stop the status/requeue thread.void
startup()
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.Exception
Start the status/requeue thread.- Specified by:
startup
in interfaceConfigurable
- Overrides:
startup
in classDefaultConfigurable
- Throws:
java.lang.Exception
- if exceptions occur while starting.
-
shutdown
public void shutdown()
Stop the status/requeue thread.- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in classDefaultConfigurable
-
addNotificationListener
public void addNotificationListener(NotificationListener listener) throws java.lang.Exception
Add a notification listener.- Specified by:
addNotificationListener
in 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:
removeNotificationListener
in 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:
notifyListeners
in 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:
run
in interfacejava.lang.Runnable
-
requeue
protected void requeue() throws java.lang.Exception
Requeue existing notifications at startup.- Throws:
java.lang.Exception
- if error occurs
-
-