FairCom RTG is designed to utilize FairCom Replication, which makes it easy to use within a cluster environment, including client-side notification support for automating failover. FairCom also makes it easy to build High Availability (HA) and Disaster Recovery (DR) systems.
This section details what’s involved in adding this support into FairCom RTG. See our general Replication section for more information.
FairCom RTG Failover Configuration
It’s easy to configure the FairCom RTG Server for use within a cluster environment. The <instance> configuration option accommodates clustering using these attributes:
- autoreconnect="yes|no" - Set to yes for use in a cluster (either a cluster managed by Replication Agent or a "transparent" cluster such as one managed by Linux Pacemaker). Set to no if the FairCom RTG instance is not in a cluster.
If you are not using a cluster, you can set autoreconnect="yes" to enable logic to automatically reconnect if the client has been disconnected, which can be helpful in a failover environment that requires reconnection.
- faircomcluster="yes|no" - Set to yes for use in a cluster managed by FairCom Replication Agent. Set to no for use in a cluster that is managed by a cluster aware operating system, such as Linux Pacemaker. If set to yes, the <instance server> attribute must contain one or more server names (delimited by ';') to initiate the connection to the cluster.
If a file open operation fails with any disconnection error, the operation is retried signaling that the previous connection was lost, thus forcing a new reconnection. In addition, the file close operation is changed so that, if it fails with any disconnection error, the file handlers are released and a success code is returned even if c-tree failed with a disconnection error. Returning success is necessary so the COBOL application does not consider the file to still be open, in which case it would not be possible to close it because the connection was lost.
Example Using Replication Manager Clustering
To set up clustering using a FairCom Replication Manager cluster, enable the <instance autoreconnect="yes"> attribute and specify <instance faircomcluster="yes">. A typical FairCom RTG configuration to connect to a Replication Manager cluster is as follows:
<instance server="FAIRCOMS1@localhost;FAIRCOMS2@remote" faircomcluster="yes" autoreconnect="yes">Example Using Pacemaker Clustering
To set up a Pacemaker cluster (this same support is applicable to a Windows Server cluster), enable the <instance autoreconnect="yes"> attribute and specify the Pacemaker virtual IP address or host name in the <instance server="FAIRCOMS@VirtualHostName"> option. Pacemaker will ensure a server is always running on the specified virtual IP address/host name, so there is no need to specify the cluster details in the FairCom RTG client. The FairCom RTG configuration to connect to a transparent cluster, such as Pacemaker, is as follows:
<instance server="FAIRCOMS@VirtualHostName" faircomcluster="no" autoreconnect="yes">Changes to Your COBOL Program
Once FairCom RTG is configured to enable failover support, it is also necessary to make your FairCom RTG application detect failover and react to it.
The COBOL application needs to check that the error returned is a disconnection error and if so, the application must close and re-open the file affected by the disconnection.
Below is a small sample program in COBOL, which shows how to handle failover.
This program is basically adding records:
* populate the table with data
PERFORM Add-Records.The records are added in an infinite loop:
Add-Records.
DISPLAY " Add records..."
PERFORM UNTIL stat NOT = "00"
MOVE numb TO cm-custnumb
MOVE "92867" TO cm-custzipc
MOVE "CA" TO cm-custstat
MOVE "1" TO cm-custrtng
MOVE "Bryan Williams" TO cm-custname
MOVE "2999 Regency" TO cm-custaddr
MOVE "Orange" TO cm-custcity
WRITE custmast-record
PERFORM Display-Record
ADD 1 TO numb
...
PERFORM Sleep
END-PERFORMIf an error occurs and it's a disconnection error, the logic closes and re-opens the file:
* get c-tree error in crerr-2
CALL "C$RERR" USING crerr
* if disconnection error
IF crerr-1 = "9D" AND ( crerr-2 = "127" OR
crerr-2 = "128" OR
crerr-2 = "129" OR
crerr-2 = "7" OR
crerr-2 = "808" OR
crerr-2 = "809" OR
crerr-2 = "820" OR
crerr-2 = "150" )
DISPLAY "Disconnected! Attempting to failover..."
* close file
CLOSE custmast-file
* re-open file on next available server in the cluster
OPEN I-O custmast-file
* populate the table with data
PERFORM Add-Records