Class NotificationIndexCleanup

java.lang.Object
gov.usgs.earthquake.distribution.NotificationIndexCleanup
All Implemented Interfaces:
Runnable

public class NotificationIndexCleanup extends Object implements 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.
  • Field Details

    • index

      public final NotificationIndex index
      Notification Index
    • listener

      public final NotificationIndexCleanup.Listener listener
      listener that can take additional actions during cleanup
    • syncObject

      public final Object syncObject
      object used to synchronize state access between threads
    • cleanupThread

      public Thread cleanupThread
      thread where cleanup loop runs
  • Constructor Details

  • Method Details

    • run

      public void run()
      Notification cleanup thread loop. This method blocks and should probably not be called by you.
      Specified by:
      run in interface Runnable
    • startup

      public void startup() throws Exception
      Start cleanup process.
      Throws:
      Exception - if clean up is already in progress
    • shutdown

      public void shutdown() throws Exception
      Stop cleanup process.
      Throws:
      Exception - if already stopped
    • wakeUp

      public void wakeUp()
      Wake up the background thread if it is waiting.