Product Documentation

FairCom Replication API for C and C++

Previous Topic

Next Topic

Tutorial

The tutorial for the C/C++ replication API is different than other FairCom tutorials. While the other tutorials concentrate on the basic procedures needed to initialize, define, manage, and disconnect in order to manipulate tables and records, the replication tutorial explores the techniques for connecting to the Replication database and defining and managing replication plans.

Two tutorials are provided to assist you in learning to use the replication API. Tutorials are provided for both the Replication REST and C/C++ APIs. They are located in the following directories:

  • sdk\ctree.cpp.replication
    This folder contains the tutorial for use with C or C++ (the API discussed in this document) - C/C++ Replication API Developer's Guide (https://docs.faricom.com/doc/repl_c_cpp_api)
  • sdk\restapi.replicationrepl - This folder contains the tutorial for the REST API - Replication REST API Developer's Guide (https://docs.faircom.com/doc/repl_rest_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.

Steps to Use the C/C++ Tutorial

A tutorial is included in the sdk\ctree.cpp.replication folder. You can compile and run this tutorial to create a simple replication environment.

Be sure you have already installed the “c-treeACE-OpsManager*” package for your desired platform. Next, change into the “OpsManager” directory and start a Replication server (which will create an empty Replication database).

You will also start two c-tree servers and create source and target directories for replication. These simple steps are enough to get you started with replication.

The source is provided in the tutorial directory

To compile and run the C/C++ high-level API example, perform the following steps:

  1. Windows only: Open the Developer Command Prompt window for your version of Microsoft Visual Studio. Typically, this is available from the Start menu, selecting menu options similar to: Visual Studio 2017 > X64 Native Tools Command prompt for VS 2017 where 2017 is your version of Visual Studio and X64 is for a 64-bit version of c-tree (note “64” in the name of the default installation directory) or X86 for a 32-bit version of c-tree.

    Warning - If the Developer Command Prompt Start menu entry does not specify a bit depth, it will open the 32-bit version of the Developer Command Prompt.

    For more details, see the Microsoft Developer Command Prompt web page.

    In the Developer Command Prompt window, move to the drivers\cpp.replication\tutorials\cmdline directory and execute the BuildTutorials.bat file.

    Note: the only DLL linked for the API is fcRepl.dll. The apiTestCPP.exe has dependencies on several DLLs (fcRepl.dll, RCESDPCtree.dll, RCESBasic.dll, ctReplAgent.dll, ctExtFileFilter.dll)

  2. Linux Only: Open a command shell, navigate to the drivers\cpp.replication\tutorials\cmdline directory, and type 'make'.
  3. Start the Replication server (memphis.exe on Windows, and memphis on Linux) from the Replication package. This will create an empty Replication database.
  4. Prepare 2 c-tree Servers to serve as the Soruce Server and the Target Server.
    Be sure following 2 lines are uncommented in ctsrvr.cfg:
    ; Plugins
    PLUGIN cthttpd;./web/cthttpd.dll
    PLUGIN ctagent;./agent/ctagent.dll
  5. Start servers 1 and 2. This will populate both DBEngines into <FC_PROD_RPL>.
  6. Create a source data directory on the source machine: c:\temp for example.
  7. Create a target data directory on the target machine: c:\temp2 for example.
  8. Place some c-tree files that qualify for replication in the c:\temp source directory;
  9. Execute (or run in Debug) apiTestCPP.exe
  • This step uses the masterAuthFile.set authentication file with both user and password encrypted to connect to the Replication server.
    a. Select one server as the source DBEngine from the provided list.
    b. Enter the source data path as c:\temp (the path must match the directory name in step 3).
    c. Check that the files placed in the source data directory are correctly listed.
    d. Select another server as the target DBEngine from the provided list.
    e. Enter the target data path as c:\temp2 (the path must match the directory name in step 4);
    f. Confirm the other entries.
  • Open the graphical interface in a Web browser so you can see what has been executed: https://localhost:8443/ReplicationManager/

TOCIndex