HA_Stateful

This sample demonstrates eXtremeDB High Availability stateful replication. In stateful replication the master application is informed of the state of a replica’s database when the replica connects. Since a system failure could result in a replica being dropped while transactions are in progress, that replica database will not be synchronized with the master database. To address this the master application can request the HA runtime to maintain a buffer of transactions which can then be replayed to synchronize the replica database when it reconnects.

The master application declares a transaction buffer and the number of “additional transactions” after detaching replicas (note that this number must be less than the transaction buffer length). Then the master creates and populates the database and enters a loop creating and deleting objects as it waits for connection requests from replicas.

After a specified count all replicas are detached by the master.

How to Run

See instructions here on how to build this and other samples on your development platform. Once built, the sample can be run from the \target\bin directory.

In a console window run:

 
    hastateful_master
     

Additional transactions are committed by the master as it waits for replicas to reconnect; then reports the number of transactions and replicas.

In a second console window run:

 
    hastateful_replica
 

The replica application makes two calls to attach_master(), so after the master detaches it, it automatically re-connects. On the second call to attach_master() it loads its latest copy of the master database, and receives commit data from the master for the missed transactions.

But it is more instructive to run one instance in your development environment debugger, stepping through the code.

Related Topics Link IconRelated Topics