batchManager command-line client utility

The batchManager command-line client utility provides a command-line interface for managing your batch jobs that run on Liberty.

The batchManager command-line client utility interacts with the batch manager over the batch manager's REST API. To use the batchManager command-line client utility, the batch manager must be running on your Liberty server. Use the batch management feature to install and enable the Liberty batch manager.

SSL configuration

The batchManager command-line client utility communicates with the batch manager over an SSL connection. To facilitate SSL communication with a batch manager that is running on a Liberty server, the utility must be able to verify the SSL certificate of the Liberty server.

If the SSL certificate is signed by a well-known certificate authority (CA), the utility can verify the certificate by the CA. No further configuration is necessary.

If the SSL certificate is not signed by a CA, then you must configure the utility to trust the SSL certificate of the server by doing one of the following actions.
  • Specify the option --trustSslCertificates, which configures the utility to trust all SSL certificates.
  • Include the server's SSL certificate in the utility's truststore.

If you choose to specify the option --trustSslCertificates, the utility trusts all SSL certificates that it receives and no further configuration is necessary.

If you choose the option to include the server's SSL certificate in the utility's truststore, then you must also configure the utility so that it can find its truststore. The utility is a stand-alone Java main. You configure SSL by using system properties such as javax.net.ssl.truststore.

 If the batch manager is running on the same machine as the utility, then you can point the utility directly at the server keystore:
   $ export JVM_ARGS="-Djavax.net.ssl.trustStore=/path/to/server/keystore.jks"
   $ batchManager submit ...
Attention: JVM arguments, such as -D properties, are passed to the batchManager command-line client utility by the JVM-ARGS environment variable.
If you cannot use the server keystore directly, you must export the server certificate from the server keystore and import it into the client truststore. Use the JDK keytool utility for exporting and importing certificates. In the following example, the server certificate is stored in the [server-dir]/resources/security/key.jks keystore file under the default alias, and the password is Liberty.
    $ keytool -export -alias default -file server.crt -keystore [server-dir]/resources/security/key.jks -storepass Liberty
    $ keytool -import -alias server_crt -file server.crt -keystore /path/to/truststore.jks -storepass passw0rd
Attention: The import command creates the truststore.jks file if the file does not exist.
    $ export JVM_ARGS="-Djavax.net.ssl.trustStore=/path/to/truststore.jks"
    $ batchManager submit ...

Commands and usage

The batchManager command-line client utility provides commands for submitting, stopping, restarting, and checking the status of jobs.

To generally use the utility:

$ batchManager [command] [options]

To see a list of available commands:

$ batchManager help

To see the description and options for a specific command:

$ batchManager help [command]

The following example illustrates how to submit a job and wait for its completion:

  $ batchManager submit \
        --batchManager=<host>:<port>
        --user=[credentials for logging into the batch manager]
        --password=[credentials for logging into the batch manager]
        --applicationName=[application name used when packaging the batch app]
        --jobXMLName=[job XML file basename in the app's batch-jobs dir]
        --wait

jobParametersFile and jobPropertiesFile

When submitting a batch job by using the batchManager client utility, the jobParametersFile and jobPropertiesFile supports the use of multiple files separated by commas. Files later in the comma-separated list take precedence over files that appear first in the list. The following example illustrates correct usage of the comma-separated list.
jobParametersFile=filePath1,filePath2,filePath3
jobPropertiesFile=filePath1,filePath2,filePath3
As an example, --jobParametersFile=<filepath1> would override --jobParametersFile=<filepath1>,<filepath2> in the control properties file. The resulting parameter is --jobParametersFile=<filepath1>.

Control properties and job parameters

To build a single set of job parameters, the program starts with an empty set and continually loads properties from various sources. The program then merges the properties into a single set. After the program reads and loads all the sources, the program passes the single set of properties to the job submission as the job parameters.

This set of properties is built by merging in this order. When the same property with the same key is loaded and set more than once, the later value overrides the earlier value. The later steps in this sequence have a higher precedence than the earlier steps.

  1. If the --jobParametersFile parameter is not included as a command line parameter, the following actions occur in order of ascending precedence:
    1. The contents of the files that are referenced by the --jobParametersFile control property are loaded and merged. This control property might appear in only one control property file, or it might appear in more than one file if the property was overridden.
    2. Job parameter control properties are loaded and merged. These properties are structured as --jobParameter=key=value inside of the control properties file.
    3. Command line job parameters are loaded and merged.
  2. If the --jobParametersFile parameter is not included as a command line parameter, the following actions occur in order of ascending precedence:
    1. The contents of the files that are referenced by the --jobParametersFile control property are loaded and merged. This control property might appear in only one control property file, or it might appear in more than one file if the property was overridden.
    2. Job parameter control properties are loaded and merged. These properties are structured as --jobParameter=key=value inside of the control properties file.
    3. Command line job parameters are loaded and merged.

This structure occurs because the --controlPropertiesFile parameter has less precedence than the command line arguments. The level at which you specify the --jobParametersFile parameter determines the level of precedence of those files.

As the program reads and loads each file in the sequence, the program collapses the --jobParametersFile and --jobPropertiesFile properties that are found into a single property. Each property is an alias of the other. A command line argument or control properties override with one of these aliases supersedes an instance of either of the two that appears in an earlier overridden control properties file.

Note: Check the Javadoc information file java.util.Properties.load() for comment specifications.

Return codes

The batchManager command-line client utility outputs the following return codes:
Code Description
0 The task completed normally.
20 A required argument was not specified.
21 An unrecognized argument was specified.
22 An invalid argument value was specified.
255 An unknown error occurred.
Note: If you specify the --wait argument, the utility outputs the following return codes about the status of the job that you are waiting for.
Code Description
33 The job stopped.
34 The job did not complete successfully.
35 The job completed successfully.
36 The job was abandoned.