An application installed in a cluster must be able to run on both the primary and secondary companions. That is, if you install an application that requires a parallel configuration, the secondary companion must also be configured for parallel processing so it can run the application during failover.
You must modify all of your applications that are written with CTLIB API calls before they can work with Sybase’s failover software. The following steps describe the modifications:
Set the CS_HAFAILOVER property using the ct_config and ct_con_props CTLIB API calls. You can set this property at either the context or the connection level. This property is set using the following syntax:
ct_config(context, action, CS_HAFAILOVER, buf, buflen, outlen) ct_con_props(connection, action, CS_HAFAILOVER, buf, buflen, outlen)
Modify the interfaces file so clients fail over to the secondary companion.
The interfaces file includes a line labeled hafailover that enables clients for reconnect to the secondary companion when the primary companion crashes or you issue a shutdown with nowait, triggering failover.
See “Add Entries for Both Adaptive Servers to the Interfaces File” for information about adding this line to the interfaces file.
Write application failover messages according to the following parameters:
As soon as the companion begins to go down, clients receive an informational message that failover is about to occur. Treat this as an informational message in the client error handlers.
Once the failover property is set (from step 1) and the interfaces file has a valid entry for the hafailover server, the client connection is an failover connection, and clients reconnect to the secondary companion appropriately.
However, if the failover property is set but the interfaces file does not have a entry for the hafailover server (or vice-versa), then it is a not a failover connection. Instead, it is a normal non-high availability connection with the failover property turned off. The user must check the failover property to know whether or not the connection was a failover connection
Add return codes
When a successful failover occurs, the client issues a return value named CS_RET_HAFAILOVER, which is specific to the following CTLIB API calls:
ret = ct_results(cmd, result_type)
ret = ct_send(cmd)
CS_RET_HAFAILOVER is returned from the API call during a synchronous connection. In an asynchronous connection, these API `s issue CS_PENDING and the callback function returns CS_RET_HAFAILOVER. Depending on the return code, the customer can do the required processing, such as sending the next command to be executed.
Rebuild your applications, linking them with the libraries included with the failover software.
You cannot connect clients with the failover property (for example isql -Q) until you issue sp_companion resume. If you do try to reconnect them after issuing sp_companion prepare_failback, the client hangs until you issue sp_companion resume.