本文整理汇总了C++中BatchedCommandResponse::getElectionId方法的典型用法代码示例。如果您正苦于以下问题:C++ BatchedCommandResponse::getElectionId方法的具体用法?C++ BatchedCommandResponse::getElectionId怎么用?C++ BatchedCommandResponse::getElectionId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BatchedCommandResponse
的用法示例。
在下文中一共展示了BatchedCommandResponse::getElectionId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeBatch
//.........这里部分代码省略.........
// Get the TargetedWriteBatch to find where to put the response
dassert( pendingBatches.find( shardHost ) != pendingBatches.end() );
TargetedWriteBatch* batchRaw = pendingBatches.find( shardHost )->second;
scoped_ptr<TargetedWriteBatch> batch( batchRaw );
if ( dispatchStatus.isOK() ) {
TrackedErrors trackedErrors;
trackedErrors.startTracking( ErrorCodes::StaleShardVersion );
// Dispatch was ok, note response
batchOp.noteBatchResponse( *batch, response, &trackedErrors );
// Note if anything was stale
const vector<ShardError*>& staleErrors =
trackedErrors.getErrors( ErrorCodes::StaleShardVersion );
if ( staleErrors.size() > 0 ) {
noteStaleResponses( staleErrors, _targeter );
++_stats->numStaleBatches;
}
// Remember if the shard is actively changing metadata right now
if ( isShardMetadataChanging( staleErrors ) ) {
remoteMetadataChanging = true;
}
// Remember that we successfully wrote to this shard
// NOTE: This will record lastOps for shards where we actually didn't update
// or delete any documents, which preserves old behavior but is conservative
_stats->noteWriteAt( shardHost,
response.isLastOpSet() ?
response.getLastOp() : OpTime(),
response.isElectionIdSet() ?
response.getElectionId() : OID());
}
else {
// Error occurred dispatching, note it
WriteErrorDetail error;
buildErrorFrom( dispatchStatus, &error );
batchOp.noteBatchError( *batch, error );
}
}
}
++rounds;
++_stats->numRounds;
// If we're done, get out
if ( batchOp.isFinished() )
break;
// MORE WORK TO DO
//
// Refresh the targeter if we need to (no-op if nothing stale)
//
bool targeterChanged = false;
Status refreshStatus = _targeter->refreshIfNeeded( &targeterChanged );
if ( !refreshStatus.isOK() ) {
// It's okay if we can't refresh, we'll just record errors for the ops if
// needed.
warning() << "could not refresh targeter" << causedBy( refreshStatus.reason() )
<< endl;
}
//
// Ensure progress is being made toward completing the batch op
//
int currCompletedOps = batchOp.numWriteOpsIn( WriteOpState_Completed );
if ( currCompletedOps == numCompletedOps && !targeterChanged
&& !remoteMetadataChanging ) {
++numRoundsWithoutProgress;
}
else {
numRoundsWithoutProgress = 0;
}
numCompletedOps = currCompletedOps;
if ( numRoundsWithoutProgress > kMaxRoundsWithoutProgress ) {
stringstream msg;
msg << "no progress was made executing batch write op in " << clientRequest.getNS()
<< " after " << kMaxRoundsWithoutProgress << " rounds (" << numCompletedOps
<< " ops completed in " << rounds << " rounds total)";
WriteErrorDetail error;
buildErrorFrom( Status( ErrorCodes::NoProgressMade, msg.str() ), &error );
batchOp.setBatchError( error );
break;
}
}
batchOp.buildClientResponse( clientResponse );
}