Class ExternalIndexerListener

All Implemented Interfaces:
IndexerListener, Configurable
Direct Known Subclasses:
ExternalPreferredListener

public class ExternalIndexerListener extends DefaultIndexerListener
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 Details

    • EVENT_ACTION_ARGUMENT

      public static final String EVENT_ACTION_ARGUMENT
      Argument for event action
      See Also:
    • EVENT_IDS_ARGUMENT

      public static final String EVENT_IDS_ARGUMENT
      Argument for event ids
      See Also:
    • PREFERRED_ID_ARGUMENT

      public static final String PREFERRED_ID_ARGUMENT
      Argument for preferred event id
      See Also:
    • PREFERRED_EVENTSOURCE_ARGUMENT

      public static final String PREFERRED_EVENTSOURCE_ARGUMENT
      Argument for preferred eventsource
      See Also:
    • PREFERRED_EVENTSOURCECODE_ARGUMENT

      public static final String PREFERRED_EVENTSOURCECODE_ARGUMENT
      Argument for preferred eventsourcecode
      See Also:
    • PREFERRED_MAGNITUDE_ARGUMENT

      public static final String PREFERRED_MAGNITUDE_ARGUMENT
      Argument for preferred magnitude
      See Also:
    • PREFERRED_LONGITUDE_ARGUMENT

      public static final String PREFERRED_LONGITUDE_ARGUMENT
      Argument for preferred longitude
      See Also:
    • PREFERRED_LATITUDE_ARGUMENT

      public static final String PREFERRED_LATITUDE_ARGUMENT
      Argument for preferred latitude
      See Also:
    • PREFERRED_DEPTH_ARGUMENT

      public static final String PREFERRED_DEPTH_ARGUMENT
      Argument for preferred depth
      See Also:
    • PREFERRED_ORIGIN_TIME_ARGUMENT

      public static final String PREFERRED_ORIGIN_TIME_ARGUMENT
      Argument for preferred eventitme
      See Also:
    • STORAGE_NAME_PROPERTY

      public static final String STORAGE_NAME_PROPERTY
      Configuration parameter for storage directory product.
      See Also:
    • STORAGE_DIRECTORY_PROPERTY

      public static final String STORAGE_DIRECTORY_PROPERTY
      Short circuit to directly configure storage directory.
      See Also:
    • COMMAND_PROPERTY

      public static final String COMMAND_PROPERTY
      Configuration parameter for command.
      See Also:
    • AUTO_ARCHIVE_PROPERTY

      public static final String AUTO_ARCHIVE_PROPERTY
      Configuration parameter for autoArchive.
      See Also:
    • AUTO_ARCHIVE_DEFAULT

      public static final String AUTO_ARCHIVE_DEFAULT
      Default state for auto archive
      See Also:
    • SIGNATURE_ARGUMENT

      public static final String 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

      public void onIndexerEvent(IndexerEvent change) throws Exception
      Description copied from interface: IndexerListener
      This method is called when the indexer makes a change to the ProductIndex.
      Specified by:
      onIndexerEvent in interface IndexerListener
      Overrides:
      onIndexerEvent in class DefaultIndexerListener
      Parameters:
      change - description of the change.
      Throws:
      Exception - if error occurs
    • storeProduct

      public Product storeProduct(Product product) throws Exception
      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

      public void runProductCommand(String command, Product product) throws Exception
      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 ExternalIndexerListener
      indexerChange - The IndexerChange
      Returns:
      the command to execute with its arguments as a string
      Throws:
      Exception - if error occurs
    • getProductSummaryCommand

      public String getProductSummaryCommand(Event event, ProductSummary summary) throws Exception
      Get the command for a specific event and summary.
      Parameters:
      event - Specific event
      summary - Specific product summary
      Returns:
      command line arguments as a string.
      Throws:
      Exception - if error occurs
    • getEventArguments

      public String getEventArguments(Event event)
      Get command line arguments for an event.
      Parameters:
      event - the event
      Returns:
      command line arguments
    • getProductSummaryArguments

      public String getProductSummaryArguments(ProductSummary summary) throws IOException
      Get command line arguments for a product summary.
      Parameters:
      summary - the product summary
      Returns:
      command line arguments
      Throws:
      IOException - if IO error occurs
    • configure

      public void configure(Config config) throws Exception
      Configure an ExternalNotificationListener using a Config object.
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class DefaultIndexerListener
      Parameters:
      config - the config containing a
      Throws:
      Exception - if configuration exceptions occur.
    • shutdown

      public void shutdown() throws Exception
      Called when client is shutting down.
      Specified by:
      shutdown in interface Configurable
      Overrides:
      shutdown in class DefaultConfigurable
      Throws:
      Exception - if exceptions occur while starting.
    • startup

      public void startup() throws Exception
      Called after client has been configured and should begin processing.
      Specified by:
      startup in interface Configurable
      Overrides:
      startup in class DefaultConfigurable
      Throws:
      Exception - if exceptions occur while starting.
    • getStorage

      public FileProductStorage getStorage()
      Returns:
      the storage
    • setStorage

      public void setStorage(FileProductStorage storage)
      Parameters:
      storage - the storage to set
    • getCommand

      public String getCommand()
      Returns:
      the command
    • setCommand

      public void setCommand(String command)
      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