当前位置: 首页>>代码示例>>C++>>正文


C++ DB_ENV::set_lk_max_objects方法代码示例

本文整理汇总了C++中DB_ENV::set_lk_max_objects方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_ENV::set_lk_max_objects方法的具体用法?C++ DB_ENV::set_lk_max_objects怎么用?C++ DB_ENV::set_lk_max_objects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB_ENV的用法示例。


在下文中一共展示了DB_ENV::set_lk_max_objects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestSetLockMaxObjects

int TestSetLockMaxObjects(CuTest *ct) {
	DB_ENV *dbenv;
	u_int32_t v;

	dbenv = NULL;
	/* lk_max_objects: NOT reset at run-time. */
	ENV
	CuAssertTrue(ct, dbenv->set_lk_max_objects(dbenv, 1037) == 0);
	CuAssertTrue(ct, dbenv->open(dbenv,
	    TEST_ENV, DB_CREATE | DB_INIT_LOCK, 0666) == 0);
	CuAssertTrue(ct, dbenv->get_lk_max_objects(dbenv, &v) == 0);
	CuAssertTrue(ct, v == 1037);
	ENV
	CuAssertTrue(ct, dbenv->set_lk_max_objects(dbenv, 1063) == 0);
	CuAssertTrue(ct, dbenv->open(dbenv, TEST_ENV, DB_JOINENV, 0666) == 0);
	CuAssertTrue(ct, dbenv->get_lk_max_objects(dbenv, &v) == 0);
	CuAssertTrue(ct, v == 1037);
	return (0);
}
开发者ID:CompassHXM,项目名称:h-store,代码行数:19,代码来源:TestEnvConfig.c

示例2: sizeof

/*
 *  This should be done before the program is open for business.
 *  As such, it does not need to be reentrant.
 */
int
open_db_env(char *topdir)
{
	DB_ENV		*tmpenv = NULL;
	int		st;
	struct stat64	sbuf;
	char		logdir[MAXPATHLEN+1];
	char		tmpdir[MAXPATHLEN+1];
	char		*dirarr[3];
	int		i;

	if (topdir == NULL) {
		return (-1);
	}

	snprintf(logdir, sizeof (tmpdir), "%s/.logs", topdir);
	snprintf(tmpdir, sizeof (tmpdir), "%s/.tmp", topdir);

	dirarr[0] = topdir;
	dirarr[1] = logdir;
	dirarr[2] = tmpdir;

	/* first, set up the environment */
	st = db_env_create(&tmpenv, 0);

	if (st != 0) {
		return (st);
	}

	/* make sure the directories exist */
	for (i = 0; i < 3; i++) {
		st = stat64(dirarr[i], &sbuf);
		if ((st != 0) && (errno == ENOENT)) {
			st = mkdirp(dirarr[i], 0744);
			if (st == 0) {
				st = stat64(dirarr[i], &sbuf);
			}
		}
		if ((st == 0) && (!S_ISDIR(sbuf.st_mode))) {
			st = -1;
			break;
		}
	}

	if (st != 0) {
		return (st);
	}

	st = tmpenv->set_data_dir(tmpenv, topdir);
	if (st != 0) {
		return (st);
	}
	st = tmpenv->set_lg_dir(tmpenv, logdir);
	if (st != 0) {
		return (st);
	}

	st = tmpenv->set_tmp_dir(tmpenv, tmpdir);
	if (st != 0) {
		return (st);
	}

	st = tmpenv->set_flags(tmpenv, env_fl, 1);
	if (st != 0) {
		return (st);
	}

	/* overall database cache size */
	st = tmpenv->set_cachesize(tmpenv, 0, (60 * MEGA), 1);

	st = tmpenv->set_shm_key(tmpenv, FSM_SHM_MASTER_KEY);
	if (st != 0) {
		return (st);
	}

	/* log buffer in memory */
	st = tmpenv->set_lg_bsize(tmpenv, (30 * MEGA));
	if (st != 0) {
		return (st);
	}

	/* set up additional error logging */
	tmpenv->set_errcall(tmpenv, fsmdb_log_err);

	/* Increase the number of locks available */
	tmpenv->set_lk_max_locks(tmpenv, 10000);
	tmpenv->set_lk_max_lockers(tmpenv, 10000);
	tmpenv->set_lk_max_objects(tmpenv, 10000);

	/* Increase the number of concurrent transactions available */
	/* Note:  Default in 4.4-20 is '20'.  In later versions it's 100 */
	tmpenv->set_tx_max(tmpenv, 100);

	st = tmpenv->open(tmpenv, topdir, env_ofl, 0644);
	if (st != 0) {
		/* check for a major failure */
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:samqfs,代码行数:101,代码来源:mkdb.c

示例3: sizeof


//.........这里部分代码省略.........
	system("rm -rf TESTDIR; mkdir TESTDIR");
	ENV
	assert(dbenv->set_lk_detect(dbenv, DB_LOCK_MAXLOCKS) == 0);
	assert(dbenv->open(dbenv,
	    "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
	assert(dbenv->get_lk_detect(dbenv, &v) == 0);
	assert(v == DB_LOCK_MAXLOCKS);
	ENV
	assert(dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT) == 0);
	assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
	assert(dbenv->get_lk_detect(dbenv, &v) == 0);
	assert(v == DB_LOCK_MAXLOCKS);

	/* lk_max_locks: NOT reset at run-time. */
	system("rm -rf TESTDIR; mkdir TESTDIR");
	ENV
	assert(dbenv->set_lk_max_locks(dbenv, 37) == 0);
	assert(dbenv->open(dbenv,
	    "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
	assert(dbenv->get_lk_max_locks(dbenv, &v) == 0);
	assert(v == 37);
	ENV
	assert(dbenv->set_lk_max_locks(dbenv, 63) == 0);
	assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
	assert(dbenv->get_lk_max_locks(dbenv, &v) == 0);
	assert(v == 37);

	/* lk_max_lockers: NOT reset at run-time. */
	system("rm -rf TESTDIR; mkdir TESTDIR");
	ENV
	assert(dbenv->set_lk_max_lockers(dbenv, 37) == 0);
	assert(dbenv->open(dbenv,
	    "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
	assert(dbenv->get_lk_max_lockers(dbenv, &v) == 0);
	assert(v == 37);
	ENV
	assert(dbenv->set_lk_max_lockers(dbenv, 63) == 0);
	assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
	assert(dbenv->get_lk_max_lockers(dbenv, &v) == 0);
	assert(v == 37);

	/* lk_max_objects: NOT reset at run-time. */
	system("rm -rf TESTDIR; mkdir TESTDIR");
	ENV
	assert(dbenv->set_lk_max_objects(dbenv, 37) == 0);
	assert(dbenv->open(dbenv,
	    "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
	assert(dbenv->get_lk_max_objects(dbenv, &v) == 0);
	assert(v == 37);
	ENV
	assert(dbenv->set_lk_max_objects(dbenv, 63) == 0);
	assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
	assert(dbenv->get_lk_max_objects(dbenv, &v) == 0);
	assert(v == 37);

	/* lock timeout: reset at run-time. */
	system("rm -rf TESTDIR; mkdir TESTDIR");
	ENV
	assert(dbenv->set_timeout(dbenv, 37, DB_SET_LOCK_TIMEOUT) == 0);
	assert(dbenv->open(dbenv,
	    "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
	assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_LOCK_TIMEOUT) == 0);
	assert(timeout == 37);
	ENV
	assert(dbenv->set_timeout(dbenv, 63, DB_SET_LOCK_TIMEOUT) == 0);
	assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
	assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_LOCK_TIMEOUT) == 0);
	assert(timeout == 63);

	/* txn timeout: reset at run-time. */
	system("rm -rf TESTDIR; mkdir TESTDIR");
	ENV
	assert(dbenv->set_timeout(dbenv, 37, DB_SET_TXN_TIMEOUT) == 0);
	assert(dbenv->open(dbenv,
	    "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
	assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
	assert(timeout == 37);
	ENV
	assert(dbenv->set_timeout(dbenv, 63, DB_SET_TXN_TIMEOUT) == 0);
	assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
	assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
	assert(timeout == 63);

	/* cache size: NOT reset at run-time. */
	system("rm -rf TESTDIR; mkdir TESTDIR");
	ENV
	assert(dbenv->set_cachesize(dbenv, 1, 131072, 3) == 0);
	assert(dbenv->open(dbenv,
	    "TESTDIR", DB_CREATE | DB_INIT_MPOOL, 0666) == 0);
	assert(dbenv->get_cachesize(dbenv, &a, &b, &ncache) == 0);
	assert(dbenv->get_cachesize(dbenv, &a, &b, &ncache) == 0);
	assert(a == 1 && b == 131072 && ncache == 3);
	ENV
	assert(dbenv->set_cachesize(dbenv, 2, 262144, 1) == 0);
	assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
	assert(dbenv->get_cachesize(dbenv, &a, &b, &ncache) == 0);
	assert(a == 1 && b == 131072 && ncache == 3);

	return (0);
}
开发者ID:sukantoguha,项目名称:INET-Vagrant-Demos,代码行数:101,代码来源:test_env_config.c

示例4: main

int main(int argc, char **argv)
{
    // Deal with command line arguments
    const char *path2DbEnv = 0;
    u_int32_t envFlags = (DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL);
    u_int32_t txnEnvFlags =	(DB_INIT_TXN|DB_INIT_LOCK|DB_INIT_LOG);
    u_int32_t dbxmlFlags = DBXML_ALLOW_EXTERNAL_ACCESS;
    vector<string> scripts;
    int verbose = 0;
    bool transactionMode = false;
    bool dbPrivate = false;
    bool envCreate = false;
    const char *progName = argv[0];
    const char *password = 0;
    int cacheSize = 64;
    int ch;
    int ret = 0;

    while ((ch = getopt(argc, argv, "?h:hs:tvxVP:cz:")) != -1) {
        switch (ch) {
        case 'h': {
            path2DbEnv = optarg;
            break;
        }
        case 'z': {
            cacheSize = atoi(optarg);
            break;
        }
        case 'c': {
            envFlags &= ~DB_PRIVATE;
            envCreate = true;
            break;
        }
        case 'x': {
            dbxmlFlags &= ~DBXML_ALLOW_EXTERNAL_ACCESS;
            break;
        }
        case 't': {
            transactionMode = true;
            envFlags |= txnEnvFlags;
            break;
        }
        case 's': {
            scripts.push_back(optarg);
            break;
        }
        case 'v': {
            ++verbose;
            break;
        }
        case 'V': {
            printf("%s\n", DbXml::dbxml_version(NULL, NULL, NULL));
            printf("%s\n", db_version(NULL, NULL, NULL));
            exit(0);
        }
        case 'P': {
            password = optarg;
            break;
        }
        case '?':
        default: {
            usage(progName, 0);
            break;
        }
        }
    }

    // Turn on logging if extra verbose is specified
    if(verbose > 1) {
        setLogLevel(LEVEL_ALL, true);
        setLogCategory(CATEGORY_ALL, true);
        setLogCategory(CATEGORY_NODESTORE, verbose > 2);
        verboseErrors = true;
    }

    SigBlock sb; // block signals, resend at end of scope
    try {
        // Create a DB environment, and XmlManager
        DB_ENV *dbenv;
        int dberr = 0;
        dberr = db_env_create(&dbenv, 0);
        if (dberr) {
            cout << "Error creating environment: " << dberr << endl;
            exit(-1);
        }
        if (password)
            dbenv->set_encrypt(dbenv, password, DB_ENCRYPT_AES);
        dbenv->set_errcall(dbenv, errcall);
        dbenv->set_cachesize(dbenv, 0, cacheSize * 1024 * 1024, 1);
        dbenv->set_lk_max_lockers(dbenv, 10000);
        dbenv->set_lk_max_locks(dbenv, 10000);
        dbenv->set_lk_max_objects(dbenv, 10000);
        if (!dbPrivate) {
            dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT);
            if (verbose && !envCreate) {
                cout <<
                     "Attempting to join environment: "
                     << (path2DbEnv ? path2DbEnv : ".")
                     << endl;
            }
//.........这里部分代码省略.........
开发者ID:kanbang,项目名称:Colt,代码行数:101,代码来源:dbxmlsh.cpp


注:本文中的DB_ENV::set_lk_max_objects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。