本文整理汇总了C++中KVEngine::getAllCommittedTimestamp方法的典型用法代码示例。如果您正苦于以下问题:C++ KVEngine::getAllCommittedTimestamp方法的具体用法?C++ KVEngine::getAllCommittedTimestamp怎么用?C++ KVEngine::getAllCommittedTimestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KVEngine
的用法示例。
在下文中一共展示了KVEngine::getAllCommittedTimestamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: opCtx
TEST(KVEngineTestHarness, AllCommittedTimestamp) {
unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create());
KVEngine* engine = helper->getEngine();
if (!engine->supportsDocLocking())
return;
unique_ptr<RecordStore> rs;
{
MyOperationContext opCtx(engine);
WriteUnitOfWork uow(&opCtx);
CollectionOptions options;
options.capped = true;
options.cappedSize = 10240;
options.cappedMaxDocs = -1;
NamespaceString oplogNss("local.oplog.rs");
ASSERT_OK(engine->createRecordStore(&opCtx, oplogNss.ns(), "ident", options));
rs = engine->getRecordStore(&opCtx, oplogNss.ns(), "ident", options);
ASSERT(rs);
}
{
Timestamp t11(1, 1);
Timestamp t12(1, 2);
Timestamp t21(2, 1);
auto t11Doc = BSON("ts" << t11);
auto t12Doc = BSON("ts" << t12);
auto t21Doc = BSON("ts" << t21);
Timestamp allCommitted = engine->getAllCommittedTimestamp();
MyOperationContext opCtx1(engine);
WriteUnitOfWork uow1(&opCtx1);
ASSERT_EQ(invariant(rs->insertRecord(
&opCtx1, t11Doc.objdata(), t11Doc.objsize(), Timestamp::min())),
RecordId(1, 1));
Timestamp lastAllCommitted = allCommitted;
allCommitted = engine->getAllCommittedTimestamp();
ASSERT_GTE(allCommitted, lastAllCommitted);
ASSERT_LT(allCommitted, t11);
MyOperationContext opCtx2(engine);
WriteUnitOfWork uow2(&opCtx2);
ASSERT_EQ(invariant(rs->insertRecord(
&opCtx2, t21Doc.objdata(), t21Doc.objsize(), Timestamp::min())),
RecordId(2, 1));
uow2.commit();
lastAllCommitted = allCommitted;
allCommitted = engine->getAllCommittedTimestamp();
ASSERT_GTE(allCommitted, lastAllCommitted);
ASSERT_LT(allCommitted, t11);
ASSERT_EQ(invariant(rs->insertRecord(
&opCtx1, t12Doc.objdata(), t12Doc.objsize(), Timestamp::min())),
RecordId(1, 2));
lastAllCommitted = allCommitted;
allCommitted = engine->getAllCommittedTimestamp();
ASSERT_GTE(allCommitted, lastAllCommitted);
ASSERT_LT(allCommitted, t11);
uow1.commit();
lastAllCommitted = allCommitted;
allCommitted = engine->getAllCommittedTimestamp();
ASSERT_GTE(allCommitted, lastAllCommitted);
ASSERT_LTE(allCommitted, t21);
}
}