diff options
author | Judah Schvimer <judah@mongodb.com> | 2016-08-15 15:47:22 -0400 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2016-08-15 15:48:08 -0400 |
commit | 10ff598752d57650783c63166180df31f907df12 (patch) | |
tree | 2a07c948cdb8ec81491ce40b85652422c034dc89 /src/mongo/db/repl/collection_cloner.cpp | |
parent | 5a728c7a8d99d4efe06fd7c19a1b9d82879ee49e (diff) | |
download | mongo-10ff598752d57650783c63166180df31f907df12.tar.gz |
SERVER-25125 Report initial sync progress in ReplSetGetStatus
Diffstat (limited to 'src/mongo/db/repl/collection_cloner.cpp')
-rw-r--r-- | src/mongo/db/repl/collection_cloner.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/mongo/db/repl/collection_cloner.cpp b/src/mongo/db/repl/collection_cloner.cpp index a5bab29f76d..fa85b2b2fcc 100644 --- a/src/mongo/db/repl/collection_cloner.cpp +++ b/src/mongo/db/repl/collection_cloner.cpp @@ -128,6 +128,7 @@ CollectionCloner::CollectionCloner(executor::TaskExecutor* executor, uassertStatusOK(options.validate()); uassert(ErrorCodes::BadValue, "callback function cannot be null", onCompletion); uassert(ErrorCodes::BadValue, "storage interface cannot be null", storageInterface); + _stats.ns = _sourceNss.ns(); } CollectionCloner::~CollectionCloner() { @@ -435,16 +436,24 @@ std::string CollectionCloner::Stats::toString() const { BSONObj CollectionCloner::Stats::toBSON() const { BSONObjBuilder bob; - bob.appendNumber("documents", documents); - bob.appendNumber("indexes", indexes); - bob.appendNumber("fetchedBatches", fetchBatches); - bob.appendDate("start", start); - bob.appendDate("end", end); - auto elapsed = end - start; - long long elapsedMillis = duration_cast<Milliseconds>(elapsed).count(); - bob.appendNumber("elapsedMillis", elapsedMillis); + bob.append("ns", ns); + append(&bob); return bob.obj(); } +void CollectionCloner::Stats::append(BSONObjBuilder* builder) const { + builder->appendNumber("documents", documents); + builder->appendNumber("indexes", indexes); + builder->appendNumber("fetchedBatches", fetchBatches); + if (start != Date_t()) { + builder->appendDate("start", start); + if (end != Date_t()) { + builder->appendDate("end", end); + auto elapsed = end - start; + long long elapsedMillis = duration_cast<Milliseconds>(elapsed).count(); + builder->appendNumber("elapsedMillis", elapsedMillis); + } + } +} } // namespace repl } // namespace mongo |