11.23. Setting Replication Session Hooks

Client applications can have some control over when the Directory Server performs replication by using custom plug-ins that define replication session hooks. The hooks apply to both the master sending the information and the consumer receiving the information. Basically, the master sends a preliminary message to the consumer and the consumer sends a response message. If either side sends a message that does not meet the expected criteria (such as the server version or some schema requirement), then the replication operation is terminated.
The intent of replication session hooks is to require some kind of parity between the servers involved in replication. If there is a situation that could cause conflicts or data corruption — such as different server versions which use different sets of schema — then the session hooks identify that potential problem. This prevents replication when it could hurt server performance.
The session hooks are implemented through callback functions in the Directory Server replication functions.
The call backs are defined in an ordered array that follows the replication operation process from initializing the replication agreement to receiving the response from the consumer.
static void *test_repl_session_api[] = {
   NULL, /* reserved for api broker use, must be zero */
   test_repl_session_plugin_agmt_init_cb,
   test_repl_session_plugin_pre_acquire_cb,
   test_repl_session_plugin_reply_acquire_cb,
   test_repl_session_plugin_post_acquire_cb,
   test_repl_session_plugin_recv_acquire_cb,
   test_repl_session_plugin_destroy_cb
};
Then, the custom replication plug-in registers the callbacks. In this example, it requires a certain version of the server.
int test_repl_session_plugin_init(Slapi_PBlock *pb)
{
...
   if( slapi_apib_register(REPL_SESSION_v1_0_GUID, test_repl_session_api) ) {
       slapi_log_error( SLAPI_LOG_FATAL, test_repl_session_plugin_name,
                        "<-- test_repl_session_plugin_start -- failed to register repl_session api -- end\n");
       return -1;
   }
...
}

Note

The callbacks themselves are described in the Plug-in Programmer's Guide. This example is provided to make administrators and programmers aware that the replication process can be controlled by using these session hooks.