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
public class DefaultNotificationSender extends DefaultNotificationListener
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
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_PRODUCT_STORAGE_MAX_AGEproperty for max age of product in storage.static java.lang.StringPRODUCT_STORAGE_MAX_AGE_PROPERTYProperty referencing the length of time products should be held in storagestatic java.lang.StringPRODUCT_STORAGE_PROPERTYProperty referencing product storage object to useprotected URLProductStorageproductStorageVariable for URL productStorageprotected longproductStorageMaxAgeVariable for long productStorageMaxAgestatic java.lang.StringSERVER_HOST_PROPERTYProperty referencing the server hoststatic java.lang.StringSERVER_PORT_PROPERTYProperty referencing the server portprotected java.lang.StringserverHostVariable for String serverHostprotected java.lang.StringserverPortVariable for String serverPort-
Fields 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 Constructor Description DefaultNotificationSender()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Config config)Configures based on configuration section.URLProductStoragegetProductStorage()longgetProductStorageMaxAge()java.lang.StringgetServerHost()java.lang.StringgetServerPort()protected 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 expiresvoidonProduct(Product product)Called 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(java.lang.String serverHost)voidsetServerPort(java.lang.String serverPort)voidshutdown()Shut down storagevoidstartup()Start up storage-
Methods 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 Detail
-
SERVER_HOST_PROPERTY
public static final java.lang.String SERVER_HOST_PROPERTY
Property referencing the server host- See Also:
- Constant Field Values
-
SERVER_PORT_PROPERTY
public static final java.lang.String SERVER_PORT_PROPERTY
Property referencing the server port- See Also:
- Constant Field Values
-
PRODUCT_STORAGE_PROPERTY
public static final java.lang.String PRODUCT_STORAGE_PROPERTY
Property referencing product storage object to use- See Also:
- Constant Field Values
-
PRODUCT_STORAGE_MAX_AGE_PROPERTY
public static final java.lang.String PRODUCT_STORAGE_MAX_AGE_PROPERTY
Property referencing the length of time products should be held in storage- See Also:
- Constant Field Values
-
DEFAULT_PRODUCT_STORAGE_MAX_AGE
public static final java.lang.String DEFAULT_PRODUCT_STORAGE_MAX_AGE
property for max age of product in storage. 7000 days?- See Also:
- Constant Field Values
-
serverHost
protected java.lang.String serverHost
Variable for String serverHost
-
serverPort
protected java.lang.String serverPort
Variable for String serverPort
-
productStorage
protected URLProductStorage productStorage
Variable for URL productStorage
-
productStorageMaxAge
protected long productStorageMaxAge
Variable for long productStorageMaxAge
-
-
Method Detail
-
configure
public void configure(Config config) throws java.lang.Exception
Configures based on configuration section.- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classDefaultNotificationListener- Parameters:
config- The config- Throws:
java.lang.Exception- if something goes wrong
-
onProduct
public void onProduct(Product product) throws java.lang.Exception
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:
java.lang.Exception- if something goes wrong
-
onBeforeProcessNotification
protected boolean onBeforeProcessNotification(Notification notification) throws java.lang.Exception
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:
java.lang.Exception- if something goes wrong
-
onAfterProcessNotification
protected void onAfterProcessNotification(Notification notification)
Description copied from class:DefaultNotificationListenerCalled when this listener has successfully processed a notification.- Overrides:
onAfterProcessNotificationin classDefaultNotificationListener- Parameters:
notification- notification that was processed.
-
onExpiredNotification
public void onExpiredNotification(Notification notification) throws java.lang.Exception
Called when a notification expires- Specified by:
onExpiredNotificationin interfaceNotificationIndexCleanup.Listener- Overrides:
onExpiredNotificationin classDefaultNotificationListener- Parameters:
notification- The expired notification- Throws:
java.lang.Exception- if something goes wrong
-
sendNotification
protected void sendNotification(Notification notification) throws java.lang.Exception
Utility method to do the actual notification sending. Should be overridden by subclasses.- Parameters:
notification- The notification to send- Throws:
java.lang.Exception- if something goes wrong
-
startup
public void startup() throws java.lang.ExceptionStart up storage- Specified by:
startupin interfaceConfigurable- Overrides:
startupin classDefaultNotificationListener- Throws:
java.lang.Exception- if something goes wrong
-
shutdown
public void shutdown() throws java.lang.ExceptionShut down storage- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultNotificationListener- Throws:
java.lang.Exception- if something goes wrong
-
getServerHost
public java.lang.String getServerHost()
- Returns:
- serverHost
-
setServerHost
public void setServerHost(java.lang.String serverHost)
- Parameters:
serverHost- string to set
-
getServerPort
public java.lang.String getServerPort()
- Returns:
- serverPort
-
setServerPort
public void setServerPort(java.lang.String serverPort)
- Parameters:
serverPort- string to set
-
getProductStorage
public URLProductStorage getProductStorage()
- Returns:
- productStorage
-
setProductStorage
public void setProductStorage(URLProductStorage productStorage)
- Parameters:
productStorage- URLProductStorage to set
-
getProductStorageMaxAge
public long getProductStorageMaxAge()
- Returns:
- productStorageMaxAge
-
setProductStorageMaxAge
public void setProductStorageMaxAge(long productStorageMaxAge)
- Parameters:
productStorageMaxAge- long to set
-
-