Class ProductBuilder

java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.distribution.ProductBuilder
All Implemented Interfaces:
Configurable
Direct Known Subclasses:
EIDSInputWedge, EIDSProductBuilder, InputWedge

public class ProductBuilder extends DefaultConfigurable
Essentials for building/sending products. This is the base class for other builders. Supported configurable properties:
senders
A comma delimited list of product senders to use when sending products.
privateKeyFile
Path to a private key that can be used to sign products.
  • Field Details

    • SENDERS_PROPERTY

      public static final String SENDERS_PROPERTY
      Configurable property for senders.
      See Also:
    • PRIVATE_KEY_FILE_PROPERTY

      public static final String PRIVATE_KEY_FILE_PROPERTY
      Private key filename configuration property.
      See Also:
    • SIGNATURE_VERSION_PROPERTY

      public static final String SIGNATURE_VERSION_PROPERTY
      Signature version property.
      See Also:
    • PARALLEL_SEND_PROPERTY

      public static final String PARALLEL_SEND_PROPERTY
      Send in parallel.
      See Also:
    • DEFAULT_PARALLEL_SEND

      public static final String DEFAULT_PARALLEL_SEND
      Bool for parallel send
      See Also:
    • PARALLEL_SEND_TIMEOUT_PROPERTY

      public static final String PARALLEL_SEND_TIMEOUT_PROPERTY
      Timeout in seconds for parallel send.
      See Also:
    • DEFAULT_PARALLEL_SEND_TIMEOUT

      public static final String DEFAULT_PARALLEL_SEND_TIMEOUT
      time in ms for parallel send timemout
      See Also:
    • parallelSend

      protected boolean parallelSend
      Whether to send in parallel.
    • parallelSendTimeout

      protected long parallelSendTimeout
      How long to wait before parallel send timeout.
  • Constructor Details

    • ProductBuilder

      public ProductBuilder()
  • Method Details

    • sendProduct

      public Map<ProductSender,Exception> sendProduct(Product product) throws Exception
      Send a product. If the product has not yet been signed, and a privateKey is configured, signs the product before sending.
      Parameters:
      product - the product to send.
      Returns:
      map of all exceptions thrown, from Sender to corresponding Exception.
      Throws:
      Exception - if an error occurs while signing product.
    • getProductSenders

      public List<ProductSender> getProductSenders()
      Returns:
      list of product senders
    • addProductSender

      public void addProductSender(ProductSender sender)
      Add a ProductSender.
      Parameters:
      sender - to add
    • removeProductSender

      public void removeProductSender(ProductSender sender)
      Remove a previously added ProductSender.
      Parameters:
      sender - to remove
    • getPrivateKey

      public PrivateKey getPrivateKey()
      Returns:
      privateKey
    • setPrivateKey

      public void setPrivateKey(PrivateKey privateKey)
      Parameters:
      privateKey - to set
    • getSignatureVersion

      public CryptoUtils.Version getSignatureVersion()
      Returns:
      signatureVersion
    • setSignatureVersion

      public void setSignatureVersion(CryptoUtils.Version signatureVersion)
      Parameters:
      signatureVersion - to set
    • configure

      public void configure(Config config) throws Exception
      Description copied from class: DefaultConfigurable
      Process configuration settings. Called before startup().
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class DefaultConfigurable
      Parameters:
      config - the Config object with settings.
      Throws:
      Exception - if configuration exceptions occur.
    • shutdown

      public void shutdown() throws Exception
      Description copied from class: DefaultConfigurable
      Stop any processing/background threads.
      Specified by:
      shutdown in interface Configurable
      Overrides:
      shutdown in class DefaultConfigurable
      Throws:
      Exception - if exceptions occur while starting.
    • startup

      public void startup() throws Exception
      Description copied from class: DefaultConfigurable
      Start any processing/background threads.
      Specified by:
      startup in interface Configurable
      Overrides:
      startup in class DefaultConfigurable
      Throws:
      Exception - if exceptions occur while starting.
    • parallelSendProduct

      public static Map<ProductSender,Exception> parallelSendProduct(List<ProductSender> senders, Product product, long timeoutSeconds)
      Send a product to all ProductSenders concurrently.
      Parameters:
      senders - the senders to receive product.
      product - the product to send.
      timeoutSeconds - number of seconds before timing out, interrupting any pending send.
      Returns:
      exceptions that occured while sending. If map is empty, there were no exceptions.