Package gov.usgs.earthquake.distribution
Class NotificationIndexCleanup
java.lang.Object
gov.usgs.earthquake.distribution.NotificationIndexCleanup
- All Implemented Interfaces:
Runnable
NotificationIndexCleanup manages cleaning up expired notifications.
Uses background thread to remove expired notifications while they exist, then
uses wait/notify to pause until shutdown() or wakeUp() methods are called.
NOTE: this class does not schedule periodic cleanup, and the wakeUp() method
must be called periodically.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Interface for cleanup listeners to take additional steps before a notification is removed. -
Field Summary
FieldsModifier and TypeFieldDescriptionthread where cleanup loop runsfinal NotificationIndex
Notification Indexlistener that can take additional actions during cleanupfinal Object
object used to synchronize state access between threads -
Constructor Summary
ConstructorsConstructorDescriptionNotificationIndexCleanup
(NotificationIndex index, NotificationIndexCleanup.Listener listener) Constructor -
Method Summary
-
Field Details
-
index
Notification Index -
listener
listener that can take additional actions during cleanup -
syncObject
object used to synchronize state access between threads -
cleanupThread
thread where cleanup loop runs
-
-
Constructor Details
-
NotificationIndexCleanup
public NotificationIndexCleanup(NotificationIndex index, NotificationIndexCleanup.Listener listener) Constructor- Parameters:
index
- notificaiton indexlistener
- the listener
-
-
Method Details
-
run
public void run()Notification cleanup thread loop. This method blocks and should probably not be called by you. -
startup
Start cleanup process.- Throws:
Exception
- if clean up is already in progress
-
shutdown
Stop cleanup process.- Throws:
Exception
- if already stopped
-
wakeUp
public void wakeUp()Wake up the background thread if it is waiting.
-