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.String
DEFAULT_PRODUCT_STORAGE_MAX_AGE
property for max age of product in storage.static java.lang.String
PRODUCT_STORAGE_MAX_AGE_PROPERTY
Property referencing the length of time products should be held in storagestatic java.lang.String
PRODUCT_STORAGE_PROPERTY
Property referencing product storage object to useprotected URLProductStorage
productStorage
Variable for URL productStorageprotected long
productStorageMaxAge
Variable for long productStorageMaxAgestatic java.lang.String
SERVER_HOST_PROPERTY
Property referencing the server hoststatic java.lang.String
SERVER_PORT_PROPERTY
Property referencing the server portprotected java.lang.String
serverHost
Variable for String serverHostprotected java.lang.String
serverPort
Variable 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 void
configure(Config config)
Configures based on configuration section.URLProductStorage
getProductStorage()
long
getProductStorageMaxAge()
java.lang.String
getServerHost()
java.lang.String
getServerPort()
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
onProduct(Product product)
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(java.lang.String serverHost)
void
setServerPort(java.lang.String serverPort)
void
shutdown()
Shut down storagevoid
startup()
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:
configure
in interfaceConfigurable
- Overrides:
configure
in 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:
onProduct
in 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:
onBeforeProcessNotification
in 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:DefaultNotificationListener
Called when this listener has successfully processed a notification.- Overrides:
onAfterProcessNotification
in classDefaultNotificationListener
- Parameters:
notification
- notification that was processed.
-
onExpiredNotification
public void onExpiredNotification(Notification notification) throws java.lang.Exception
Called when a notification expires- Specified by:
onExpiredNotification
in interfaceNotificationIndexCleanup.Listener
- Overrides:
onExpiredNotification
in 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.Exception
Start up storage- Specified by:
startup
in interfaceConfigurable
- Overrides:
startup
in classDefaultNotificationListener
- Throws:
java.lang.Exception
- if something goes wrong
-
shutdown
public void shutdown() throws java.lang.Exception
Shut down storage- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in 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
-
-