This sample contains C and Java applications that demonstrate solidDB HotStandby (HSB) high availability functionality and also a Watchdog application that can monitor both HSB servers and switch the states of the servers when necessary.
The files for the sample are located in the soliddb-installdir\samples\hsb directory. For general information about running the samples, see Samples.
The sample includes the following three applications:
▪ hsb.c (samples\hsb\application_c): a C application that connects to a pair of solidDB HSB servers, creates a table on the primary server, populates the table and then runs queries to show that the databases on each server have the same data.
▪ watchdog.c (samples\hsb\watchdog): a C application that monitors the HSB servers and switches the state of servers when it detects that a server is unavailable. For more information about how the Watchdog application works, see Watchdog sample application.
▪ Sample_Hsb.java (samples\hsb\application_java): a Java application that demonstrates the same functionality as hsb.c.
Note This application is not included in the main runme script that is described in the following paragraphs, however, you can run the application from the runme script in the samples\hsb\application_java directory.
Running the sample
Run the runme script (runme.bat in Windows), which completes the following actions to demonstrate HSB operation and the application functionality:
1 Compile the applications (hsb.exe and watchdog.exe).
2 Start two servers with default parameters (the servers are configured as HSB servers in solid.ini so both servers start in SECONDARY_ALONE state).
3 On one of the servers, run Primary1a.sql, which sets the server to be the primary server with state set to PRIMARY ALONE.
4 On the primary server, run Primary1b.sql, which creates a table and a procedure that will populate the table, and then use the command ADMIN COMMAND 'hsb netcopy' to make a copy of the database on the secondary server (which remains in SECONDARY ALONE state).
For details of the 'hsb netcopy' command, see HOTSTANDBY.
5 On the primary server, wait 30 seconds and then run Primary2.sql to check that the netcopy command has completed.
6 On the secondary server, run Secondary1.sql, which queries the server to check that the table exists and is empty.
7 On the primary server, run Primary3a.sql, which instructs the server to connect to the secondary server and then verify that the server is in PRIMARY ACTIVE state (HSB is fully operational).
8 On the primary server, run Primary3b.sql, which uses the procedure to populate the table with one row and runs a query to validate that the row exists.
9 On the secondary server, run Secondary2.sql, which validates that the same row exists in the table that is on the secondary server.
10 Run the hsb.exe application, which executes a similar set of steps.
The sample then performs the following steps to demonstrate the Watchdog program:
11 Start the Watchdog application, which shows that the servers are in PRIMARY ACTIVE and SECONDARY ACTIVE states.
12 Shut down the primary server.
The Watchdog application registers that the primary server is not available and switches the current secondary server to be the primary server with the state PRIMARY ALONE.