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.StringBINARY_FORMAT_ARGUMENTbinaryFormat argumentstatic java.lang.StringCODE_ARGUMENTproduct id code argumentstatic java.lang.StringCONNECT_TIMEOUT_ARGUMENTconnectionTimeout argumentstatic java.lang.StringCONTENT_ARGUMENTproduct content argumentstatic java.lang.StringCONTENT_TYPE_ARGUMENTproduct content type argumentstatic java.lang.IntegerDEFAULT_CONNECT_TIMEOUTDefault connectionTimeout argument.static java.lang.StringDELETE_ARGUMENTproduct delete argumentstatic java.lang.StringDEPTH_ARGUMENTdepth argumentstatic java.lang.StringDIRECTORY_ARGUMENTproduct directory argumentstatic java.lang.StringDISABLE_DEFLATEdisableDeflate argumentstatic java.lang.StringDISABLE_PARALLEL_SENDdisableParallelSend argumentstatic java.lang.StringEVENTCODE_ARGUMENTeventCode argumentstatic java.lang.StringEVENTID_ARGUMENTeventID argumentstatic java.lang.StringEVENTSOURCE_ARGUMENTeventsource argumentstatic java.lang.StringEVENTSOURCECODE_ARGUMENTeventsourcecode argumentstatic java.lang.StringEVENTTIME_ARGUMENTeventtime argumentstatic intEXIT_INVALID_ARGUMENTSExit code used when an invalid combination of arguments is used.static intEXIT_PARTIALLY_SENTExit code when errors occur while sending, but not to all senders.static intEXIT_UNABLE_TO_BUILDExit code used when unable to build a product.static intEXIT_UNABLE_TO_SENDExit code used when errors occur while sending.static java.lang.StringFILE_ARGUMENTproduct file argumentstatic java.lang.StringLATITUDE_ARGUMENTlatitude argumentstatic java.lang.StringLINK_ARGUMENTproduct link argumentstatic java.lang.StringLONGITUDE_ARGUMENTlongitude argumentstatic java.lang.StringMAGNITUDE_ARGUMENTmagnitude argumentstatic java.lang.StringPARALLEL_SEND_TIMEOUT_ARGUMENTparallelSendTimeout argumentstatic java.lang.StringPRIVATE_KEY_ARGUMENTprivate key argumentstatic java.lang.StringPROPERTY_ARGUMENTproperty argumentstatic java.lang.StringSENDERS_CONFIG_PROPERTYProperty name used for configuring the list of senders.static java.lang.StringSERVERS_ARGUMENTArguments for configuring servers and connectTimeouts.static java.lang.StringSIGNATURE_VERSION_ARGUMENTsignature version argumentstatic java.lang.StringSOURCE_ARGUMENTproduct id source argumentstatic java.lang.StringSTATUS_ARGUMENTproduct status argumentstatic java.lang.StringTRACKER_URL_ARGUMENTtracker url argumentstatic java.lang.StringTRACKER_URL_CONFIG_PROPERTYProperty name used for configuring a tracker url.static java.lang.StringTYPE_ARGUMENTproduct id type argumentstatic java.lang.StringUPDATE_TIME_ARGUMENTproduct id updateTime argumentstatic java.lang.StringVERSION_ARGUMENTversion argument
-
Constructor Summary
Constructors Modifier Constructor Description protectedCLIProductBuilder(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 ProductbuildProduct()Build a product using command line arguments.voidconfigure(Config config)Load ProductSenders that will send any built Products.java.net.URLgetDefaultTrackerURL()java.util.List<ProductSender>getSenders()static java.lang.StringgetUsage()Function on how to use commandstatic voidmain(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.voidsetDefaultTrackerURL(java.net.URL defaultTrackerURL)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 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:
configurein interfaceConfigurable- Overrides:
configurein classDefaultConfigurable- Parameters:
config- the Config to load.- Throws:
java.lang.Exception- if configuration exceptions occur.
-
shutdown
public void shutdown() throws java.lang.ExceptionCalled when the client is shutting down.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultConfigurable- Throws:
java.lang.Exception- if exceptions occur while starting.
-
startup
public void startup() throws java.lang.ExceptionCalled when the client is done configuring.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin 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.ExceptionEntry 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
-
-