Package gov.usgs.earthquake.distribution
Class CLIProductBuilder
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.distribution.CLIProductBuilder
- All Implemented Interfaces:
Configurable
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final String
binaryFormat argumentstatic final String
product id code argumentstatic final String
connectionTimeout argumentstatic final String
product content argumentstatic final String
product content type argumentstatic final Integer
Default connectionTimeout argument.static final String
product delete argumentstatic final String
depth argumentstatic final String
product directory argumentstatic final String
disableDeflate argumentstatic final String
disableParallelSend argumentstatic final String
eventCode argumentstatic final String
eventID argumentstatic final String
eventsource argumentstatic final String
eventsourcecode argumentstatic final String
eventtime argumentstatic final int
Exit code used when an invalid combination of arguments is used.static final int
Exit code when errors occur while sending, but not to all senders.static final int
Exit code used when unable to build a product.static final int
Exit code used when errors occur while sending.static final String
product file argumentstatic final String
latitude argumentstatic final String
product link argumentstatic final String
longitude argumentstatic final String
magnitude argumentstatic final String
parallelSendTimeout argumentstatic final String
private key argumentstatic final String
property argumentstatic final String
Property name used for configuring the list of senders.static final String
Arguments for configuring servers and connectTimeouts.static final String
signature version argumentstatic final String
product id source argumentstatic final String
product status argumentstatic final String
product id type argumentstatic final String
product id updateTime argumentstatic final String
version argument -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CLIProductBuilder
(String[] args) This class is not intended to be instantiated directly. -
Method Summary
Modifier and TypeMethodDescriptionBuild a product using command line arguments.void
Load ProductSenders that will send any built Products.static String
getUsage()
Function on how to use commandstatic void
Entry point into CLIProductBuilder.static List<ProductSender>
parseServers
(String servers, Integer connectTimeout, boolean binaryFormat, boolean enableDeflate) Parse servers for list of product senderssendProduct
(Product product) Send a product to all configured ProductSenders.void
shutdown()
Called when the client is shutting down.void
startup()
Called when the client is done configuring.Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName
-
Field Details
-
EXIT_INVALID_ARGUMENTS
public static final int EXIT_INVALID_ARGUMENTSExit code used when an invalid combination of arguments is used.- See Also:
-
EXIT_UNABLE_TO_BUILD
public static final int EXIT_UNABLE_TO_BUILDExit code used when unable to build a product.- See Also:
-
EXIT_UNABLE_TO_SEND
public static final int EXIT_UNABLE_TO_SENDExit code used when errors occur while sending.- See Also:
-
EXIT_PARTIALLY_SENT
public static final int EXIT_PARTIALLY_SENTExit code when errors occur while sending, but not to all senders.- See Also:
-
TYPE_ARGUMENT
product id type argument- See Also:
-
CODE_ARGUMENT
product id code argument- See Also:
-
SOURCE_ARGUMENT
product id source argument- See Also:
-
UPDATE_TIME_ARGUMENT
product id updateTime argument- See Also:
-
STATUS_ARGUMENT
product status argument- See Also:
-
DELETE_ARGUMENT
product delete argument- See Also:
-
PROPERTY_ARGUMENT
property argument- See Also:
-
EVENTID_ARGUMENT
eventID argument- See Also:
-
EVENTSOURCE_ARGUMENT
eventsource argument- See Also:
-
EVENTSOURCECODE_ARGUMENT
eventsourcecode argument- See Also:
-
EVENTCODE_ARGUMENT
eventCode argument- See Also:
-
EVENTTIME_ARGUMENT
eventtime argument- See Also:
-
LATITUDE_ARGUMENT
latitude argument- See Also:
-
LONGITUDE_ARGUMENT
longitude argument- See Also:
-
DEPTH_ARGUMENT
depth argument- See Also:
-
MAGNITUDE_ARGUMENT
magnitude argument- See Also:
-
VERSION_ARGUMENT
version argument- See Also:
-
LINK_ARGUMENT
product link argument- See Also:
-
CONTENT_ARGUMENT
product content argument- See Also:
-
CONTENT_TYPE_ARGUMENT
product content type argument- See Also:
-
DIRECTORY_ARGUMENT
product directory argument- See Also:
-
FILE_ARGUMENT
product file argument- See Also:
-
PRIVATE_KEY_ARGUMENT
private key argument- See Also:
-
SIGNATURE_VERSION_ARGUMENT
signature version argument- See Also:
-
SENDERS_CONFIG_PROPERTY
Property name used for configuring the list of senders.- See Also:
-
SERVERS_ARGUMENT
Arguments for configuring servers and connectTimeouts.- See Also:
-
CONNECT_TIMEOUT_ARGUMENT
connectionTimeout argument- See Also:
-
DEFAULT_CONNECT_TIMEOUT
Default connectionTimeout argument. 15s -
BINARY_FORMAT_ARGUMENT
binaryFormat argument- See Also:
-
DISABLE_DEFLATE
disableDeflate argument- See Also:
-
DISABLE_PARALLEL_SEND
disableParallelSend argument- See Also:
-
PARALLEL_SEND_TIMEOUT_ARGUMENT
parallelSendTimeout argument- See Also:
-
-
Constructor Details
-
CLIProductBuilder
This class is not intended to be instantiated directly.- Parameters:
args
- arguments
-
-
Method Details
-
getSenders
- Returns:
- the senders
-
configure
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 interfaceConfigurable
- Overrides:
configure
in classDefaultConfigurable
- Parameters:
config
- the Config to load.- Throws:
Exception
- if configuration exceptions occur.
-
shutdown
Called when the client is shutting down.- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in classDefaultConfigurable
- Throws:
Exception
- if exceptions occur while starting.
-
startup
Called when the client is done configuring.- Specified by:
startup
in interfaceConfigurable
- Overrides:
startup
in classDefaultConfigurable
- Throws:
Exception
- if exceptions occur while starting.
-
sendProduct
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
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 serversconnectTimeout
- timeoutbinaryFormat
- if binaryFormatenableDeflate
- if enableDeflate- Returns:
- List of product senders
- Throws:
Exception
- if error occurs
-
main
Entry point into CLIProductBuilder. Called by Main if the --build argument is present.- Parameters:
args
- arguments- Throws:
Exception
- if error occurs
-
getUsage
Function on how to use command- Returns:
- string
-