Skip to main content

Replication C++ tutorial

Replication quick start tutorial for C++ programmers

Two tutorials are provided to assist you in learning to use the Replication API. They are for JSON and C++ programmers.

These two tutorials are in the following directories:
  • drivers\cpp.replication\

    This folder contains the tutorial for the Replication C++ API.

  • drivers\java.rest.replication

    This folder contains the tutorial for the Replication JSON RPC API.

These tutorials provide examples of how to use these APIs. They include sample projects that you can compile and run. After compiling the projects, you will start the servers and define the source and target folders that will be used for replication. You can run the projects in debug mode and add breakpoints so you can see how the various calls are used. Additionally, you can review the source code to study the use of the APIs. Procedures for these tutorials are provided in this section.

Requirements:
  1. Compile and run this tutorial to create a simple replication environment. The tutorial code is in the cpp.replication or java.rest.replication folder of the <faircom>\drivers folder.

  2. Ensure you have already installed the Replication Manager package for your desired platform.

  3. Navigate to the Replication Manager directory and start a Replication server to create an empty replication database.

  4. Start two FairCom servers and create source and target directories for replication.

  5. Locate the source provided in the tutorial directory.

Compile and run the C++ high-level API example:
  1. Compile the tutorial using BuildTutorial.bat (BuildTutorial shell file or makefile on Linux platforms).

    Note

    • BuildTutorial.bat needs to be run from the Visual Studio x64 Native Tools command prompt unless vcvars64.bat is run prior to running BuildTutorials.bat.

    • Use the x64 platform.

    • The only DLL linked for the API is fcRepl.dll. The apiTestCPP.exe has dependencies on several DLLs (fcRepl.dllRCESDPCtree.dllRCESBasic.dllctReplAgent.dllctExtFileFilter.dll).

  2. Start the replication server (memphis.exe on Windows and memphis on Linux) from the Replication package to create an empty replication database.

  3. Prepare two FairCom servers to serve as the source server and the target server.

  4. Ensure the following two lines (after "; Plugins") are uncommented in ctsrvr.cfg.

    ; Plugins
    
    PLUGIN cthttpd;./web/cthttpd.dll
    
    PLUGIN ctagent;./agent/ctagent.dll
  5. Start servers 1 and 2 to populate both DBEngines into Replication Agent.

  6. Create a source data directory on the source machine — for example, c:\temp.

  7. Create a target data directory on the target machine — for example, c:\temp2.

  8. Place some FairCom files that qualify for replication in the c:\temp source directory.

  9. Execute (or run in debug) apiTestCPP.exe.

    Note

    This step uses the masterAuthFile.set authentication file with both user and password encrypted to connect to the replication server.

    1. Select one server from the provided list as the source DBEngine.

    2. Enter the source data path as c:\temp.

      Note

      The path must match the directory name made in Step 6.

    3. Ensure that the files placed in the source data directory are correctly listed.

    4. Select another server from the provided list as the target DBEngine.

    5. Enter the target data path as c:\temp2.

      Note

      The path must match the directory name made in Step 7.

    6. Ensure that the files placed in the target data directory are correctly listed.

  10. Open the graphical interface (https://localhost:8440/ReplicationManager/) in a web browser to view what has been executed.