Package gov.usgs.earthquake.distribution
Class ProductBuilder
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.distribution.ProductBuilder
- All Implemented Interfaces:
Configurable
- Direct Known Subclasses:
EIDSInputWedge
,EIDSProductBuilder
,InputWedge
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Bool for parallel sendstatic final String
time in ms for parallel send timemoutstatic final String
Send in parallel.static final String
Timeout in seconds for parallel send.protected boolean
Whether to send in parallel.protected long
How long to wait before parallel send timeout.static final String
Private key filename configuration property.static final String
Configurable property for senders.static final String
Signature version property. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProductSender
(ProductSender sender) Add a ProductSender.void
Process configuration settings.static Map<ProductSender,
Exception> parallelSendProduct
(List<ProductSender> senders, Product product, long timeoutSeconds) Send a product to all ProductSenders concurrently.void
removeProductSender
(ProductSender sender) Remove a previously added ProductSender.sendProduct
(Product product) Send a product.void
setPrivateKey
(PrivateKey privateKey) void
setSignatureVersion
(CryptoUtils.Version signatureVersion) void
shutdown()
Stop any processing/background threads.void
startup()
Start any processing/background threads.Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName
-
Field Details
-
SENDERS_PROPERTY
Configurable property for senders.- See Also:
-
PRIVATE_KEY_FILE_PROPERTY
Private key filename configuration property.- See Also:
-
SIGNATURE_VERSION_PROPERTY
Signature version property.- See Also:
-
PARALLEL_SEND_PROPERTY
Send in parallel.- See Also:
-
DEFAULT_PARALLEL_SEND
Bool for parallel send- See Also:
-
PARALLEL_SEND_TIMEOUT_PROPERTY
Timeout in seconds for parallel send.- See Also:
-
DEFAULT_PARALLEL_SEND_TIMEOUT
time in ms for parallel send timemout- See Also:
-
parallelSend
protected boolean parallelSendWhether to send in parallel. -
parallelSendTimeout
protected long parallelSendTimeoutHow long to wait before parallel send timeout.
-
-
Constructor Details
-
ProductBuilder
public ProductBuilder()
-
-
Method Details
-
sendProduct
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
- Returns:
- list of product senders
-
addProductSender
Add a ProductSender.- Parameters:
sender
- to add
-
removeProductSender
Remove a previously added ProductSender.- Parameters:
sender
- to remove
-
getPrivateKey
- Returns:
- privateKey
-
setPrivateKey
- Parameters:
privateKey
- to set
-
getSignatureVersion
- Returns:
- signatureVersion
-
setSignatureVersion
- Parameters:
signatureVersion
- to set
-
configure
Description copied from class:DefaultConfigurable
Process configuration settings. Called before startup().- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultConfigurable
- Parameters:
config
- the Config object with settings.- Throws:
Exception
- if configuration exceptions occur.
-
shutdown
Description copied from class:DefaultConfigurable
Stop any processing/background threads.- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in classDefaultConfigurable
- Throws:
Exception
- if exceptions occur while starting.
-
startup
Description copied from class:DefaultConfigurable
Start any processing/background threads.- Specified by:
startup
in interfaceConfigurable
- Overrides:
startup
in classDefaultConfigurable
- 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.
-