Google

DbEnv::rep_process_message

APIRef

#include <db_cxx.h>

int DbEnv::rep_process_message(Dbt *control, Dbt *rec, int *envid)

Description

The DbEnv::rep_process_message method processes an incoming replication message sent by a member of the replication group to the local database environment.

The rec and control parameters should reference a copy of the parameters specified by Berkeley DB for the rec and control parameters on the sending environment.

The envid parameter should contain the local identifier that corresponds to the environment that sent the message to be processed (see Replication environment IDs for more information).

For implementation reasons, all incoming replication messages must be processed using the same DbEnv handle. It is not required that a single thread of control process all messages, only that all threads of control processing messages use the same handle.

If a new master has been elected, the DbEnv::rep_process_message method will return DB_REP_NEWMASTER. The envid parameter contains the environment ID of the new master. If the recipient of this error return has been made master, it is the application's responsibility to begin acting as the master environment.

If the system received contact information from a new environment, the DbEnv::rep_process_message method will return DB_REP_NEWSITE. The rec parameter contains the opaque data specified in the cdata parameter to the DbEnv::rep_start. The application should take whatever action is needed to establish a communication channel with this new environment.

If the replication group has more than one master, the DbEnv::rep_process_message method either returns DB_REP_DUPMASTER or throws an exception that encapsulates DB_REP_DUPMASTER. The application should reconfigure itself as a client by calling the DbEnv::rep_start method, and then call for an election by calling DbEnv::rep_elect.

If an election is needed, the DbEnv::rep_process_message method either returns DB_REP_HOLDELECTION or throws an exception that encapsulates DB_REP_HOLDELECTION. The application should call for an election by calling DbEnv::rep_elect.

If the current environment's logs are too far out of date with respect to the master to be automatically synchronized, the DbEnv::rep_process_message method either returns DB_REP_OUTDATED or throws an exception that encapsulates DB_REP_OUTDATED. The application should copy over a hot backup of the environment, run recovery, and restart the client.

Otherwise, the DbEnv::rep_process_message method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

Errors

The DbEnv::rep_process_message method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. If a catastrophic error has occurred, the DbEnv::rep_process_message method may fail and either return DB_RUNRECOVERY or throw a DbRunRecoveryException, in which case all subsequent Berkeley DB calls will fail in the same way.

Class

DbEnv

See Also

Replication and Related Methods

APIRef

Copyright Sleepycat Software