本文整理汇总了C++中LastError::appendSelf方法的典型用法代码示例。如果您正苦于以下问题:C++ LastError::appendSelf方法的具体用法?C++ LastError::appendSelf怎么用?C++ LastError::appendSelf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LastError
的用法示例。
在下文中一共展示了LastError::appendSelf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
bool run(OperationContext* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
LastError *le = lastError.disableForCommand();
le->appendSelf( result );
if ( le->valid )
result.append( "nPrev", le->nPrev );
else
result.append( "nPrev", -1 );
return true;
}
示例2: run
bool run(OperationContext* txn,
const string& dbname,
BSONObj& cmdObj,
int,
string& errmsg,
BSONObjBuilder& result) {
LastError *le = &LastError::get(txn->getClient());
le->disable();
le->appendSelf(result, true);
if (le->isValid())
result.append("nPrev", le->getNPrev());
else
result.append("nPrev", -1);
return true;
}
示例3: run
bool run(const string& dbname, BSONObj& _cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
LastError *le = lastError.disableForCommand();
if ( le->nPrev != 1 ) {
LastError::noError.appendSelf( result , false );
le->appendSelfStatus( result );
}
else {
le->appendSelf( result , false );
}
Client& c = cc();
c.appendLastOp( result );
result.appendNumber( "connectionId" , c.getConnectionId() ); // for sharding; also useful in general for debugging
BSONObj cmdObj = _cmdObj;
{
BSONObj::iterator i(_cmdObj);
i.next();
if( !i.more() ) {
/* empty, use default */
BSONObj *def = getLastErrorDefault;
if( def )
cmdObj = *def;
}
}
WriteConcernOptions writeConcern;
Status status = writeConcern.parse( cmdObj );
if ( !status.isOK() ) {
result.append( "badGLE", cmdObj );
errmsg = status.toString();
return false;
}
WriteConcernResult res;
status = waitForWriteConcern( cc(), writeConcern, &res );
res.appendTo( &result );
if ( status.code() == ErrorCodes::WriteConcernLegacyOK ) {
result.append( "wnote", status.toString() );
return true;
}
return appendCommandStatus( result, status );
}
示例4: run
virtual bool run(const string& dbName, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
LastError *le = lastError.disableForCommand();
{
assert( le );
if ( le->msg.size() && le->nPrev == 1 ){
le->appendSelf( result );
return true;
}
}
ClientInfo * client = ClientInfo::get();
set<string> * shards = client->getPrev();
if ( shards->size() == 0 ){
result.appendNull( "err" );
return true;
}
//log() << "getlasterror enter: " << shards->size() << endl;
vector<OID> writebacks;
// handle single server
if ( shards->size() == 1 ){
string theShard = *(shards->begin() );
result.append( "theshard" , theShard.c_str() );
ShardConnection conn( theShard , "" );
BSONObj res;
bool ok = conn->runCommand( dbName , cmdObj , res );
//log() << "\t" << res << endl;
result.appendElements( res );
conn.done();
result.append( "singleShard" , theShard );
addWriteBack( writebacks , res );
// hit other machines just to block
for ( set<string>::const_iterator i=client->sinceLastGetError().begin(); i!=client->sinceLastGetError().end(); ++i ){
string temp = *i;
if ( temp == theShard )
continue;
ShardConnection conn( temp , "" );
addWriteBack( writebacks , conn->getLastErrorDetailed() );
conn.done();
}
client->clearSinceLastGetError();
handleWriteBacks( writebacks );
return ok;
}
BSONArrayBuilder bbb( result.subarrayStart( "shards" ) );
long long n = 0;
// hit each shard
vector<string> errors;
vector<BSONObj> errorObjects;
for ( set<string>::iterator i = shards->begin(); i != shards->end(); i++ ){
string theShard = *i;
bbb.append( theShard );
ShardConnection conn( theShard , "" );
BSONObj res;
bool ok = conn->runCommand( dbName , cmdObj , res );
addWriteBack( writebacks, res );
string temp = DBClientWithCommands::getLastErrorString( res );
if ( ok == false || temp.size() ){
errors.push_back( temp );
errorObjects.push_back( res );
}
n += res["n"].numberLong();
conn.done();
}
bbb.done();
result.appendNumber( "n" , n );
// hit other machines just to block
for ( set<string>::const_iterator i=client->sinceLastGetError().begin(); i!=client->sinceLastGetError().end(); ++i ){
string temp = *i;
if ( shards->count( temp ) )
continue;
ShardConnection conn( temp , "" );
addWriteBack( writebacks, conn->getLastErrorDetailed() );
conn.done();
}
client->clearSinceLastGetError();
if ( errors.size() == 0 ){
result.appendNull( "err" );
handleWriteBacks( writebacks );
return true;
}
result.append( "err" , errors[0].c_str() );
{ // errs
BSONArrayBuilder all( result.subarrayStart( "errs" ) );
//.........这里部分代码省略.........