Package gov.usgs.earthquake.indexer
Class ExternalIndexerListener
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.product.AbstractListener
gov.usgs.earthquake.indexer.DefaultIndexerListener
gov.usgs.earthquake.indexer.ExternalIndexerListener
- All Implemented Interfaces:
IndexerListener,Configurable
- Direct Known Subclasses:
ExternalPreferredListener
ExternalIndexerListener triggers external, non-Java listener processes.
Provides a translation to a command-line interface for the product indexer to
speak with external, non-Java listeners.
As a child-class of the AbstractListener, this also accepts the following
configration parameters:
- command
- (Required) The command to execute. This must be an executable command and may include arguments. Any product-specific arguments are appended at the end of command.
- storage
- (Required) A directory used to store all products. Each product is extracted into a separate directory within this directory and is referenced by the --directory=/path/to/directory argument when command is executed.
- processUnassociated
- (Optional, Default = false) Whether or not to process unassociated products. Valid values are "true" and "false".
- processPreferredOnly
- (Optional, Default = false) Whether or not to process only preferred products of the type accepted by this listener. Valid values are "true" and "false".
- autoArchive
- (Optional, Default = false) Whether or not to archive products from storage when they are archived by the indexer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault state for auto archivestatic final StringConfiguration parameter for autoArchive.static final StringConfiguration parameter for command.static final StringArgument for event actionstatic final StringArgument for event idsstatic final StringArgument for preferred depthstatic final StringArgument for preferred eventsourcestatic final StringArgument for preferred eventsourcecodestatic final StringArgument for preferred event idstatic final StringArgument for preferred latitudestatic final StringArgument for preferred longitudestatic final StringArgument for preferred magnitudestatic final StringArgument for preferred eventitmestatic final StringArgument used to pass signature to external process.static final StringShort circuit to directly configure storage directory.static final StringConfiguration parameter for storage directory product.Fields 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
ConstructorsConstructorDescriptionConstruct a new ExternalIndexerListener object The listener must be configured with a FileProductStorage and a command to function. -
Method Summary
Modifier and TypeMethodDescriptionvoidConfigure an ExternalNotificationListener using a Config object.getEventArguments(Event event) Get command line arguments for an event.getProductSummaryArguments(ProductSummary summary) Get command line arguments for a product summary.getProductSummaryCommand(Event event, ProductSummary summary) Get the command for a specific event and summary.getProductSummaryCommand(IndexerEvent change, IndexerChange indexerChange) Get the product command and add the indexer arguments to it.booleanvoidonIndexerEvent(IndexerEvent change) This method is called when the indexer makes a change to the ProductIndex.voidrunProductCommand(String command, Product product) Run a product command.voidsetAutoArchive(boolean autoArchive) voidsetCommand(String command) voidsetStorage(FileProductStorage storage) voidshutdown()Called when client is shutting down.voidstartup()Called after client has been configured and should begin processing.storeProduct(Product product) Store product associated with the change.Methods 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
-
EVENT_ACTION_ARGUMENT
Argument for event action- See Also:
-
EVENT_IDS_ARGUMENT
Argument for event ids- See Also:
-
PREFERRED_ID_ARGUMENT
Argument for preferred event id- See Also:
-
PREFERRED_EVENTSOURCE_ARGUMENT
Argument for preferred eventsource- See Also:
-
PREFERRED_EVENTSOURCECODE_ARGUMENT
Argument for preferred eventsourcecode- See Also:
-
PREFERRED_MAGNITUDE_ARGUMENT
Argument for preferred magnitude- See Also:
-
PREFERRED_LONGITUDE_ARGUMENT
Argument for preferred longitude- See Also:
-
PREFERRED_LATITUDE_ARGUMENT
Argument for preferred latitude- See Also:
-
PREFERRED_DEPTH_ARGUMENT
Argument for preferred depth- See Also:
-
PREFERRED_ORIGIN_TIME_ARGUMENT
Argument for preferred eventitme- See Also:
-
STORAGE_NAME_PROPERTY
Configuration parameter for storage directory product.- See Also:
-
STORAGE_DIRECTORY_PROPERTY
Short circuit to directly configure storage directory.- See Also:
-
COMMAND_PROPERTY
Configuration parameter for command.- See Also:
-
AUTO_ARCHIVE_PROPERTY
Configuration parameter for autoArchive.- See Also:
-
AUTO_ARCHIVE_DEFAULT
Default state for auto archive- See Also:
-
SIGNATURE_ARGUMENT
Argument used to pass signature to external process.- See Also:
-
-
Constructor Details
-
ExternalIndexerListener
public ExternalIndexerListener()Construct a new ExternalIndexerListener object The listener must be configured with a FileProductStorage and a command to function.
-
-
Method Details
-
onIndexerEvent
Description copied from interface:IndexerListenerThis method is called when the indexer makes a change to the ProductIndex.- Specified by:
onIndexerEventin interfaceIndexerListener- Overrides:
onIndexerEventin classDefaultIndexerListener- Parameters:
change- description of the change.- Throws:
Exception- if error occurs
-
storeProduct
Store product associated with the change.- Parameters:
product- product to be stored.- Returns:
- a new product object, read from the listener storage.
- Throws:
Exception- if error occurs
-
runProductCommand
Run a product command.- Parameters:
command- command and arguments.product- product, when set and empty content (path "") is defined, the content is provided to the command on stdin.- Throws:
Exception- if error occurs
-
getProductSummaryCommand
public String getProductSummaryCommand(IndexerEvent change, IndexerChange indexerChange) throws Exception Get the product command and add the indexer arguments to it.- Parameters:
change- The IndexerEvent received by the ExternalIndexerListenerindexerChange- The IndexerChange- Returns:
- the command to execute with its arguments as a string
- Throws:
Exception- if error occurs
-
getProductSummaryCommand
Get the command for a specific event and summary.- Parameters:
event- Specific eventsummary- Specific product summary- Returns:
- command line arguments as a string.
- Throws:
Exception- if error occurs
-
getEventArguments
Get command line arguments for an event.- Parameters:
event- the event- Returns:
- command line arguments
-
getProductSummaryArguments
Get command line arguments for a product summary.- Parameters:
summary- the product summary- Returns:
- command line arguments
- Throws:
IOException- if IO error occurs
-
configure
Configure an ExternalNotificationListener using a Config object.- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classDefaultIndexerListener- Parameters:
config- the config containing a- Throws:
Exception- if configuration exceptions occur.
-
shutdown
Called when client is shutting down.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultConfigurable- Throws:
Exception- if exceptions occur while starting.
-
startup
Called after client has been configured and should begin processing.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin classDefaultConfigurable- Throws:
Exception- if exceptions occur while starting.
-
getStorage
- Returns:
- the storage
-
setStorage
- Parameters:
storage- the storage to set
-
getCommand
- Returns:
- the command
-
setCommand
- Parameters:
command- the command to set
-
isAutoArchive
public boolean isAutoArchive()- Returns:
- the autoArchive
-
setAutoArchive
public void setAutoArchive(boolean autoArchive) - Parameters:
autoArchive- the autoArchive to set
-