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 StringBool for parallel sendstatic final Stringtime in ms for parallel send timemoutstatic final StringSend in parallel.static final StringTimeout in seconds for parallel send.protected booleanWhether to send in parallel.protected longHow long to wait before parallel send timeout.static final StringPrivate key filename configuration property.static final StringConfigurable property for senders.static final StringSignature version property. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProductSender(ProductSender sender) Add a ProductSender.voidProcess configuration settings.static Map<ProductSender,Exception> parallelSendProduct(List<ProductSender> senders, Product product, long timeoutSeconds) Send a product to all ProductSenders concurrently.voidremoveProductSender(ProductSender sender) Remove a previously added ProductSender.sendProduct(Product product) Send a product.voidsetPrivateKey(PrivateKey privateKey) voidsetSignatureVersion(CryptoUtils.Version signatureVersion) voidshutdown()Stop any processing/background threads.voidstartup()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:DefaultConfigurableProcess configuration settings. Called before startup().- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classDefaultConfigurable- Parameters:
config- the Config object with settings.- Throws:
Exception- if configuration exceptions occur.
-
shutdown
Description copied from class:DefaultConfigurableStop any processing/background threads.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultConfigurable- Throws:
Exception- if exceptions occur while starting.
-
startup
Description copied from class:DefaultConfigurableStart any processing/background threads.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin 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.
-