本文整理汇总了C++中CursorManager::hasTransactionCursorReference方法的典型用法代码示例。如果您正苦于以下问题:C++ CursorManager::hasTransactionCursorReference方法的具体用法?C++ CursorManager::hasTransactionCursorReference怎么用?C++ CursorManager::hasTransactionCursorReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CursorManager
的用法示例。
在下文中一共展示了CursorManager::hasTransactionCursorReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeLogicalSessionIdForTest
TEST_F(CursorManagerTestCustomOpCtx,
KillAllCursorsForTransactionRemovesCorrectEntryFromTransactionMap) {
CursorManager* cursorManager = CursorManager::getGlobalCursorManager();
// Create 3 sets of cursors, each with a unique LogicalSessionId/TxnNumber pair, but each
// sharing either LogicalSessionId or TxnNumber with another set.
auto lsid1 = makeLogicalSessionIdForTest();
TxnNumber txnNumber1 = 0;
{
auto opCtx = _queryServiceContext->makeOperationContext(lsid1, txnNumber1);
auto pinned = cursorManager->registerCursor(opCtx.get(),
{makeFakePlanExecutor(),
NamespaceString{"test.collection"},
{},
repl::ReadConcernLevel::kLocalReadConcern,
BSONObj()});
pinned.release();
}
auto lsid2 = lsid1;
TxnNumber txnNumber2 = 1;
{
auto opCtx = _queryServiceContext->makeOperationContext(lsid2, txnNumber2);
auto pinned = cursorManager->registerCursor(opCtx.get(),
{makeFakePlanExecutor(),
NamespaceString{"test.collection"},
{},
repl::ReadConcernLevel::kLocalReadConcern,
BSONObj()});
pinned.release();
}
auto lsid3 = makeLogicalSessionIdForTest();
TxnNumber txnNumber3 = txnNumber1;
{
auto opCtx = _queryServiceContext->makeOperationContext(lsid3, txnNumber3);
// Create 2 cursors for the third set to confirm multiple cursor deregistration.
auto pinned = cursorManager->registerCursor(opCtx.get(),
{makeFakePlanExecutor(),
NamespaceString{"test.collection"},
{},
repl::ReadConcernLevel::kLocalReadConcern,
BSONObj()});
pinned.release();
pinned = cursorManager->registerCursor(opCtx.get(),
{makeFakePlanExecutor(),
NamespaceString{"test.collection"},
{},
repl::ReadConcernLevel::kLocalReadConcern,
BSONObj()});
pinned.release();
}
auto opCtx = _queryServiceContext->makeOperationContext();
// Transaction reference exists for all 3 sets.
ASSERT_TRUE(cursorManager->hasTransactionCursorReference(lsid1, txnNumber1));
ASSERT_TRUE(cursorManager->hasTransactionCursorReference(lsid2, txnNumber2));
ASSERT_TRUE(cursorManager->hasTransactionCursorReference(lsid3, txnNumber3));
// Transaction reference does not exist for LogicalSessionId/TxnNumber that has no cursors.
ASSERT_FALSE(cursorManager->hasTransactionCursorReference(makeLogicalSessionIdForTest(), 99));
// Kill cursors for set 1.
ASSERT_EQ(1ul, cursorManager->killAllCursorsForTransaction(opCtx.get(), lsid1, txnNumber1));
ASSERT_FALSE(cursorManager->hasTransactionCursorReference(lsid1, txnNumber1));
ASSERT_TRUE(cursorManager->hasTransactionCursorReference(lsid2, txnNumber2));
ASSERT_TRUE(cursorManager->hasTransactionCursorReference(lsid3, txnNumber3));
// Kill cursors for set 2.
ASSERT_EQ(1ul, cursorManager->killAllCursorsForTransaction(opCtx.get(), lsid2, txnNumber2));
ASSERT_FALSE(cursorManager->hasTransactionCursorReference(lsid2, txnNumber2));
ASSERT_TRUE(cursorManager->hasTransactionCursorReference(lsid3, txnNumber3));
// Kill cursors for set 3.
ASSERT_EQ(2ul, cursorManager->killAllCursorsForTransaction(opCtx.get(), lsid3, txnNumber3));
ASSERT_FALSE(cursorManager->hasTransactionCursorReference(lsid3, txnNumber3));
}