Package gov.usgs.earthquake.distribution
Class DefaultNotificationSender
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.product.AbstractListener
gov.usgs.earthquake.distribution.DefaultNotificationListener
gov.usgs.earthquake.distribution.DefaultNotificationSender
- All Implemented Interfaces:
NotificationIndexCleanup.Listener
,NotificationListener
,Configurable
- Direct Known Subclasses:
EIDSNotificationSender
,NATSStreamingNotificationSender
The base class for all Notification senders.
The DefaultNotificationSender references a general need to send
notifications. It extends DefaultNotificationListener to allow forwarding of
products from any subclass of DefaultNotificationReceiver. *
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
property for max age of product in storage.static final String
Property referencing the length of time products should be held in storagestatic final String
Property referencing product storage object to useprotected URLProductStorage
Variable for URL productStorageprotected long
Variable for long productStorageMaxAgestatic final String
Property referencing the server hoststatic final String
Property referencing the server portprotected String
Variable for String serverHostprotected String
Variable for String serverPortFields inherited from class gov.usgs.earthquake.distribution.DefaultNotificationListener
CLEANUP_INTERVAL_PROPERTY, CONCURRENT_PRODUCTS_PROPERTY, DEFAULT_CLEANUP_INTERVAL, DEFAULT_CONCURRENT_PRODUCTS, DEFAULT_PROCESS_DUPLICATES, EXCLUDE_PATHS_PROPERTY, INCLUDE_PATHS_PROPERTY, INDEX_FILE_PROPERTY, NOTIFICATION_INDEX_PROPERTY, PROCESS_DUPLICATES
Fields inherited from class gov.usgs.earthquake.product.AbstractListener
ATTEMPT_COUNT_PROPERTY, DEFAULT_ATTEMPT_COUNT, DEFAULT_RETRY_DELAY, DEFAULT_TIMEOUT, EXCLUDE_SOURCES_PROPERTY, EXCLUDE_TYPES_PROPERTY, INCLUDE_ACTUALS_PROPERTY, INCLUDE_DEVELOPMENTS_PROPERTY, INCLUDE_INTERNALS_PROPERTY, INCLUDE_SCENARIOS_PROPERTY, INCLUDE_SOURCES_PROPERTY, INCLUDE_TESTS_PROPERTY, INCLUDE_TYPES_PROPERTY, MAX_TRIES_PROPERTY, RETRY_DELAY_PROPERTY, TIMEOUT_PROPERTY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Configures based on configuration section.long
protected void
onAfterProcessNotification
(Notification notification) Called when this listener has successfully processed a notification.protected boolean
onBeforeProcessNotification
(Notification notification) Called just before this listener processes a notification.void
onExpiredNotification
(Notification notification) Called when a notification expiresvoid
Called on receipt of a new product.protected void
sendNotification
(Notification notification) Utility method to do the actual notification sending.void
setProductStorage
(URLProductStorage productStorage) void
setProductStorageMaxAge
(long productStorageMaxAge) void
setServerHost
(String serverHost) void
setServerPort
(String serverPort) void
shutdown()
Shut down storagevoid
startup()
Start up storageMethods inherited from class gov.usgs.earthquake.distribution.DefaultNotificationListener
cleanup, getCleanupInterval, getConcurrentProducts, getExcludePaths, getIncludePaths, getNotificationIndex, isProcessDuplicates, onBeforeProcessProduct, onNotification, setCleanupInterval, setConcurrentProducts, setNotificationIndex, setProcessDuplicates
Methods inherited from class gov.usgs.earthquake.product.AbstractListener
accept, getExcludeSources, getExcludeTypes, getIncludeSources, getIncludeTypes, getMaxTries, getRetryDelay, getTimeout, isIncludeActuals, isIncludeDevelopments, isIncludeInternals, isIncludeScenarios, isIncludeTests, setIncludeActuals, setIncludeDevelopments, setIncludeInternals, setIncludeScenarios, setIncludeTests, setMaxTries, setRetryDelay, setTimeout
Methods inherited from class gov.usgs.util.DefaultConfigurable
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
getName, setName
Methods inherited from interface gov.usgs.earthquake.distribution.NotificationListener
getMaxTries, getTimeout
-
Field Details
-
SERVER_HOST_PROPERTY
Property referencing the server host- See Also:
-
SERVER_PORT_PROPERTY
Property referencing the server port- See Also:
-
PRODUCT_STORAGE_PROPERTY
Property referencing product storage object to use- See Also:
-
PRODUCT_STORAGE_MAX_AGE_PROPERTY
Property referencing the length of time products should be held in storage- See Also:
-
DEFAULT_PRODUCT_STORAGE_MAX_AGE
property for max age of product in storage. 7000 days?- See Also:
-
serverHost
Variable for String serverHost -
serverPort
Variable for String serverPort -
productStorage
Variable for URL productStorage -
productStorageMaxAge
protected long productStorageMaxAgeVariable for long productStorageMaxAge
-
-
Constructor Details
-
DefaultNotificationSender
public DefaultNotificationSender()
-
-
Method Details
-
configure
Configures based on configuration section.- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultNotificationListener
- Parameters:
config
- The config- Throws:
Exception
- if something goes wrong
-
onProduct
Called on receipt of a new product. Stores this product and calls sendMessage() Most of this logic was lifted from the pre-08/2019 EIDSNotificationSender class.- Overrides:
onProduct
in classDefaultNotificationListener
- Parameters:
product
- a product whose notification was accepted.- Throws:
Exception
- if something goes wrong
-
onBeforeProcessNotification
Called just before this listener processes a notification.- Overrides:
onBeforeProcessNotification
in classDefaultNotificationListener
- Parameters:
notification
- notification about to be processed.- Returns:
- true to process the notification, false to skip
- Throws:
Exception
- if something goes wrong
-
onAfterProcessNotification
Description copied from class:DefaultNotificationListener
Called when this listener has successfully processed a notification.- Overrides:
onAfterProcessNotification
in classDefaultNotificationListener
- Parameters:
notification
- notification that was processed.
-
onExpiredNotification
Called when a notification expires- Specified by:
onExpiredNotification
in interfaceNotificationIndexCleanup.Listener
- Overrides:
onExpiredNotification
in classDefaultNotificationListener
- Parameters:
notification
- The expired notification- Throws:
Exception
- if something goes wrong
-
sendNotification
Utility method to do the actual notification sending. Should be overridden by subclasses.- Parameters:
notification
- The notification to send- Throws:
Exception
- if something goes wrong
-
startup
Start up storage- Specified by:
startup
in interfaceConfigurable
- Overrides:
startup
in classDefaultNotificationListener
- Throws:
Exception
- if something goes wrong
-
shutdown
Shut down storage- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in classDefaultNotificationListener
- Throws:
Exception
- if something goes wrong
-
getServerHost
- Returns:
- serverHost
-
setServerHost
- Parameters:
serverHost
- string to set
-
getServerPort
- Returns:
- serverPort
-
setServerPort
- Parameters:
serverPort
- string to set
-
getProductStorage
- Returns:
- productStorage
-
setProductStorage
- Parameters:
productStorage
- URLProductStorage to set
-
getProductStorageMaxAge
public long getProductStorageMaxAge()- Returns:
- productStorageMaxAge
-
setProductStorageMaxAge
public void setProductStorageMaxAge(long productStorageMaxAge) - Parameters:
productStorageMaxAge
- long to set
-