summaryrefslogtreecommitdiff
path: root/src/mongo/s/write_ops/batch_write_exec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/write_ops/batch_write_exec.cpp')
-rw-r--r--src/mongo/s/write_ops/batch_write_exec.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/mongo/s/write_ops/batch_write_exec.cpp b/src/mongo/s/write_ops/batch_write_exec.cpp
index 66a81a93023..e5a1656c65b 100644
--- a/src/mongo/s/write_ops/batch_write_exec.cpp
+++ b/src/mongo/s/write_ops/batch_write_exec.cpp
@@ -51,10 +51,7 @@ using std::vector;
BatchWriteExec::BatchWriteExec(NSTargeter* targeter,
ShardResolver* resolver,
MultiCommandDispatch* dispatcher)
- : _targeter(targeter),
- _resolver(resolver),
- _dispatcher(dispatcher),
- _stats(new BatchWriteExecStats) {}
+ : _targeter(targeter), _resolver(resolver), _dispatcher(dispatcher) {}
namespace {
@@ -92,8 +89,10 @@ static bool isShardMetadataChanging(const vector<ShardError*>& staleErrors) {
// This only applies when no writes are occurring and metadata is not changing on reload
static const int kMaxRoundsWithoutProgress(5);
+
void BatchWriteExec::executeBatch(const BatchedCommandRequest& clientRequest,
- BatchedCommandResponse* clientResponse) {
+ BatchedCommandResponse* clientResponse,
+ BatchWriteExecStats* stats) {
LOG(4) << "starting execution of write batch of size "
<< static_cast<int>(clientRequest.sizeWriteOps()) << " for " << clientRequest.getNS()
<< endl;
@@ -143,7 +142,7 @@ void BatchWriteExec::executeBatch(const BatchedCommandRequest& clientRequest,
// Don't do anything until a targeter refresh
_targeter->noteCouldNotTarget();
refreshedTargeter = true;
- ++_stats->numTargetErrors;
+ ++stats->numTargetErrors;
dassert(childBatches.size() == 0u);
}
@@ -181,7 +180,7 @@ void BatchWriteExec::executeBatch(const BatchedCommandRequest& clientRequest,
Status resolveStatus =
_resolver->chooseWriteHost(nextBatch->getEndpoint().shardName, &shardHost);
if (!resolveStatus.isOK()) {
- ++_stats->numResolveErrors;
+ ++stats->numResolveErrors;
// Record a resolve failure
// TODO: It may be necessary to refresh the cache if stale, or maybe just
@@ -268,7 +267,7 @@ void BatchWriteExec::executeBatch(const BatchedCommandRequest& clientRequest,
if (staleErrors.size() > 0) {
noteStaleResponses(staleErrors, _targeter);
- ++_stats->numStaleBatches;
+ ++stats->numStaleBatches;
}
// Remember if the shard is actively changing metadata right now
@@ -279,10 +278,10 @@ void BatchWriteExec::executeBatch(const BatchedCommandRequest& clientRequest,
// 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());
+ stats->noteWriteAt(shardHost,
+ response.isLastOpSet() ? response.getLastOp() : OpTime(),
+ response.isElectionIdSet() ? response.getElectionId()
+ : OID());
} else {
// Error occurred dispatching, note it
@@ -302,7 +301,7 @@ void BatchWriteExec::executeBatch(const BatchedCommandRequest& clientRequest,
}
++rounds;
- ++_stats->numRounds;
+ ++stats->numRounds;
// If we're done, get out
if (batchOp.isFinished())
@@ -359,14 +358,6 @@ void BatchWriteExec::executeBatch(const BatchedCommandRequest& clientRequest,
<< " for " << clientRequest.getNS() << endl;
}
-const BatchWriteExecStats& BatchWriteExec::getStats() {
- return *_stats;
-}
-
-BatchWriteExecStats* BatchWriteExec::releaseStats() {
- return _stats.release();
-}
-
void BatchWriteExecStats::noteWriteAt(const ConnectionString& host,
OpTime opTime,
const OID& electionId) {