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 StringbinaryFormat argumentstatic final Stringproduct id code argumentstatic final StringconnectionTimeout argumentstatic final Stringproduct content argumentstatic final Stringproduct content type argumentstatic final IntegerDefault connectionTimeout argument.static final Stringproduct delete argumentstatic final Stringdepth argumentstatic final Stringproduct directory argumentstatic final StringdisableDeflate argumentstatic final StringdisableParallelSend argumentstatic final StringeventCode argumentstatic final StringeventID argumentstatic final Stringeventsource argumentstatic final Stringeventsourcecode argumentstatic final Stringeventtime argumentstatic final intExit code used when an invalid combination of arguments is used.static final intExit code when errors occur while sending, but not to all senders.static final intExit code used when unable to build a product.static final intExit code used when errors occur while sending.static final Stringproduct file argumentstatic final Stringlatitude argumentstatic final Stringproduct link argumentstatic final Stringlongitude argumentstatic final Stringmagnitude argumentstatic final StringparallelSendTimeout argumentstatic final Stringprivate key argumentstatic final Stringproperty argumentstatic final StringProperty name used for configuring the list of senders.static final StringArguments for configuring servers and connectTimeouts.static final Stringsignature version argumentstatic final Stringproduct id source argumentstatic final Stringproduct status argumentstatic final Stringproduct id type argumentstatic final Stringproduct id updateTime argumentstatic final Stringversion argument -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCLIProductBuilder(String[] args) This class is not intended to be instantiated directly. -
Method Summary
Modifier and TypeMethodDescriptionBuild a product using command line arguments.voidLoad ProductSenders that will send any built Products.static StringgetUsage()Function on how to use commandstatic voidEntry 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.voidshutdown()Called when the client is shutting down.voidstartup()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:
configurein interfaceConfigurable- Overrides:
configurein classDefaultConfigurable- Parameters:
config- the Config to load.- Throws:
Exception- if configuration exceptions occur.
-
shutdown
Called when the client is shutting down.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultConfigurable- Throws:
Exception- if exceptions occur while starting.
-
startup
Called when the client is done configuring.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin 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
-