本文整理汇总了C++中DB_ENV::get_backup_config方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_ENV::get_backup_config方法的具体用法?C++ DB_ENV::get_backup_config怎么用?C++ DB_ENV::get_backup_config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_ENV
的用法示例。
在下文中一共展示了DB_ENV::get_backup_config方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestBackupSimpleEnvWithConfig
int TestBackupSimpleEnvWithConfig(CuTest *ct) {
DB_ENV *dbenv;
DB *dbp;
DBTYPE dtype;
struct handlers *info;
char **names;
int cnt, has_callback;
time_t end_time, secs1, secs2, start_time;
u_int32_t flag, value;
dtype = DB_BTREE;
info = ct->context;
has_callback = 0;
flag = DB_EXCL;
end_time = secs1 = secs2 = start_time = 0;
/* Step 1: set up directories. */
CuAssert(ct, "setup_dir", setup_dir(0, NULL) == 0);
/* Step 2: open db handle. */
CuAssert(ct, "open_dbp", open_dbp(&dbenv,
&dbp, dtype, 0, NULL, NULL, NULL, 0, NULL) == 0);
info->dbenvp = dbenv;
info->dbp = dbp;
/*
* Step 3: store records into db so that there is more than
* 1 data page in the db.
*/
CuAssert(ct, "store_records", store_records(dbp, 10) == 0);
CuAssert(ct, "DB->sync", dbp->sync(dbp, 0) == 0);
/*
* Step 4: verify the backup handle is NULL,
* since we never configure the backup.
*/
CuAssert(ct, "DB_ENV->get_backup_config",
dbenv->get_backup_config(dbenv,
DB_BACKUP_WRITE_DIRECT, &value) == EINVAL);
/*
* Step 5: backup without any backup configs.
* 5a: backup only the db file without callbacks and record the time.
*/
start_time = time(NULL);
CuAssert(ct, "backup_db",
backup_db(ct, dbenv, BACKUP_DB, flag, has_callback) == 0);
end_time = time(NULL);
secs1 = end_time - start_time;
/* 5b: verify db file is in BACKUP_DIR. */
CuAssert(ct, "verify_db_log",
verify_db_log(dtype, 0, 0, NULL, NULL) == 0);
/* 5c: verify that no other files are in BACKUP_DIR. */
CuAssert(ct, "__os_dirlist",
__os_dirlist(NULL, BACKUP_DIR, 0, &names, &cnt) == 0);
CuAssert(ct, "too many files in backupdir", cnt == 1);
/* Clean up the backup directory. */
setup_envdir(BACKUP_DIR, 1);
/*
* Step 6: backup with backup configs.
* 6a: configure the backup handle: use direct I/O to write pages to
* the disk, the backup buffer size is 256 bytes (which is smaller
* than the db page size), the number of pages
* to read before pausing is 1, and the number of seconds to sleep
* between batches of reads is 1.
*/
CuAssert(ct, "DB_ENV->set_backup_config",
dbenv->set_backup_config(dbenv, DB_BACKUP_WRITE_DIRECT, 1) == 0);
CuAssert(ct, "DB_ENV->set_backup_config",
dbenv->set_backup_config(dbenv, DB_BACKUP_SIZE, 256) == 0);
CuAssert(ct, "DB_ENV->set_backup_config",
dbenv->set_backup_config(dbenv, DB_BACKUP_READ_COUNT, 1) == 0);
CuAssert(ct, "DB_ENV->set_backup_config",
dbenv->set_backup_config(dbenv,
DB_BACKUP_READ_SLEEP, US_PER_SEC / 2) == 0);
/*
* 6b: backup only the db file without callbacks and
* record the time.
*/
start_time = time(NULL);
CuAssert(ct, "backup_db",
backup_db(ct, dbenv, BACKUP_DB, flag, has_callback) == 0);
end_time = time(NULL);
secs2 = end_time - start_time;
/* 6c: verify db file is in BACKUP_DIR. */
CuAssert(ct, "verify_db_log",
verify_db_log(dtype, 0, 0, NULL, NULL) == 0);
/* 6d: no other files are in BACKUP_DIR. */
CuAssert(ct, "__os_dirlist",
__os_dirlist(NULL, BACKUP_DIR, 0, &names, &cnt) == 0);
CuAssert(ct, "too many files in backupdir", cnt == 1);
/* 6e: verify the backup config. */
//.........这里部分代码省略.........