COBOL Manual for TNS/E Programs (H06.03+)

Fault-Tolerant Processes
HP COBOL Manual for TNS/E Programs520347-003
32-13
Designing Programs for the Fault-Tolerant Facility
After the program is compiled and debugged, it must be run as a named process (see
Process Names).
Designing Programs for the Fault-Tolerant Facility
You must design a program to use the fault-tolerant facility. It is very difficult, if not
impossible, to retrofit the use of the fault-tolerant facility to an existing program.
A checkpoint is a location in the program at which processing resumes when a
takeover occurs. All data from the primary process that is part of the program state
must be checkpointed to the backup process if the takeover is to succeed.
You must checkpoint before any nonretryable operation, such as a write to disk. You
can (for operator convenience) checkpoint after a read from a terminal. You can (for
programming convenience) checkpoint after a read from tape.
If your SYNCDEPTH exceeds one, and you open or close a file during checkpoint-
protected operation, you must checkpoint the sync blocks and record areas of all other
files before the next nonretryable operation.
Debugging Programs That Use the Fault-Tolerant Facility
Debugging a program that uses the fault-tolerant facility requires at least as careful an
analysis as designing the program. This list of suggestions is not exhaustive.
Test the program thoroughly as a simple batch job. You might create files of
transactions that the job must successfully process before you try testing the fault-
tolerance mechanisms. You can have the program read the files instead of having
the program read from $RECEIVE.
GET-CPUNUM.
MOVE "BACKUPCPU" TO PARAM.
ENTER "SMU_Param_GetText_" USING PARAM PARAM-RET
GIVING ERROR-CODE.
MOVE PARAM-RET TO BCPU.
IF BCPU < 0 OR BCPU > 15
DISPLAY "BACKUP CPU INVALID, RUNNING WITHOUT BACKUP".
UPDATE-RECS.
...
READ TEST-FILE WITH LOCK.
...
CHECKPOINT TEST-FILE,
TEST-REC,
CKPT-DATA.
IF PROGRAM-STATUS > "0000"
AND PROGRAM-STATUS < "1000"
DISPLAY "Backup took over".
REWRITE TEST-REC WITH UNLOCK.
...
Example 32-1. Key Parts of Fault-Tolerant HP COBOL Program (page 2 of 2)