Package gov.usgs.earthquake.indexer
Class ReliableIndexerListener
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.product.AbstractListener
gov.usgs.earthquake.indexer.DefaultIndexerListener
gov.usgs.earthquake.indexer.ReliableIndexerListener
- All Implemented Interfaces:
IndexerListener,Configurable,Runnable
- Direct Known Subclasses:
ExtentIndexerListener
ReliableIndexerListener listens for product changes by the indexer, then
handles the new products independently in a background thread.
This class does little more than output logs for the products it has seen; it
is designed to be extended.
Several useful methods are availble to be overridden or otherwise used:
- onBeforeProcessThreadStart
- onProcessException
- getNextProducts
- processProducts
- index
- (Required) The index to use for product querying.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final LoggerLogger objectprotected ProductIndexProduct IndexFields inherited from class gov.usgs.earthquake.indexer.DefaultIndexerListener
IGNORE_ARCHIVE_DEFAULT, IGNORE_ARCHIVE_PROPERTY, PROCESS_ONLY_WHEN_EVENT_CHANGE_DEFAULT, PROCESS_ONLY_WHEN_EVENT_CHANGE_PROPERTY, PROCESS_PREFERRED_ONLY_DEFAULT, PROCESS_PREFERRED_ONLY_PROPERTY, PROCESS_UNASSOCIATED_DEFAULT, PROCESS_UNASSOCIATED_PROPERTYFields 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 TypeMethodDescriptionvoidSets up an object on startlongGets index ID of last processed productGets the next products using the index provided in Configprotected voidRun before thread start.voidonIndexerEvent(IndexerEvent delta) Wakes thread when indexer makes changesprotected voidonProcessException(ProductSummary product, Exception e) Exception handling for product processing.protected voidException handling for product fetchvoidprocessProduct(ProductSummary product) Does a task with each productvoidrun()Thread main body.voidsetLastIndexId(long lastIndexId) Sets index ID of last processed productvoidsetProductIndex(ProductIndex productIndex) voidshutdown()Closes threadvoidstartup()Starts thread Calls onBeforeProcessThreadStart() in case subclasses want to add functionalityMethods inherited from class gov.usgs.earthquake.indexer.DefaultIndexerListener
accept, accept, getProcessOnlyPreferredProducts, getProcessUnassociatedProducts, isIgnoreArchive, isProcessOnlyWhenEventChanged, setIgnoreArchive, setProcessOnlyPreferredProducts, setProcessOnlyWhenEventChanged, setProcessUnassociatedProductsMethods 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.indexer.IndexerListener
getMaxTries, getTimeout
-
Field Details
-
LOGGER
Logger object -
productIndex
Product Index
-
-
Constructor Details
-
ReliableIndexerListener
public ReliableIndexerListener()
-
-
Method Details
-
configure
Sets up an object on start- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classDefaultIndexerListener- Parameters:
config- configuration- Throws:
Exception- if missing product index
-
onIndexerEvent
Wakes thread when indexer makes changes- Specified by:
onIndexerEventin interfaceIndexerListener- Overrides:
onIndexerEventin classDefaultIndexerListener- Parameters:
delta- Indexer Event - not used- Throws:
Exception- if something goes wrong
-
run
public void run()Thread main body. Waits until notified, then tries to get the next products and process them. -
startup
Starts thread Calls onBeforeProcessThreadStart() in case subclasses want to add functionality- Specified by:
startupin interfaceConfigurable- Overrides:
startupin classDefaultConfigurable- Throws:
Exception- if there's a thread issueException- if thread start fails
-
shutdown
Closes thread- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultConfigurable- Throws:
Exception- if there's a thread issue
-
getProductIndex
- Returns:
- ProductIndex
-
setProductIndex
- Parameters:
productIndex- to set
-
getLastIndexId
public long getLastIndexId()Gets index ID of last processed product- Returns:
- lastIndexId
-
setLastIndexId
public void setLastIndexId(long lastIndexId) Sets index ID of last processed product- Parameters:
lastIndexId- to set
-
onBeforeProcessThreadStart
Run before thread start.- Throws:
Exception- available for subclasses
-
onProductGetException
Exception handling for product fetch- Parameters:
e- the caught exception- Throws:
Exception- in case we can't handle the first exception
-
onProcessException
Exception handling for product processing.- Parameters:
product- the product that gave us the errore- the caught exception- Throws:
Exception- in case we can't handle the first exception.
-
getNextProducts
Gets the next products using the index provided in Config- Returns:
- List of product summaries
- Throws:
Exception- if we have a database issue
-
processProduct
Does a task with each product- Parameters:
product- ProductSummary to process- Throws:
Exception- available for subclasses
-