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


C++ OperationContext::getOpID方法代码示例

本文整理汇总了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>{}};
}
开发者ID:DINKIN,项目名称:mongo,代码行数:26,代码来源:kill_sessions_common.cpp

示例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;
}
开发者ID:kangic,项目名称:mongo,代码行数:12,代码来源:service_context_d.cpp

示例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;
}
开发者ID:AnkyrinRepeat,项目名称:mongo,代码行数:13,代码来源:service_context_d.cpp

示例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);
        }
    }
}
开发者ID:AnkyrinRepeat,项目名称:mongo,代码行数:17,代码来源:service_context_d.cpp

示例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);
    }
开发者ID:ChineseDr,项目名称:mongo,代码行数:21,代码来源:kill_op.cpp


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