本文整理汇总了C++中LastError::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ LastError::reset方法的具体用法?C++ LastError::reset怎么用?C++ LastError::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LastError
的用法示例。
在下文中一共展示了LastError::reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
bool run(OperationContext* txn,
const string& db,
BSONObj& cmdObj,
int,
string& errmsg,
BSONObjBuilder& result,
bool fromRepl) {
LastError* le = lastError.get();
verify(le);
le->reset();
return true;
}
示例2: run
bool ClusterWriteCmd::run( const string& dbName,
BSONObj& cmdObj,
int options,
string& errMsg,
BSONObjBuilder& result,
bool ) {
BatchedCommandRequest request( _writeType );
BatchedCommandResponse response;
// TODO: if we do namespace parsing, push this to the type
if ( !request.parseBSON( cmdObj, &errMsg ) || !request.isValid( &errMsg ) ) {
// Batch parse failure
response.setOk( false );
response.setErrCode( ErrorCodes::FailedToParse );
response.setErrMessage( errMsg );
dassert( response.isValid( &errMsg ) );
}
else {
// Fixup the namespace to be a full ns internally
NamespaceString nss( dbName, request.getNS() );
request.setNS( nss.ns() );
clusterWrite( request, &response, true /* autosplit */ );
}
// Populate the lastError object based on the write
dassert( response.isValid( NULL ) );
LastError* lastErrorForRequest = lastError.get( true /* create */ );
dassert( lastErrorForRequest );
lastErrorForRequest->reset();
batchErrorToLastError( request, response, lastErrorForRequest );
// TODO
// There's a pending issue about how to report response here. If we use
// the command infra-structure, we should reuse the 'errmsg' field. But
// we have already filed that message inside the BatchCommandResponse.
// return response.getOk();
result.appendElements( response.toBSON() );
return true;
}
示例3: run
bool ClusterWriteCmd::run(OperationContext* txn, const string& dbName,
BSONObj& cmdObj,
int options,
string& errMsg,
BSONObjBuilder& result,
bool ) {
BatchedCommandRequest request( _writeType );
BatchedCommandResponse response;
ClusterWriter writer( true /* autosplit */, 0 /* timeout */ );
// NOTE: Sometimes this command is invoked with LE disabled for legacy writes
LastError* cmdLastError = lastError.get( false );
{
// Disable the last error object for the duration of the write
LastError::Disabled disableLastError( cmdLastError );
// TODO: if we do namespace parsing, push this to the type
if ( !request.parseBSON( cmdObj, &errMsg ) || !request.isValid( &errMsg ) ) {
// Batch parse failure
response.setOk( false );
response.setErrCode( ErrorCodes::FailedToParse );
response.setErrMessage( errMsg );
}
else {
// Fixup the namespace to be a full ns internally
NamespaceString nss( dbName, request.getNS() );
request.setNS( nss.ns() );
writer.write( request, &response );
}
dassert( response.isValid( NULL ) );
}
if ( cmdLastError ) {
// Populate the lastError object based on the write response
cmdLastError->reset();
batchErrorToLastError( request, response, cmdLastError );
}
size_t numAttempts;
if ( !response.getOk() ) {
numAttempts = 0;
} else if ( request.getOrdered() && response.isErrDetailsSet() ) {
numAttempts = response.getErrDetailsAt(0)->getIndex() + 1; // Add one failed attempt
} else {
numAttempts = request.sizeWriteOps();
}
// TODO: increase opcounters by more than one
if ( _writeType == BatchedCommandRequest::BatchType_Insert ) {
for( size_t i = 0; i < numAttempts; ++i ) {
globalOpCounters.gotInsert();
}
} else if ( _writeType == BatchedCommandRequest::BatchType_Update ) {
for( size_t i = 0; i < numAttempts; ++i ) {
globalOpCounters.gotUpdate();
}
} else if ( _writeType == BatchedCommandRequest::BatchType_Delete ) {
for( size_t i = 0; i < numAttempts; ++i ) {
globalOpCounters.gotDelete();
}
}
// Save the last opTimes written on each shard for this client, to allow GLE to work
if ( ClientInfo::exists() && writer.getStats().hasShardStats() ) {
ClientInfo* clientInfo = ClientInfo::get( NULL );
clientInfo->addHostOpTimes( writer.getStats().getShardStats().getWriteOpTimes() );
}
// TODO
// There's a pending issue about how to report response here. If we use
// the command infra-structure, we should reuse the 'errmsg' field. But
// we have already filed that message inside the BatchCommandResponse.
// return response.getOk();
result.appendElements( response.toBSON() );
return true;
}