A demo is included in your product package to give you an idea of how the replication solution operates. This demo is a good starting point to familiarize yourself with the basic concepts of this comprehensive replication solution. The demo is located in the following folder:
drivers\java.rest.replication
This demo is useful to developers who want to experiment with the replication RPC API. You can read the Replication RPC API Developer's Guide to learn more about using this extensive API to control replication in your c-tree environment.
Overview
For testing, you will need to set up three servers:
To simplify the c-tree replication tutorial, the example configuration in this document places all of these servers on a single computer. Although this is not considered a “real world” configuration, it is useful for learning.
It is recommended that you follow the example configuration shown below when using this demo for the first time. Notice that each server must be installed in a separate folder.
Requirements:
To run this demo with the default configuration you will need the following:
Separate Folders
The first task in using the example is to install and two copies of c-tree on your test computer. Each should be placed in a separate folder.
Configuring Replication Manager
You will not start either of the servers or the Replication Manager until you have edited their configuration files. There are up to three configuration files that need to be edited in the server/config folder of each of the three servers (“source”, “target”, and “Memphis”). Additionally, the demo program itself needs to be configured by editing a few lines of its source code.
1. Configure and Build the Demo
drivers\java.rest.replication\ReplFileDemo\src\main\java\replfiledemo\ReplFileDemo.java
In particular, change the following:
Change the memphisURL variable to match the location of your Memphis server and the primaryDbeName and secondaryDbeName variables to match your server names.
Change variables primaryFileDir and secondaryFileDir if the files are not located in the default server directory (LOCAL_DIRECTORY in ctsrvr.cfg).
If you are using the recommended example configuration, the relevant lines of the Java program should look like this:
public class ReplFileDemo
{
static boolean debug = false;
static String memphisURL = "http://localhost:8080/ReplicationManager/";
static String memphisUser = "admin";
static String memphisPassword = "ADMIN";
static String primaryDbeName = "FAIRCOMS";
static String secondaryDbeName = "FAIRCOM2";
static String dbName = "ctreeSQL";
static String planName = "ReplPlan1";
static String primaryFileDir = null; // default to LOCAL_DIRECTORY
static List<String> primaryFileNames = Arrays.asList("custmast.dat","custordr.dat","itemmast.dat","ordritem.dat");
static String secondaryFileDir = null; // default to LOCAL_DIRECTORY
gradlew build
2. Configure the c-tree and Memphis servers
Configure the Memphis server and the Source and Target c-tree servers. To do this, you need to change various lines in three configuration files (ctagent.json, cthttpd.json, and ctsrvr.cfg) in the server/config folder of each of the three servers (Memphis, source, and target). In other words, you need to look at a few lines in each of nine different files. To simplify this task, here is our example configuration, with each of the nine files listed and the lines that should be validated for each of them:
Memphis:
ctagent.json
accept_conn true
memphis_sql_port 7000
memphis_host 127.0.0.1
cthttpd.json
listening_http_port 8080
listening_https_port 8443
mqtt_listening_port n/a
mqtt_websocket_port n/a
ctsrvr.cfg
SERVER_NAME MEMPHIS
SERVER_PORT 5532
PLUGIN cthttpd (uncomment)
PLUGIN ctagent (uncomment)
SQL_PORT 7000
Source c-tree server:
ctagent.json
accept_conn true
memphis_sql_port 7000
memphis_host 127.0.0.1
cthttpd.json
listening_http_port 8084
listening_https_port 8445
mqtt_listening_port 1884
mqtt_websocket_port 8082
ctsrvr.cfg
SERVER_NAME FAIRCOMS
SERVER_PORT 5598
PLUGIN cthttpd (uncomment)
PLUGIN ctagent (uncomment)
SQL_PORT 6597
Target c-tree server:
ctagent.json
accept_conn true
memphis_sql_port 7000
memphis_host 127.0.0.1
cthttpd.json
listening_http_port 8083
listening_https_port 8444
mqtt_listening_port 1883
mqtt_websocket_port 8081
ctsrvr.cfg
SERVER_NAME FAIRCOM2
SERVER_PORT 5597
PLUGIN cthttpd (uncomment)
PLUGIN ctagent (uncomment)
SQL_PORT 6598
Note that this configuration assumes that all nodes are being run on the same computer.
Some notes about the above settings for the Source and Target Servers:
3. Start the Servers
4. Create Files
Create files by running ctdb_Tutorial4.exe on FAIRCOMS. The easiest way to do this is to run BuildTutorials.bat or make run in the drivers/c.nav/tutorials/cmdline/ directory.
5. Run the Demo
Execute the commands shown below to perform the following actions.
To set up (but not start) replication:
gradlew run --args=setup
To get the current replication status:
gradlew run --args=status
To redeploy all files in the replication plan:
gradlew run --args=redeploy
To resync all files in the replication plan:
gradlew run --args=resync
To stop the replication plan:
gradlew run --args=stop
To stop replication and remove all replication plans and publications:
gradlew run --args=cleanup
You are now ready to view the Replication RPC API Developer's Guide to learn more about using this API to control replication in your c-tree environment.