checkInitialConditions
- checkInitialConditions()
The checkInitialConditions method is a no-argument class method. It is possible for the batch process manager to call this method multiple times for the same batch job as it processes that job.
PolicyCenter instantiates batch process
classes at startup on servers with the batch
server role. Later, PolicyCenter
calls the checkInitialConditions
method to determine whether to start a batch process:
- If the method returns
true, PolicyCenter starts the batch process by calling its doWork method. - If the method returns
false, the initial conditions are not met and PolicyCenter does not call the doWork method, skipping the batch process for the time being.
The base class implementation of the checkInitialConditions method
always returns true. You
must override this method if you want to provide a conditional response.
If you override the checkInitialConditions
method, be certain your code completes and returns quickly. Do not include
long running code, such as queries of the database. The intent of the
method is to determine environmental conditions, such as server run level.
If you want to check initial conditions of data in the database, perform
the query in the doWork
method.
The batch process base class automatically
ensures the server is at the maintenance run level if you configure your
batch process typecode with the MaintenanceOnly
category. You can perform additional checks of the current server run
level by overriding the checkInitialConditions
method.
If you override the checkInitialConditions method,
forward the call to the superclass before returning. If the superclass
returns false, you must
return false. If the superclass
returns true, then perform
your additional checks of environmental conditions and return true or false appropriately.
Returning false from the checkInitialConditions method
false from the
checkInitialConditions method unless the condition that
triggered the false return value is likely to be temporary. If your
overridden checkInitialConditions method returns
false, PolicyCenter:- Freezes any on-going work in the batch process.
- Sets the Last Run Status value in the Server Tools Batch Process Info screen to Running.
- Executes the checkInitialConditions method once a minute
unless the returned value becomes
true, or you click Stop in the Batch Process Info screen for this batch process, or the repeat attempts time out. - Stops executing the checkInitialConditions method after
10 minutes and generates the following error message in the PolicyCenter log.
- No one started batch process after 600 seconds.
For example, suppose that your implementation of the checkInitialConditions
method checks whether the necessary files are available for processing. In some
cases, it can be necessary to schedule a batch process to run more often than the
actual schedule of input files arriving for processing. In such a case, it is better
for the checkInitialConditions method to return
true to indicate that the batch job is ready to run. You then
log an INFO or WARN message to the effect that the necessary files are missing.
