DbEnv::rep_elect
|
|
#include <db_cxx.h>
int
DbEnv::rep_elect(int nsites, int nvotes,
int priority, u_int32_t timeout, int *envid, u_int32_t flags);
Description: DbEnv::rep_elect
The DbEnv::rep_elect method holds an election for the master of a replication
group.
If the election is successful, the new master's ID may be the ID of the
previous master, or the ID of the current environment. The application
is responsible for adjusting its usage of the other environments in the
replication group, including directing all database updates to the newly
selected master, in accordance with the results of this election.
The thread of control that calls the DbEnv::rep_elect method must not be the
thread of control that processes incoming messages; processing the
incoming messages is necessary to successfully complete an election.
Parameters
- envid
- The envid parameter references memory into which
the newly elected master's ID is copied.
- nsites
- The nsites parameter indicates the number of environments that
the application believes are in the replication group. This number is
used by Berkeley DB to avoid having two masters active simultaneously, even
in the case of a network partition. During an election, a new master
cannot be elected unless more than half of nsites agree on the
new master. Thus, in the face of a network partition, the side of the
partition with more than half the environments will elect a new master
and continue, while the environments communicating with fewer than half
the other environments will fail to find a new master.
- nvotes
- The nvotes parameter indicates the number of votes required by
the application to successfully elect a new master. It must be a
positive integer, no greater than nsites, or 0 if the election
should use a simple majority of the nsites value as the
requirement. A warning is given if half or fewer votes are required to
win an election as that can potentially lead to multiple masters in the
face of a network partition.
- priority
- The priority parameter is the priority of this environment. It
must be a positive integer, or 0 if this environment is not permitted
to become a master (see Replication
environment priorities for more information).
- timeout
- The timeout parameter specifies a timeout period for an election.
If the election has not completed after timeout microseconds, the
election will fail.
- flags
- The flags parameter is currently unused, and must be set to 0.
Errors
The DbEnv::rep_elect method
may fail and throw
DbException,
encapsulating one of the following non-zero errors, or return one of
the following non-zero errors:
- DB_REP_UNAVAIL
- The replication group was unable to elect a master, or was unable to
complete the election in the specified timeout period.
Class
DbEnv
See Also
Replication and Related Methods
Copyright (c) 1996-2004 Sleepycat Software, Inc. - All rights reserved.