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
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 Stringproperty for max age of product in storage.static final StringProperty referencing the length of time products should be held in storagestatic final StringProperty referencing product storage object to useprotected URLProductStorageVariable for URL productStorageprotected longVariable for long productStorageMaxAgestatic final StringProperty referencing the server hoststatic final StringProperty referencing the server portprotected StringVariable for String serverHostprotected StringVariable 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_DUPLICATESFields 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 TypeMethodDescriptionvoidConfigures based on configuration section.longprotected voidonAfterProcessNotification(Notification notification) Called when this listener has successfully processed a notification.protected booleanonBeforeProcessNotification(Notification notification) Called just before this listener processes a notification.voidonExpiredNotification(Notification notification) Called when a notification expiresvoidCalled on receipt of a new product.protected voidsendNotification(Notification notification) Utility method to do the actual notification sending.voidsetProductStorage(URLProductStorage productStorage) voidsetProductStorageMaxAge(long productStorageMaxAge) voidsetServerHost(String serverHost) voidsetServerPort(String serverPort) voidshutdown()Shut down storagevoidstartup()Start up storageMethods inherited from class gov.usgs.earthquake.distribution.DefaultNotificationListener
cleanup, getCleanupInterval, getConcurrentProducts, getExcludePaths, getIncludePaths, getNotificationIndex, isProcessDuplicates, onBeforeProcessProduct, onNotification, setCleanupInterval, setConcurrentProducts, setNotificationIndex, setProcessDuplicatesMethods 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, setTimeoutMethods 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, setNameMethods 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:
configurein interfaceConfigurable- Overrides:
configurein 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:
onProductin 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:
onBeforeProcessNotificationin 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:DefaultNotificationListenerCalled when this listener has successfully processed a notification.- Overrides:
onAfterProcessNotificationin classDefaultNotificationListener- Parameters:
notification- notification that was processed.
-
onExpiredNotification
Called when a notification expires- Specified by:
onExpiredNotificationin interfaceNotificationIndexCleanup.Listener- Overrides:
onExpiredNotificationin 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:
startupin interfaceConfigurable- Overrides:
startupin classDefaultNotificationListener- Throws:
Exception- if something goes wrong
-
shutdown
Shut down storage- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin 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
-