Class CLIProductBuilder

java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.distribution.CLIProductBuilder
All Implemented Interfaces:
Configurable

public class CLIProductBuilder extends DefaultConfigurable
Command Line Interface Product Builder. This class is used to build and send products. It is typically called by using the --build argument with the standard ProductClient. The CLIProductBuilder implements the Configurable interface and uses the following configuration parameters:
senders
(Required). A comma separated list of section names that should be loaded as ProductSender objects. Each sender in this list will be used to send any built products. See each type of ProductSender for more configuration details.
  • Field Details

  • Constructor Details

    • CLIProductBuilder

      protected CLIProductBuilder(String[] args)
      This class is not intended to be instantiated directly.
      Parameters:
      args - arguments
  • Method Details

    • getSenders

      public List<ProductSender> getSenders()
      Returns:
      the senders
    • configure

      public void configure(Config config) throws Exception
      Load ProductSenders that will send any built Products. There should be a property "senders" containing a comma delimited list of sender names to be loaded.
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class DefaultConfigurable
      Parameters:
      config - the Config to load.
      Throws:
      Exception - if configuration exceptions occur.
    • shutdown

      public void shutdown() throws Exception
      Called when the 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 when the client is done configuring.
      Specified by:
      startup in interface Configurable
      Overrides:
      startup in class DefaultConfigurable
      Throws:
      Exception - if exceptions occur while starting.
    • sendProduct

      public Map<ProductSender,Exception> sendProduct(Product product)
      Send a product to all configured ProductSenders.
      Parameters:
      product - the product to send.
      Returns:
      exceptions that occured while sending. If map is empty, there were no exceptions.
    • buildProduct

      public Product buildProduct() throws Exception
      Build a product using command line arguments.
      Returns:
      Product
      Throws:
      Exception - if error occurs
    • parseServers

      public static List<ProductSender> parseServers(String servers, Integer connectTimeout, boolean binaryFormat, boolean enableDeflate) throws Exception
      Parse servers for list of product senders
      Parameters:
      servers - CSV string of servers
      connectTimeout - timeout
      binaryFormat - if binaryFormat
      enableDeflate - if enableDeflate
      Returns:
      List of product senders
      Throws:
      Exception - if error occurs
    • main

      public static void main(String[] args) throws Exception
      Entry point into CLIProductBuilder. Called by Main if the --build argument is present.
      Parameters:
      args - arguments
      Throws:
      Exception - if error occurs
    • getUsage

      public static String getUsage()
      Function on how to use command
      Returns:
      string