Ex_repquote: a replication example
Ex_repquote, found in the examples_c/ex_repquote subdirectory of the Berkeley DB distribution, is a simple but complete demonstration of a replicated application. The application is a mock stock ticker. The master accepts a stock symbol and an integer value as input, stores this information into a replicated database; the clients display the contents of the database every few seconds.
The ex_repquote application's communication infrastructure is based on TCP/IP sockets, and uses POSIX 1003.1 style networking/socket support. As a result, it is not as portable as the Berkeley DB library itself. The Makefile created by the standard UNIX configuration will build the ex_repquote application on most platforms. Enter "make ex_repquote" to attempt to build it.
The synopsis for ex_repquote is as follows:
ex_repquote [-MC] [-h home] [-m host:port] [-o host:port] [-n sites] [-p priority]
The options to ex_repquote are as follows:
A typical ex_repquote session begins with a command such as the following, to start a master:
ex_repquote -M -p 100 -n 4 -h DIR1 -m localhost:5000
and several clients:
ex_repquote -C -p 50 -n 4 -h DIR2 -m localhost:5001 -o localhost:5000 ex_repquote -C -p 10 -n 4 -h DIR3 -m localhost:5002 -o localhost:5000 ex_repquote -C -p 0 -n 4 -h DIR4 -m localhost:5003 -o localhost:5000
In this example, the client with home directory DIR4 can never become a master (its priority is 0). Both of the other clients can become masters, but the one with home directory DIR2 is preferred. Priorities are assigned by the application and should reflect the desirability of having particular clients take over as master in the case that the master fails.