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


C++ StatusWith::getStatus方法代码示例

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


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

示例1: uow

TEST(RecordStoreTestHarness, UpdateInPlace1) {
    unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper());
    unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore());

    if (!rs->updateWithDamagesSupported())
        return;

    string s1 = "aaa111bbb";
    string s2 = "aaa222bbb";

    RecordId loc;
    const RecordData s1Rec(s1.c_str(), s1.size() + 1);
    {
        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
        {
            WriteUnitOfWork uow(opCtx.get());
            StatusWith<RecordId> res =
                rs->insertRecord(opCtx.get(), s1Rec.data(), s1Rec.size(), -1);
            ASSERT_OK(res.getStatus());
            loc = res.getValue();
            uow.commit();
        }
    }

    {
        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
        ASSERT_EQUALS(s1, rs->dataFor(opCtx.get(), loc).data());
    }

    {
        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
        {
            WriteUnitOfWork uow(opCtx.get());
            const char* damageSource = "222";
            mutablebson::DamageVector dv;
            dv.push_back(mutablebson::DamageEvent());
            dv[0].sourceOffset = 0;
            dv[0].targetOffset = 3;
            dv[0].size = 3;

            auto newRecStatus = rs->updateWithDamages(opCtx.get(), loc, s1Rec, damageSource, dv);
            ASSERT_OK(newRecStatus.getStatus());
            ASSERT_EQUALS(s2, newRecStatus.getValue().data());
            uow.commit();
        }
    }

    {
        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
        ASSERT_EQUALS(s2, rs->dataFor(opCtx.get(), loc).data());
    }
}
开发者ID:stevelyall,项目名称:mongol-db,代码行数:52,代码来源:record_store_test_harness.cpp

示例2: getIdentSize

int64_t WiredTigerUtil::getIdentSize(WT_SESSION* s, const std::string& uri) {
    StatusWith<int64_t> result = WiredTigerUtil::getStatisticsValueAs<int64_t>(
        s, "statistics:" + uri, "statistics=(size)", WT_STAT_DSRC_BLOCK_SIZE);
    const Status& status = result.getStatus();
    if (!status.isOK()) {
        if (status.code() == ErrorCodes::CursorNotFound) {
            // ident gone, so its 0
            return 0;
        }
        uassertStatusOK(status);
    }
    return result.getValue();
}
开发者ID:ChineseDr,项目名称:mongo,代码行数:13,代码来源:wiredtiger_util.cpp

示例3: _startVoteRequester

void ReplicationCoordinatorImpl::_startVoteRequester(long long newTerm) {
    invariant(_voteRequester);
    LoseElectionGuardV1 lossGuard(this);

    LockGuard lk(_topoMutex);

    const auto lastOpTime =
        _isDurableStorageEngine() ? getMyLastDurableOpTime() : getMyLastAppliedOpTime();

    _voteRequester.reset(new VoteRequester);
    StatusWith<ReplicationExecutor::EventHandle> nextPhaseEvh = _voteRequester->start(
        &_replExecutor, _rsConfig, _selfIndex, _topCoord->getTerm(), false, lastOpTime);
    if (nextPhaseEvh.getStatus() == ErrorCodes::ShutdownInProgress) {
        return;
    }
    fassert(28643, nextPhaseEvh.getStatus());
    _replExecutor.onEvent(
        nextPhaseEvh.getValue(),
        stdx::bind(&ReplicationCoordinatorImpl::_onVoteRequestComplete, this, newTerm));

    lossGuard.dismiss();
}
开发者ID:CaffeineForCode,项目名称:mongo,代码行数:22,代码来源:replication_coordinator_impl_elect_v1.cpp

示例4: harnessHelper

 TEST(WiredTigerUtilTest, GetStatisticsValueValidKey) {
     WiredTigerUtilHarnessHelper harnessHelper("statistics=(all)");
     WiredTigerRecoveryUnit recoveryUnit(harnessHelper.getSessionCache());
     WiredTigerSession* session = recoveryUnit.getSession(NULL);
     WT_SESSION* wtSession = session->getSession();
     ASSERT_OK(wtRCToStatus(wtSession->create(wtSession, "table:mytable", NULL)));
     // Use connection statistics key which does not apply to a table.
     StatusWith<uint64_t> result = WiredTigerUtil::getStatisticsValue(session->getSession(),
         "statistics:table:mytable", "statistics=(fast)", WT_STAT_DSRC_LSM_CHUNK_COUNT);
     ASSERT_OK(result.getStatus());
     // Expect statistics value to be zero for a LSM key on a Btree.
     ASSERT_EQUALS(0U, result.getValue());
 }
开发者ID:ForNowForever,项目名称:mongo,代码行数:13,代码来源:wiredtiger_util_test.cpp

示例5: oplogDiskLocRegister

    Status KVRecordStoreCapped::oplogDiskLocRegister(OperationContext* txn,
                                                     const OpTime& opTime) {
        if (!_engineSupportsDocLocking) {
            return Status::OK();
        }

        StatusWith<RecordId> loc = oploghack::keyForOptime( opTime );
        if ( !loc.isOK() )
            return loc.getStatus();

        _idTracker->addUncommittedId(txn, loc.getValue());
        return Status::OK();
    }
开发者ID:kingfs,项目名称:tokumxse,代码行数:13,代码来源:kv_record_store_capped.cpp

示例6: step

Status NativeSaslClientSession::step(const StringData& inputData, std::string* outputData) {
    if (!_saslConversation) {
        return Status(ErrorCodes::BadValue,
                      mongoutils::str::stream()
                          << "The client authentication session has not been properly initialized");
    }

    StatusWith<bool> status = _saslConversation->step(inputData, outputData);
    if (status.isOK()) {
        _done = status.getValue();
    }
    return status.getStatus();
}
开发者ID:MaheshOruganti,项目名称:mongo-cxx-driver-legacy-1.1.0,代码行数:13,代码来源:native_sasl_client_session.cpp

示例7: uow

    TEST( RecordStoreTestHarness, Truncate1 ) {
        scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );
        scoped_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() );

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) );
        }

        string s = "eliot was here";

        DiskLoc loc;
        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            {
                WriteUnitOfWork uow( opCtx.get() );
                StatusWith<DiskLoc> res = rs->insertRecord( opCtx.get(), s.c_str(), s.size() + 1, false );
                ASSERT_OK( res.getStatus() );
                loc = res.getValue();
                uow.commit();
            }

        }


        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT_EQUALS( s, rs->dataFor( opCtx.get(), loc ).data() );
        }

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) );
        }

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            {
                WriteUnitOfWork uow( opCtx.get() );
                rs->truncate( opCtx.get() );
                uow.commit();
            }

        }

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) );
        }

    }
开发者ID:dpercy,项目名称:mongo,代码行数:51,代码来源:record_store_test_harness.cpp

示例8: addResponse

 bool NetworkInterfaceMockWithMap::addResponse(
         const ReplicationExecutor::RemoteCommandRequest& request,
         const StatusWith<BSONObj>& response,
         bool isBlocked) {
     boost::lock_guard<boost::mutex> lk(_mutex);
     return _responses.insert(std::make_pair(request,
                                             BlockableResponseStatus(
                                                  !response.isOK() ?
                                                         ResponseStatus(response.getStatus()) :
                                                         ResponseStatus(Response(
                                                                            response.getValue(),
                                                                            Milliseconds(0)))
                                                  , isBlocked))).second;
 }
开发者ID:DieterLutz,项目名称:mongo,代码行数:14,代码来源:network_interface_mock.cpp

示例9: setValidationAction

Status Collection::setValidationAction(OperationContext* txn, StringData newAction) {
    invariant(txn->lockState()->isCollectionLockedForMode(ns().toString(), MODE_X));

    StatusWith<ValidationAction> status = _parseValidationAction(newAction);
    if (!status.isOK()) {
        return status.getStatus();
    }

    _validationAction = status.getValue();

    _details->updateValidator(txn, _validatorDoc, getValidationLevel(), getValidationAction());

    return Status::OK();
}
开发者ID:roxberry,项目名称:mongo,代码行数:14,代码来源:collection.cpp

示例10: rec

    // Insert a record and try to call updateWithDamages() with an empty DamageVector.
    TEST( RecordStoreTestHarness, UpdateWithNoDamages ) {
        scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );
        scoped_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() );

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) );
        }

        string data = "my record";
        DiskLoc loc;
        const RecordData rec(data.c_str(), data.size() + 1);
        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            {
                WriteUnitOfWork uow( opCtx.get() );
                StatusWith<DiskLoc> res = rs->insertRecord( opCtx.get(),
                                                            rec.data(),
                                                            rec.size(),
                                                            false );
                ASSERT_OK( res.getStatus() );
                loc = res.getValue();
                uow.commit();
            }
        }

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) );
        }

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            {
                mutablebson::DamageVector dv;

                WriteUnitOfWork uow( opCtx.get() );
                ASSERT_OK( rs->updateWithDamages( opCtx.get(), loc, rec, "", dv ) );
                uow.commit();
            }
        }

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            {
                RecordData record = rs->dataFor( opCtx.get(), loc );
                ASSERT_EQUALS( data, record.data() );
            }
        }
    }
开发者ID:Aaron20141021,项目名称:mongo,代码行数:51,代码来源:record_store_test_updatewithdamages.cpp

示例11: uow

// Insert multiple records and create an iterator for repairing the record store,
// even though the it has not been corrupted.
TEST(RecordStoreTestHarness, GetIteratorForRepairNonEmpty) {
    unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper());
    unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore());

    {
        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
        ASSERT_EQUALS(0, rs->numRecords(opCtx.get()));
    }

    const int nToInsert = 10;
    RecordId locs[nToInsert];
    for (int i = 0; i < nToInsert; i++) {
        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
        {
            stringstream ss;
            ss << "record " << i;
            string data = ss.str();

            WriteUnitOfWork uow(opCtx.get());
            StatusWith<RecordId> res =
                rs->insertRecord(opCtx.get(), data.c_str(), data.size() + 1, false);
            ASSERT_OK(res.getStatus());
            locs[i] = res.getValue();
            uow.commit();
        }
    }

    {
        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
        ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get()));
    }

    set<RecordId> remain(locs, locs + nToInsert);
    {
        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
        auto cursor = rs->getCursorForRepair(opCtx.get());
        // returns NULL if getCursorForRepair is not supported
        if (!cursor) {
            return;
        }

        while (auto record = cursor->next()) {
            remain.erase(record->id);  // can happen more than once per doc
        }
        ASSERT(remain.empty());

        ASSERT(!cursor->next());
    }
}
开发者ID:AnkyrinRepeat,项目名称:mongo,代码行数:51,代码来源:record_store_test_repairiter.cpp

示例12: runCommand

    ResponseStatus NetworkInterfaceMock::runCommand(
            const ReplicationExecutor::RemoteCommandRequest& request) {
        boost::unique_lock<boost::mutex> lk(_mutex);
        Date_t wakeupTime = _now + _simulatedNetworkLatencyMillis;
        while (wakeupTime < _now) {
            _timeElapsed.wait(lk);
        }

        StatusWith<int> toStatus = getTimeoutMillis(request.expirationDate, _now);
        if (!toStatus.isOK())
            return ResponseStatus(toStatus.getStatus());

        lk.unlock();
        return _helper(request);
    }
开发者ID:DieterLutz,项目名称:mongo,代码行数:15,代码来源:network_interface_mock.cpp

示例13: run

 Status ScatterGatherRunner::run(ReplicationExecutor* executor) {
     StatusWith<ReplicationExecutor::EventHandle> finishEvh(ErrorCodes::InternalError,
                                                            "Not set");
     StatusWith<ReplicationExecutor::CallbackHandle> startCBH = executor->scheduleWork(
             stdx::bind(startTrampoline, stdx::placeholders::_1, this, &finishEvh));
     if (!startCBH.isOK()) {
         return startCBH.getStatus();
     }
     executor->wait(startCBH.getValue());
     if (!finishEvh.isOK()) {
         return finishEvh.getStatus();
     }
     executor->waitForEvent(finishEvh.getValue());
     return Status::OK();
 }
开发者ID:Alessandra92,项目名称:mongo,代码行数:15,代码来源:scatter_gather_runner.cpp

示例14: td

    TEST( RocksRecordStoreTest, UpdateInPlace1 ) {
        unittest::TempDir td( _rocksRecordStoreTestDir );
        scoped_ptr<rocksdb::DB> db( getDB( td.path() ) );

        {
            RocksRecordStore rs( "foo.bar", db.get(),
                                 db->DefaultColumnFamily(),
                                 db->DefaultColumnFamily() );
            string s1 = "aaa111bbb";
            string s2 = "aaa222bbb";

            DiskLoc loc;
            {
                MyOperationContext opCtx( db.get() );
                {
                    WriteUnitOfWork uow( opCtx.recoveryUnit() );
                    StatusWith<DiskLoc> res = rs.insertRecord( &opCtx,
                                                               s1.c_str(),
                                                               s1.size() + 1,
                                                               -1 );
                    ASSERT_OK( res.getStatus() );
                    loc = res.getValue();
                }

                ASSERT_EQUALS( s1, rs.dataFor( loc ).data() );
            }

            {
                MyOperationContext opCtx( db.get() );
                {
                    WriteUnitOfWork uow( opCtx.recoveryUnit() );
                    const char* damageSource = "222";
                    mutablebson::DamageVector dv;
                    dv.push_back( mutablebson::DamageEvent() );
                    dv[0].sourceOffset = 0;
                    dv[0].targetOffset = 3;
                    dv[0].size = 3;
                    Status res = rs.updateWithDamages( &opCtx,
                                                       loc,
                                                       damageSource,
                                                       dv );
                    ASSERT_OK( res );
                }
                ASSERT_EQUALS( s2, rs.dataFor( loc ).data() );
            }

        }
    }
开发者ID:li--paul,项目名称:mongo,代码行数:48,代码来源:rocks_record_store_test.cpp

示例15: run

    virtual bool run(OperationContext* txn,
                     const string& dbname,
                     BSONObj& cmdObj,
                     int,
                     string& errmsg,
                     BSONObjBuilder& result) {
        boost::optional<DisableDocumentValidation> maybeDisableValidation;
        if (shouldBypassDocumentValidationForCommand(cmdObj))
            maybeDisableValidation.emplace(txn);

        if (cmdObj.firstElement().type() != Array) {
            errmsg = "ops has to be an array";
            return false;
        }

        BSONObj ops = cmdObj.firstElement().Obj();

        {
            // check input
            BSONObjIterator i(ops);
            while (i.more()) {
                BSONElement e = i.next();
                if (!_checkOperation(e, errmsg)) {
                    return false;
                }
            }
        }

        StatusWith<WriteConcernOptions> wcResult = extractWriteConcern(txn, cmdObj, dbname);
        if (!wcResult.isOK()) {
            return appendCommandStatus(result, wcResult.getStatus());
        }
        txn->setWriteConcern(wcResult.getValue());
        setupSynchronousCommit(txn);

        auto applyOpsStatus = appendCommandStatus(result, applyOps(txn, dbname, cmdObj, &result));

        WriteConcernResult res;
        auto waitForWCStatus =
            waitForWriteConcern(txn,
                                repl::ReplClientInfo::forClient(txn->getClient()).getLastOp(),
                                txn->getWriteConcern(),
                                &res);
        appendCommandWCStatus(result, waitForWCStatus);

        return applyOpsStatus;
    }
开发者ID:CeperaCPP,项目名称:mongo,代码行数:47,代码来源:apply_ops.cpp


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