Improved Asadmin Commands

The following is a list of the administration commands that have been introduced or changed from GlassFish in Payara Server to improve the JBatch API.

set-batch-runtime-configuration

Usage

asadmin> set-batch-runtime-configuration --datasourcelookupname="jdbc/default" --executorservicelookupname="concurrent/__defaultManagedExecutorService" --schemaName="APP" --tablePrefix="BJP" --tableSuffix="BJS"

Aim

Configures the batch runtime storage and execution settings.

Command Options

Option Shortcut Description Default Mandatory

--target

N/A

The instance or cluster to configure

server

No

--datasourcelookupname

-d

The JNDI name of the JDBC data source used to store job information

N/A

Yes (unless executorservicelookupname is specified)

--executorservicelookupname

-x

The JNDI name of the Managed Executor Service that provides threads for the jobs' execution.

N/A

Yes (unless datasourceLookupName is used)

--schemaName

-n

The database schema that holds the batch tables.

APP

No

--tablePrefix

N/A

The prefix to apply to the batch table name.

N/A

No

--tableSuffix

N/A

Sets the suffix to apply to the batch table name.

N/A

No

Example

The following command will set the data source, and the prefix and suffix for the DAS:

asadmin > set-batch-runtime-configuration --target="server"
            --datasourcelookupname="jdbc/BatchJobsDS"
            --tablePrefix="BATCHJ_" --tableSuffix="_JB"

purge-jbatch-repository

Since Payara Server 4.1.2.173

Usage

asadmin> purge-jbatch-repository <apptag>

Aim

Purges the current JBatch repository of all jobs scheduled for the referenced application’s tag. The application’s tag is structured like this:

<Configuration Identifier>:<Application Name>__/<Application Name>

Where Configuration Identifier is the identifier of the configuration associated to the instance or cluster where the application is deployed and Application Name is the name of the deployed application.

Command Options

There are no options available.

Example

To remove all current jobs for an application named jbatch-test deployed on the DAS (server-config) then run the following command:

asadmin > purge-jbatch-repository "server-config:jbatch-test__/jbatch-test"
The command will remove all current jobs created by the referenced application whether these jobs are running or not.
If you are having trouble finding the application’s tag for your application, you can get it programmatically on a Java EE application by using the following code:
import com.ibm.jbatch.container.servicesmanager.ServicesManager;
import com.ibm.jbatch.container.servicesmanager.ServicesManagerImpl;
import com.ibm.jbatch.container.services.IPersistenceManagerService;
...

JobOperator jobOperator = getJobOperator();
Long executionId = jobOperator.start("job-name", new Properties());

ServicesManager manager = ServicesManagerImpl.getInstance();
IPersistenceManagerService ps = manager.getPersistenceManagerService();
String applicationTag = ps.getJobCurrentTag(jobid);

You need to add a dependency to IBM’s JBatch runtime to your project to access the classes mentioned:

<dependency>
    <groupId>com.ibm.jbatch</groupId>
    <artifactId>com.ibm.jbatch-runtime-all</artifactId>
    <version>1.0</version>
    <scope>provided</scope>
</dependency>

clean-jbatch-repository

Since Payara Server 5.25.0

Usage

asadmin> clean-jbatch-repository --status COMPLETED|ALL --days <int.value> <JobName>

Aim

The clean-jbatch-repository subcommand deletes records of job executions.

The command will only clean jobs that are stored in the internal embedded H2 database. If a separate database is used to store the records for JBatch jobs, the command will not clear them. Support for other database storage types will come later in the future.

Command Options

Option Type Description Default Mandatory

--status

  • ALL

  • COMPLETED

The status of batch jobs executions to which delete the records of. If ALL then all job executions will be deleted, regardless of status. If COMPLETED only job executions that successfully completed will be deleted.

COMPLETED

No

--days

Integer

The number of days previous that the end time of the job execution must be to get deleted.

0

No

Example

The following command will delete all Batch jobs that were executed before 7 days ago.

asadmin > clean-jbatch-repository --status=ALL --days=7 test job

list-batch-jobs

Since Payara Server 5.183

Usage

asadmin> list-batch-jobs --output jobname,appname,instancecount,instanceid, executionid,batchstatus,starttime,endtime,exitstatus --limit <long.value> --offset <long.value> --header true|false <JobName>

Aim

Lists batch jobs and information about them.

Command Options

Option Shortcut Description Default Mandatory

--target

N/A

The instance or cluster to configure

server

No

--long

-l

Shows detailed information about batch jobs

false

No

--output

-0

Shows specific information about batch jobs. You can specify information to display by using comma-separarted list. Following are the available values: jobname, appname, instancecount, instanceid, executionid, batchstatus, starttime, endtime, exitstatus

The jobname and instancecount information are displayed by default

No

--header

-h

Option to choose whether column heading should be displayed or not

false

No

--limit

N/A

Set number of rows of batch jobs to display

N/A

No

--offset

N/A

Set number of rows of batch jobs to skip

N/A

No

Example

asadmin > list-batch-jobs --target server
            --long true
            --limit 20
            --offset 0