Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop batch applications > Develop batch applications > Develop a simple transactional batch application > The batch programming model


Checkpoint algorithms

The grid endpoints use checkpoint algorithms to determine when to commit global transactions under which batch steps are invoked. These algorithms are applied to a batch job through the XML Job Control Language (xJCL) definition. Properties specified for checkpoint algorithms in xJCL allow for checkpoint behavior, such as transaction timeouts and checkpoint intervals, to be customized for batch steps. The product provides both a time-based checkpoint algorithm and a record-based algorithm, and defines a service provider interface (SPI) for building additional custom checkpoint algorithms.

On each batch step iteration of the processJobStep method, the common batch container consults the checkpoint algorithm applied to that step if it commits the global transaction or not. Call back methods on the checkpoint algorithms allow the common batch container to inform the algorithm when a global transaction is committed or started. This behavior enables the algorithm to tracks the global transaction life cycle. On each iteration of the processJobStep method, the common batch container calls the ShouldCheckpointBeExecuted callback method on the algorithm to determine if the transaction is committed. The algorithm controls the checkpoint interval through this method.

Review the batch API for the checkpoint algorithm SPI, located in the Information Center reference section, for the checkpoint algorithm SPI that you can use to create custom checkpoint algorithms. The class name is com.ibm.wsspi.batch.CheckpointPolicyAlgorithm.

The product supports two checkpoint algorithms: the time-based algorithm and the record based algorithm. Both are explained in the following sections.


Time-based algorithm

The time-based checkpoint algorithm commits global transactions at a specified time interval. The following example declares a time-based algorithm in xJCL:

<checkpoint-algorithm name="timebased">
<classname>com.ibm.wsspi.batch.checkpointalgorithms.timebased
</classname>
<props>     
<prop name="interval" value="15" />     
<prop name="TransactionTimeOut" value="30" />
</props>
</checkpoint-algorithm>

The units of interval and TransactionTimeOut properties in the previous example are expressed in seconds.


Record-based algorithm

The record-based checkpoint algorithm commits global transactions at a specified number of iterations of the processJobStep method of batch step. Each call to the processJobStep method is treated as iterating through one record. The processJobStep method can retrieve multiple records from a batch data stream on each call. However, for this checkpoint algorithm one record is the equivalent one call to the processJobStep method.

The following example declares a record-based algorithm in xJCL:

<checkpoint-algorithm name="recordbased">
<classname>com.ibm.wsspi.batch.checkpointalgorithms.recordbased
</classname>
<props>     
<prop name="recordcount" value="1000" />     
<prop name="TransactionTimeOut" value="60" />
</props>
</checkpoint-algorithm>

The unit of the TransactionTimeOut property in the previous example is expressed in seconds.

If not specified in xJCL, the default transaction timeout is 60 seconds and the default record count is 10000.


Apply a checkpoint algorithm to a batch step

Checkpoint algorithms are applied to a batch job through xJCL. We can declare multiple checkpoint algorithms in xJCL, and you can apply a different algorithm to each batch step. We can apply no more than one checkpoint algorithm to a batch step.

The following example applies checkpoint algorithms in xJCL:

<job name="PostingsSampleEar">

<checkpoint-algorithm name="timebased">
<classname>com.ibm.wsspi.batch.checkpointalgorithms.timebased
</classname>

<props>     
<prop name="interval" value="15" />     
<prop name=" TransactionTimeOut" value="30" />
</props>
</checkpoint-algorithm>

<checkpoint-algorithm name="recordbased">
<classname>com.ibm.wsspi.batch.checkpointalgorithms.recordbased
</classname>
<props>     
<prop name="recordcount" value="1000" />     
<prop name="TransactionTimeOut" value="60" />
</props>
</checkpoint-algorithm>

<job-step name="Step1">
<checkpoint-algorithm-ref name="timebased" />
</job-step>

<job-step name="Step2">
<checkpoint-algorithm-ref name="recordbased" />
</job-step>
</job>

The batch programming model
Program Interfaces (APIs)

+

Search Tips   |   Advanced Search