Berkeley DB Reference Guide:
Berkeley DB Replication
PrevRefNext

Building the communications infrastructure

Replication Manager provides a built-in communications infrastructure.

For applications that use the Base replication API, which must provide their own communications infrastructure, it is typically written with one or more threads of control looping on one or more communication channels, receiving and sending messages. These threads accept messages from remote environments for the local database environment, and accept messages from the local environment for remote environments. Messages from remote environments are passed to the local database environment using the DB_ENV->rep_process_message method. Messages from the local environment are passed to the application for transmission using the callback function specified to the DB_ENV->rep_set_transport method.

Processes establish communication channels by calling the DB_ENV->rep_set_transport method, regardless of whether they are running in client or server environments. This method specifies the send function, a callback function used by Berkeley DB for sending messages to other database environments in the replication group. The send function takes an environment ID and two opaque data objects. It is the responsibility of the send function to transmit the information in the two data objects to the database environment corresponding to the ID, with the receiving application then calling the DB_ENV->rep_process_message method to process the message.

The details of the transport mechanism are left entirely to the application; the only requirement is that the data buffer and size of each of the control and rec DBTs passed to the send function on the sending site be faithfully copied and delivered to the receiving site by means of a call to DB_ENV->rep_process_message with corresponding arguments. Messages that are broadcast (whether by broadcast media or when directed by setting the DB_ENV->rep_set_transport method's envid parameter DB_EID_BROADCAST), should not be processed by the message sender. In all cases, the application's transport media or software must ensure that DB_ENV->rep_process_message is never called with a message intended for a different database environment or a broadcast message sent from the same environment on which DB_ENV->rep_process_message will be called. The DB_ENV->rep_process_message method is free-threaded; it is safe to deliver any number of messages simultaneously, and from any arbitrary thread or process in the Berkeley DB environment.

There are a number of informational returns from the DB_ENV->rep_process_message method:


DB_REP_DUPMASTER DB_REP_HOLDELECTION DB_REP_IGNORE DB_REP_ISPERM DB_REP_NEWSITE DB_REP_NOTPERM

PrevRefNext

Copyright (c) 1996,2008 Oracle. All rights reserved.