本文整理汇总了C++中DB_ENV::rep_set_timeout方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_ENV::rep_set_timeout方法的具体用法?C++ DB_ENV::rep_set_timeout怎么用?C++ DB_ENV::rep_set_timeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_ENV
的用法示例。
在下文中一共展示了DB_ENV::rep_set_timeout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
int
main(int argc, char *argv[])
{
DB_ENV *dbenv;
DB_SITE *dbsite;
extern char *optarg;
const char *home;
char ch, *host, *portstr;
int local_is_set, ret, is_group_creator;
u_int16_t port;
/* Used to track whether this is a replica or a master. */
APP_DATA my_app_data;
dbenv = NULL;
ret = local_is_set = is_group_creator = 0;
home = NULL;
my_app_data.is_master = 0; /* Assume that we start as a replica */
if ((ret = create_env(progname, &dbenv)) != 0)
goto err;
/* Make APP_DATA available through the environment handle. */
dbenv->app_private = &my_app_data;
/* Default priority is 100. */
dbenv->rep_set_priority(dbenv, 100);
/* Permanent messages require at least one ack. */
dbenv->repmgr_set_ack_policy(dbenv, DB_REPMGR_ACKS_ONE);
/* Give 500 microseconds to receive the ack. */
dbenv->rep_set_timeout(dbenv, DB_REP_ACK_TIMEOUT, 500);
/* Collect the command line options. */
while ((ch = getopt(argc, argv, "h:l:L:p:r:")) != EOF)
switch (ch) {
case 'h':
home = optarg;
break;
/* Set the host and port used by this environment. */
case 'L':
is_group_creator = 1; /* FALLTHROUGH */
case 'l':
host = strtok(optarg, ":");
if ((portstr = strtok(NULL, ":")) == NULL) {
fprintf(stderr, "Bad host specification.\n");
goto err;
}
port = (unsigned short)atoi(portstr);
if ((ret =
dbenv->repmgr_site(dbenv, host, port, &dbsite, 0)) != 0){
fprintf(stderr, "Could not set local address %s:%d.\n",
host, port);
goto err;
}
dbsite->set_config(dbsite, DB_LOCAL_SITE, 1);
if (is_group_creator)
dbsite->set_config(dbsite, DB_GROUP_CREATOR, 1);
if ((ret = dbsite->close(dbsite)) != 0) {
dbenv->err(dbenv, ret, "DB_SITE->close");
goto err;
}
local_is_set = 1;
break;
/* Set this replica's election priority. */
case 'p':
dbenv->rep_set_priority(dbenv, atoi(optarg));
break;
/* Identify another site in the replication group. */
case 'r':
host = strtok(optarg, ":");
if ((portstr = strtok(NULL, ":")) == NULL) {
fprintf(stderr, "Bad host specification.\n");
goto err;
}
port = (unsigned short)atoi(portstr);
if ((ret = dbenv->repmgr_site(dbenv, host, port, &dbsite, 0)) != 0) {
dbenv->err(dbenv, ret, "DB_ENV->repmgr_site");
goto err;
}
dbsite->set_config(dbsite, DB_BOOTSTRAP_HELPER, 1);
if ((ret = dbsite->close(dbsite)) != 0) {
dbenv->err(dbenv, ret, "DB_SITE->close");
goto err;
}
break;
case '?':
default:
usage();
}
/* Error check command line. */
if (home == NULL || !local_is_set)
usage();
if ((ret = env_init(dbenv, home)) != 0)
goto err;
if ((ret = dbenv->repmgr_start(dbenv, 3, DB_REP_ELECTION)) != 0)
goto err;
//.........这里部分代码省略.........