本文整理汇总了C++中OperationContext::getOpID方法的典型用法代码示例。如果您正苦于以下问题:C++ OperationContext::getOpID方法的具体用法?C++ OperationContext::getOpID怎么用?C++ OperationContext::getOpID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationContext
的用法示例。
在下文中一共展示了OperationContext::getOpID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: killSessionsLocalKillOps
SessionKiller::Result killSessionsLocalKillOps(OperationContext* opCtx,
const SessionKiller::Matcher& matcher) {
for (ServiceContext::LockedClientsCursor cursor(opCtx->getClient()->getServiceContext());
Client* client = cursor.next();) {
invariant(client);
stdx::unique_lock<Client> lk(*client);
OperationContext* opCtxToKill = client->getOperationContext();
if (opCtxToKill) {
const auto& lsid = opCtxToKill->getLogicalSessionId();
if (lsid) {
if (const KillAllSessionsByPattern* pattern = matcher.match(*lsid)) {
ScopedKillAllSessionsByPatternImpersonator impersonator(opCtx, *pattern);
log() << "killing op: " << opCtxToKill->getOpID()
<< " as part of killing session: " << lsid->toBSON();
opCtx->getServiceContext()->killOperation(opCtxToKill);
}
}
}
}
return {std::vector<HostAndPort>{}};
}
示例2: _killOperationsAssociatedWithClientAndOpId_inlock
bool ServiceContextMongoD::_killOperationsAssociatedWithClientAndOpId_inlock(Client* client,
unsigned int opId) {
OperationContext* opCtx = client->getOperationContext();
if (!opCtx) {
return false;
}
if (opCtx->getOpID() != opId) {
return false;
}
_killOperation_inlock(opCtx);
return true;
}
示例3: killOperation
bool ServiceContextMongoD::killOperation(unsigned int opId) {
for (LockedClientsCursor cursor(this); Client* client = cursor.next();) {
stdx::lock_guard<Client> lk(*client);
OperationContext* opCtx = client->getOperationContext();
if (opCtx && opCtx->getOpID() == opId) {
_killOperation_inlock(opCtx, ErrorCodes::Interrupted);
return true;
}
}
return false;
}
示例4: killAllUserOperations
void ServiceContextMongoD::killAllUserOperations(const OperationContext* txn,
ErrorCodes::Error killCode) {
for (LockedClientsCursor cursor(this); Client* client = cursor.next();) {
if (!client->isFromUserConnection()) {
// Don't kill system operations.
continue;
}
stdx::lock_guard<Client> lk(*client);
OperationContext* toKill = client->getOperationContext();
// Don't kill ourself.
if (toKill && toKill->getOpID() != txn->getOpID()) {
_killOperation_inlock(toKill, killCode);
}
}
}
示例5: Status
static StatusWith<std::tuple<stdx::unique_lock<Client>, OperationContext*>> _findOp(
ClientBasic* client, unsigned int opId) {
AuthorizationSession* authzSession = AuthorizationSession::get(client);
for (ServiceContext::LockedClientsCursor cursor(client->getServiceContext());
Client* opClient = cursor.next();) {
stdx::unique_lock<Client> lk(*opClient);
OperationContext* opCtx = opClient->getOperationContext();
if (opCtx && opCtx->getOpID() == opId) {
if (authzSession->isAuthorizedForActionsOnResource(
ResourcePattern::forClusterResource(), ActionType::killop) ||
authzSession->isCoauthorizedWithClient(opClient)) {
return {std::make_tuple(std::move(lk), opCtx)};
}
break;
}
}
return Status(ErrorCodes::NoSuchKey, str::stream() << "Could not access opID: " << opId);
}