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