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 String
Default state for auto archivestatic final String
Configuration parameter for autoArchive.static final String
Configuration parameter for command.static final String
Argument for event actionstatic final String
Argument for event idsstatic final String
Argument for preferred depthstatic final String
Argument for preferred eventsourcestatic final String
Argument for preferred eventsourcecodestatic final String
Argument for preferred event idstatic final String
Argument for preferred latitudestatic final String
Argument for preferred longitudestatic final String
Argument for preferred magnitudestatic final String
Argument for preferred eventitmestatic final String
Argument used to pass signature to external process.static final String
Short circuit to directly configure storage directory.static final String
Configuration 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_PROPERTY
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
ConstructorsConstructorDescriptionConstruct a new ExternalIndexerListener object The listener must be configured with a FileProductStorage and a command to function. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Configure 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.boolean
void
onIndexerEvent
(IndexerEvent change) This method is called when the indexer makes a change to the ProductIndex.void
runProductCommand
(String command, Product product) Run a product command.void
setAutoArchive
(boolean autoArchive) void
setCommand
(String command) void
setStorage
(FileProductStorage storage) void
shutdown()
Called when client is shutting down.void
startup()
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, setProcessUnassociatedProducts
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.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:IndexerListener
This method is called when the indexer makes a change to the ProductIndex.- Specified by:
onIndexerEvent
in interfaceIndexerListener
- Overrides:
onIndexerEvent
in 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:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultIndexerListener
- Parameters:
config
- the config containing a- Throws:
Exception
- if configuration exceptions occur.
-
shutdown
Called when client is shutting down.- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in classDefaultConfigurable
- Throws:
Exception
- if exceptions occur while starting.
-
startup
Called after client has been configured and should begin processing.- Specified by:
startup
in interfaceConfigurable
- Overrides:
startup
in 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
-