Package gov.usgs.earthquake.aws
Class FileTrackingListener
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.aws.FileTrackingListener
- All Implemented Interfaces:
NotificationListener,Configurable
This class is a stop-gap to store file-based tracking information in a
TrackingIndex.
It implements the NotificationListener interface so it can hook into
startup/shutdown lifecycle calls used by ProductClient. Listeners are started
before and shutdown after Receivers, and can put a tracking file in place
before the receiver starts and save its state after a receiver stops.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileTrackingListener constructorFileTrackingListener(File trackingFile, TrackingIndex trackingIndex) Initializable FileTrackingListener -
Method Summary
Modifier and TypeMethodDescriptionvoidProcess configuration settings.intA NotificationReceiver that generates a NotificationEvent will attempt to deliver the event up to this many times, if the listener throws an Exception while processing.longA NotificationListener has this many milliseconds to process a notification before being interrupted.Getter for trackingFileGetter for trackingIndexvoidRead trackingIndex and write trackingFile.voidonNotification(NotificationEvent event) Notification Listener method stubs.voidsetTrackingFile(File trackingFile) Setter for trackingFilevoidsetTrackingIndex(TrackingIndex trackingIndex) Setter for trackingIndexvoidshutdown()When shutting down, call storeTrackingFile to read from file on disk.voidstartup()When starting, call loadTrackingFile to create/update file on disk.voidRead trackingFile and write into trackingIndex.Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface gov.usgs.util.Configurable
getName, setName
-
Field Details
-
TRACKING_INDEX_PROPERTY
Tracking index property- See Also:
-
TRACKING_INDEX_FILE_PROPERTY
Tracking index file property- See Also:
-
TRACKING_FILE_PROEPRTY
Tracking file property- See Also:
-
-
Constructor Details
-
FileTrackingListener
public FileTrackingListener()FileTrackingListener constructor -
FileTrackingListener
Initializable FileTrackingListener- Parameters:
trackingFile- file to be traackedtrackingIndex- Index where contents are stored
-
-
Method Details
-
getTrackingFile
Getter for trackingFile- Returns:
- trackingFile
-
setTrackingFile
Setter for trackingFile- Parameters:
trackingFile- File to be tracked
-
getTrackingIndex
Getter for trackingIndex- Returns:
- trackingIndex
-
setTrackingIndex
Setter for trackingIndex- Parameters:
trackingIndex- Index where contents are stored
-
configure
Description copied from class:DefaultConfigurableProcess configuration settings. Called before startup().- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classDefaultConfigurable- Parameters:
config- the Config object with settings.- Throws:
Exception- if configuration exceptions occur.
-
startup
When starting, call loadTrackingFile to create/update file on disk.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin classDefaultConfigurable- Throws:
Exception- if exceptions occur while starting.
-
shutdown
When shutting down, call storeTrackingFile to read from file on disk.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultConfigurable- Throws:
Exception- if exceptions occur while starting.
-
loadTrackingFile
Read trackingIndex and write trackingFile.- Throws:
Exception- Exception
-
storeTrackingFile
Read trackingFile and write into trackingIndex.- Throws:
Exception- Exception
-
onNotification
Notification Listener method stubs. These are used only to gain access to lifecycle hooks above.- Specified by:
onNotificationin interfaceNotificationListener- Parameters:
event- the event corresponding to the notification that is available.- Throws:
ContinuableListenerException- if redelivery should be attempted (depending on what getAttemptCount() returns).Exception- See Also:
-
getMaxTries
public int getMaxTries()Description copied from interface:NotificationListenerA NotificationReceiver that generates a NotificationEvent will attempt to deliver the event up to this many times, if the listener throws an Exception while processing.- Specified by:
getMaxTriesin interfaceNotificationListener- Returns:
- A value of 1 or less means do not attempt more than once.
-
getTimeout
public long getTimeout()Description copied from interface:NotificationListenerA NotificationListener has this many milliseconds to process a notification before being interrupted.- Specified by:
getTimeoutin interfaceNotificationListener- Returns:
- number of milliseconds before timing out. A value of 0 or less means never time out.
-