本文整理汇总了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());
}
}
示例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();
}
示例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();
}
示例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());
}
示例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();
}
示例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();
}
示例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() ) );
}
}
示例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;
}
示例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();
}
示例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() );
}
}
}
示例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());
}
}
示例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);
}
示例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();
}
示例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() );
}
}
}
示例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;
}