Package gov.usgs.earthquake.distribution
Class NotificationIndexCleanup
- java.lang.Object
-
- gov.usgs.earthquake.distribution.NotificationIndexCleanup
-
- All Implemented Interfaces:
java.lang.Runnable
public class NotificationIndexCleanup extends java.lang.Object implements java.lang.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 Classes Modifier and Type Class Description static interface
NotificationIndexCleanup.Listener
Interface for cleanup listeners to take additional steps before a notification is removed.
-
Field Summary
Fields Modifier and Type Field Description java.lang.Thread
cleanupThread
NotificationIndex
index
NotificationIndexCleanup.Listener
listener
java.lang.Object
syncObject
-
Constructor Summary
Constructors Constructor Description NotificationIndexCleanup(NotificationIndex index, NotificationIndexCleanup.Listener listener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
run()
Notification cleanup thread loop.void
shutdown()
Stop cleanup process.void
startup()
Start cleanup process.void
wakeUp()
Wake up the background thread if it is waiting.
-
-
-
Field Detail
-
index
public final NotificationIndex index
-
listener
public final NotificationIndexCleanup.Listener listener
-
syncObject
public final java.lang.Object syncObject
-
cleanupThread
public java.lang.Thread cleanupThread
-
-
Constructor Detail
-
NotificationIndexCleanup
public NotificationIndexCleanup(NotificationIndex index, NotificationIndexCleanup.Listener listener)
-
-
Method Detail
-
run
public void run()
Notification cleanup thread loop. This method blocks and should probably not be called by you.- Specified by:
run
in interfacejava.lang.Runnable
-
startup
public void startup() throws java.lang.Exception
Start cleanup process.- Throws:
java.lang.Exception
-
shutdown
public void shutdown() throws java.lang.Exception
Stop cleanup process.- Throws:
java.lang.Exception
-
wakeUp
public void wakeUp()
Wake up the background thread if it is waiting.
-
-