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


C++ WT_SESSION::checkpoint方法代码示例

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


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

示例1: waitUntilDurable

void WiredTigerSessionCache::waitUntilDurable(bool forceCheckpoint) {
    const int shuttingDown = _shuttingDown.fetchAndAdd(1);
    ON_BLOCK_EXIT([this] { _shuttingDown.fetchAndSubtract(1); });

    uassert(ErrorCodes::ShutdownInProgress,
            "Cannot wait for durability because a shutdown is in progress",
            !(shuttingDown & kShuttingDownMask));

    // When forcing a checkpoint with journaling enabled, don't synchronize with other
    // waiters, as a log flush is much cheaper than a full checkpoint.
    if (forceCheckpoint && _engine->isDurable()) {
        UniqueWiredTigerSession session = getSession();
        WT_SESSION* s = session->getSession();
        {
            stdx::unique_lock<stdx::mutex> lk(_journalListenerMutex);
            JournalListener::Token token = _journalListener->getToken();
            invariantWTOK(s->checkpoint(s, NULL));
            _journalListener->onDurable(token);
        }
        LOG(4) << "created checkpoint (forced)";
        return;
    }

    uint32_t start = _lastSyncTime.load();
    // Do the remainder in a critical section that ensures only a single thread at a time
    // will attempt to synchronize.
    stdx::unique_lock<stdx::mutex> lk(_lastSyncMutex);
    uint32_t current = _lastSyncTime.loadRelaxed();  // synchronized with writes through mutex
    if (current != start) {
        // Someone else synced already since we read lastSyncTime, so we're done!
        return;
    }
    _lastSyncTime.store(current + 1);

    // Nobody has synched yet, so we have to sync ourselves.
    auto session = getSession();
    WT_SESSION* s = session->getSession();

    // This gets the token (OpTime) from the last write, before flushing (either the journal, or a
    // checkpoint), and then reports that token (OpTime) as a durable write.
    stdx::unique_lock<stdx::mutex> jlk(_journalListenerMutex);
    JournalListener::Token token = _journalListener->getToken();

    // Use the journal when available, or a checkpoint otherwise.
    if (_engine->isDurable()) {
        invariantWTOK(s->log_flush(s, "sync=on"));
        LOG(4) << "flushed journal";
    } else {
        invariantWTOK(s->checkpoint(s, NULL));
        LOG(4) << "created checkpoint";
    }
    _journalListener->onDurable(token);
}
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:53,代码来源:wiredtiger_session_cache.cpp

示例2:

int
main(void)
{
	WT_CONNECTION *conn;
	WT_CURSOR *cursor;
	WT_SESSION *session;
	int ret;

	ret = wiredtiger_open(home, NULL, "create,statistics=(all)", &conn);
	ret = conn->open_session(conn, NULL, NULL, &session);
	ret = session->create(
	    session, "table:access", "key_format=S,value_format=S");

	ret = session->open_cursor(
	    session, "table:access", NULL, NULL, &cursor);
	cursor->set_key(cursor, "key");
	cursor->set_value(cursor, "value");
	ret = cursor->insert(cursor);
	cursor->close(cursor);

	ret = session->checkpoint(session, NULL);

	ret = print_database_stats(session);

	ret = print_file_stats(session);

	ret = print_overflow_pages(session);

	ret = print_derived_stats(session);

	return (conn->close(conn, NULL) == 0 ? ret : EXIT_FAILURE);
}
开发者ID:EaseTech,项目名称:wiredtiger,代码行数:32,代码来源:ex_stat.c

示例3:

/*
 * Function for repeatedly running checkpoint operations.
 */
static WT_THREAD_RET
do_checkpoints(void *_opts)
{
	TEST_OPTS *opts;
	WT_SESSION *session;
	time_t now, start;
	int ret;

	opts = (TEST_OPTS *)_opts;
	(void)time(&start);
	(void)time(&now);

	while (difftime(now, start) < RUNTIME) {
		testutil_check(
		    opts->conn->open_session(opts->conn, NULL, NULL, &session));

		if ((ret = session->checkpoint(session, "force")) != 0)
			if (ret != EBUSY && ret != ENOENT)
				testutil_die(ret, "session.checkpoint");

		testutil_check(session->close(session, NULL));

		/*
		 * A short sleep to let operations process and avoid back to
		 * back checkpoints locking up resources.
		 */
		sleep(1);
		(void)time(&now);
	}

	return (WT_THREAD_RET_VALUE);
}
开发者ID:DINKIN,项目名称:mongo,代码行数:35,代码来源:main.c

示例4: flushAllFiles

int WiredTigerKVEngine::flushAllFiles(bool sync) {
    LOG(1) << "WiredTigerKVEngine::flushAllFiles";
    syncSizeInfo(true);

    WiredTigerSession session(_conn);
    WT_SESSION* s = session.getSession();
    invariantWTOK(s->checkpoint(s, NULL));

    return 1;
}
开发者ID:jianjunliu,项目名称:mongo,代码行数:10,代码来源:wiredtiger_kv_engine.cpp

示例5: checkpoint

void WTServerHandler::
checkpoint()
{
    int rc = 0;
    WT_SESSION *sess;
    rc = conn_->open_session(conn_, NULL, NULL, &sess);
    rc = sess->checkpoint(sess, NULL);
    if (rc != 0) {
        fprintf(stderr, "WT_SESSION::checkpoint error %s\n",
            wiredtiger_strerror(rc));
    }
    sess->close(sess, NULL);
}
开发者ID:ckoolkarni,项目名称:mapkeeper,代码行数:13,代码来源:WTServerHandler.cpp

示例6: fopen

/*
 * thread_ckpt_run --
 *	Runner function for the checkpoint thread.
 */
static WT_THREAD_RET
thread_ckpt_run(void *arg)
{
	FILE *fp;
	WT_RAND_STATE rnd;
	WT_SESSION *session;
	WT_THREAD_DATA *td;
	uint64_t ts;
	uint32_t sleep_time;
	int i, ret;
	bool first_ckpt;

	__wt_random_init(&rnd);

	td = (WT_THREAD_DATA *)arg;
	/*
	 * Keep a separate file with the records we wrote for checking.
	 */
	(void)unlink(ckpt_file);
	if ((ret = td->conn->open_session(td->conn, NULL, NULL, &session)) != 0)
		testutil_die(ret, "WT_CONNECTION:open_session");
	first_ckpt = true;
	ts = 0;
	for (i = 0; ;++i) {
		sleep_time = __wt_random(&rnd) % MAX_CKPT_INTERVAL;
		sleep(sleep_time);
		if (use_ts)
			ts = global_ts;
		/*
		 * Since this is the default, send in this string even if
		 * running without timestamps.
		 */
		testutil_check(session->checkpoint(
		    session, "use_timestamp=true"));
		printf("Checkpoint %d complete.  Minimum ts %" PRIu64 "\n",
		    i, ts);
		fflush(stdout);
		/*
		 * Create the checkpoint file so that the parent process knows
		 * at least one checkpoint has finished and can start its
		 * timer.
		 */
		if (first_ckpt) {
			testutil_checksys((fp = fopen(ckpt_file, "w")) == NULL);
			first_ckpt = false;
			testutil_checksys(fclose(fp) != 0);
		}
	}
	/* NOTREACHED */
}
开发者ID:DINKIN,项目名称:mongo,代码行数:54,代码来源:timestamp-abort.c

示例7:

/*
 * wt_shutdown --
 *	Flush the file to disk and shut down the WiredTiger connection.
 */
static void
wt_shutdown(void)
{
	WT_SESSION *session;
	int ret;

	if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
		testutil_die(ret, "conn.session");

	if ((ret = session->checkpoint(session, NULL)) != 0)
		testutil_die(ret, "session.checkpoint");

	if ((ret = conn->close(conn, NULL)) != 0)
		testutil_die(ret, "conn.close");
}
开发者ID:ChineseDr,项目名称:mongo,代码行数:19,代码来源:t.c

示例8:

void *
checkpoint_worker(void *arg)
{
	CONFIG *cfg;
	WT_CONNECTION *conn;
	WT_SESSION *session;
	int ret;
	struct timeval e, s;
	uint32_t i;
	uint64_t ms;

	session = NULL;
	cfg = (CONFIG *)arg;
	conn = cfg->conn;

	if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) {
		lprintf(cfg, ret, 0,
		    "open_session failed in checkpoint thread.");
		goto err;
	}

	while (g_util_running) {
		/*
		 * TODO: do we care how long the checkpoint takes?
		 */
		/* Break the sleep up, so we notice interrupts faster. */
		for (i = 0; i < cfg->checkpoint_interval; i++) {
			sleep(cfg->report_interval);
			if (!g_util_running)
				break;
		}

		gettimeofday(&s, NULL);
		if ((ret = session->checkpoint(session, NULL)) != 0)
			/* Report errors and continue. */
			lprintf(cfg, ret, 0, "Checkpoint failed.");
		gettimeofday(&e, NULL);
		ms = (e.tv_sec * 1000) + (e.tv_usec / 1000.0);
		ms -= (s.tv_sec * 1000) + (s.tv_usec / 1000.0);
		lprintf(cfg, 0, 1,
		    "Finished checkpoint in %" PRIu64 " ms.", ms);
	}
err:	if (session != NULL)
		session->close(session, NULL);
	return (arg);
}
开发者ID:umerazad,项目名称:wiredtiger,代码行数:46,代码来源:wtperf.c

示例9:

/*
 * wt_shutdown --
 *	Flush the file to disk and shut down the WiredTiger connection.
 */
static void
wt_shutdown(void)
{
	WT_SESSION *session;
	int ret;

	if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
		die("conn.session", ret);

	if ((ret = session->verify(session, FNAME, NULL)) != 0)
		die("session.verify", ret);

	if ((ret = session->checkpoint(session, NULL)) != 0)
		die("session.checkpoint", ret);

	if ((ret = conn->close(conn, NULL)) != 0)
		die("conn.close", ret);
}
开发者ID:ckoolkarni,项目名称:wiredtiger,代码行数:22,代码来源:t.c

示例10:

/*
 * wt_shutdown --
 *	Flush the file to disk and shut down the WiredTiger connection.
 */
static void
wt_shutdown(SHARED_CONFIG *cfg)
{
	WT_CONNECTION *conn;
	WT_SESSION *session;
	int ret;

	conn = cfg->conn;

	if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
		testutil_die(ret, "conn.session");

	if ((ret = session->checkpoint(session, NULL)) != 0)
		testutil_die(ret, "session.checkpoint");

	if ((ret = conn->close(conn, NULL)) != 0)
		testutil_die(ret, "conn.close");
}
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:22,代码来源:cursor_order.c

示例11: strlen

/*
 * real_checkpointer --
 *     Do the work of creating checkpoints and then verifying them. Also
 *     responsible for finishing in a timely fashion.
 */
static int
real_checkpointer(void)
{
	WT_SESSION *session;
	char *checkpoint_config, _buf[128];
	int ret;

	if (g.running == 0)
		return (log_print_err(
		    "Checkpoint thread started stopped\n", EINVAL, 1));

	while (g.ntables > g.ntables_created)
		sched_yield();

	if ((ret = g.conn->open_session(g.conn, NULL, NULL, &session)) != 0)
		return (log_print_err("conn.open_session", ret, 1));

	if (strncmp(g.checkpoint_name,
	    "WiredTigerCheckpoint", strlen("WiredTigerCheckpoint")) == 0)
		checkpoint_config = NULL;
	else {
		checkpoint_config = _buf;
		snprintf(checkpoint_config, 128, "name=%s", g.checkpoint_name);
	}
	while (g.running) {
		/* Execute a checkpoint */
		if ((ret = session->checkpoint(
		    session, checkpoint_config)) != 0)
			return (log_print_err("session.checkpoint", ret, 1));
		printf("Finished a checkpoint\n");

		if (!g.running)
			goto done;

		/* Verify the content of the checkpoint. */
		if ((ret = verify_checkpoint(session)) != 0)
			return (log_print_err("verify_checkpoint", ret, 1));
	}

done:	if ((ret = session->close(session, NULL)) != 0)
		return (log_print_err("session.close", ret, 1));

	return (0);
}
开发者ID:EaseTech,项目名称:wiredtiger,代码行数:49,代码来源:checkpointer.c

示例12: system

int
main(void)
{
	WT_CONNECTION *conn;
	WT_CURSOR *cursor;
	WT_SESSION *session;
	int ret;

	/*
	 * Create a clean test directory for this run of the test program if the
	 * environment variable isn't already set (as is done by make check).
	 */
	if (getenv("WIREDTIGER_HOME") == NULL) {
		home = "WT_HOME";
		ret = system("rm -rf WT_HOME && mkdir WT_HOME");
	} else
		home = NULL;

	ret = wiredtiger_open(home, NULL, "create,statistics=(all)", &conn);
	ret = conn->open_session(conn, NULL, NULL, &session);
	ret = session->create(
	    session, "table:access", "key_format=S,value_format=S");

	ret = session->open_cursor(
	    session, "table:access", NULL, NULL, &cursor);
	cursor->set_key(cursor, "key");
	cursor->set_value(cursor, "value");
	ret = cursor->insert(cursor);
	ret = cursor->close(cursor);

	ret = session->checkpoint(session, NULL);

	ret = print_database_stats(session);

	ret = print_file_stats(session);

	ret = print_overflow_pages(session);

	ret = print_derived_stats(session);

	return (conn->close(conn, NULL) == 0 ? ret : EXIT_FAILURE);
}
开发者ID:XinzeChi,项目名称:wiredtiger,代码行数:42,代码来源:ex_stat.c

示例13:

void
obj_checkpoint(void)
{
	WT_SESSION *session;
	int ret;

	if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
		testutil_die(ret, "conn.session");

	/*
	 * Force the checkpoint so it has to be taken. Forced checkpoints can
	 * race with other metadata operations and return EBUSY - we'd expect
	 * applications using forced checkpoints to retry on EBUSY.
	 */
	if ((ret = session->checkpoint(session, "force")) != 0)
		if (ret != EBUSY && ret != ENOENT)
			testutil_die(ret, "session.checkpoint");

	if ((ret = session->close(session, NULL)) != 0)
		testutil_die(ret, "session.close");
}
开发者ID:DINKIN,项目名称:mongo,代码行数:21,代码来源:file.c

示例14: sizeof

static void
uri_init(void)
{
	WT_CURSOR *cursor;
	WT_SESSION *session;
	u_int i, key;
	char buf[128];

	for (i = 0; i < uris; ++i)
		if (uri_list[i] == NULL) {
			testutil_check(
			    __wt_snprintf(buf, sizeof(buf), "table:%u", i));
			uri_list[i] = dstrdup(buf);
		}

	testutil_check(conn->open_session(conn, NULL, NULL, &session));

	/* Initialize the file contents. */
	for (i = 0; i < uris; ++i) {
		testutil_check(__wt_snprintf(buf, sizeof(buf),
		    "key_format=S,value_format=S,"
		    "allocation_size=4K,leaf_page_max=32KB,"));
		testutil_check(session->create(session, uri_list[i], buf));
		testutil_check(session->open_cursor(
		    session, uri_list[i], NULL, NULL, &cursor));
		for (key = 1; key < MAXKEY; ++key) {
			testutil_check(__wt_snprintf(
			    buf, sizeof(buf), "key:%020u", key));
			cursor->set_key(cursor, buf);
			cursor->set_value(cursor, buf);
			testutil_check(cursor->insert(cursor));
		}
		testutil_check(cursor->close(cursor));
	}

	/* Create a checkpoint we can use for readonly handles. */
	testutil_check(session->checkpoint(session, NULL));

	testutil_check(session->close(session, NULL));
}
开发者ID:ajdavis,项目名称:mongo,代码行数:40,代码来源:main.c

示例15:

int
main(int argc, char *argv[])
{
	WT_CONNECTION *conn;
	WT_CURSOR *cursor;
	WT_SESSION *session;

	home = example_setup(argc, argv);

	error_check(
	    wiredtiger_open(home, NULL, "create,statistics=(all)", &conn));
	error_check(conn->open_session(conn, NULL, NULL, &session));
	error_check(session->create(session,
	    "table:access", "key_format=S,value_format=S,columns=(k,v)"));

	error_check(session->open_cursor(
	    session, "table:access", NULL, NULL, &cursor));
	cursor->set_key(cursor, "key");
	cursor->set_value(cursor, "value");
	error_check(cursor->insert(cursor));
	error_check(cursor->close(cursor));

	error_check(session->checkpoint(session, NULL));

	print_database_stats(session);

	print_file_stats(session);

	print_join_cursor_stats(session);

	print_overflow_pages(session);

	print_derived_stats(session);

	error_check(conn->close(conn, NULL));

	return (EXIT_SUCCESS);
}
开发者ID:DINKIN,项目名称:mongo,代码行数:38,代码来源:ex_stat.c


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