diff options
author | Benety Goh <benety@mongodb.com> | 2016-10-04 13:45:05 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2016-10-05 10:13:41 -0400 |
commit | e2993ff9da726c50397b6de20e2013087ed18606 (patch) | |
tree | 231eabc0f157f68388a6991f4b18bd34a473f28a /src/mongo/db/repl/collection_bulk_loader_impl.cpp | |
parent | 75e6ae5618169108545425894f02a0a565fb21d5 (diff) | |
download | mongo-e2993ff9da726c50397b6de20e2013087ed18606.tar.gz |
SERVER-26448 added a progress meter to the CollectionBulkLoader
Diffstat (limited to 'src/mongo/db/repl/collection_bulk_loader_impl.cpp')
-rw-r--r-- | src/mongo/db/repl/collection_bulk_loader_impl.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp index 226e5bcb898..8cf62682f23 100644 --- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp +++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp @@ -51,6 +51,12 @@ namespace mongo { namespace repl { +namespace { + +const int kProgressMeterSecondsBetween = 60; +const int kProgressMeterCheckInterval = 128; +} + CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(OperationContext* txn, Collection* coll, const BSONObj idIndexSpec, @@ -67,7 +73,12 @@ CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(OperationContext* txn, _nss{coll->ns()}, _idIndexBlock(stdx::make_unique<MultiIndexBlock>(txn, coll)), _secondaryIndexesBlock(stdx::make_unique<MultiIndexBlock>(txn, coll)), - _idIndexSpec(idIndexSpec) { + _idIndexSpec(idIndexSpec), + _progressMeter(1U, + kProgressMeterSecondsBetween, + kProgressMeterCheckInterval, + "documents copied", + str::stream() << coll->ns().toString() << " collection clone progress") { invariant(txn); invariant(coll); invariant(_runner); @@ -75,6 +86,10 @@ CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(OperationContext* txn, invariant(_autoColl); invariant(_autoDB->getDb()); invariant(_autoColl->getDb() == _autoDB->getDb()); + // Hide collection size in progress output because this information is not available. + // Additionally, even if the collection size is known, it may change while we are copying the + // documents from the sync source. + _progressMeter.showTotal(false); } CollectionBulkLoaderImpl::~CollectionBulkLoaderImpl() { @@ -146,6 +161,9 @@ Status CollectionBulkLoaderImpl::insertDocuments(const std::vector<BSONObj>::con ++count; } + + _progressMeter.hit(count); + return Status::OK(); }); } @@ -217,6 +235,8 @@ Status CollectionBulkLoaderImpl::commit() { LOG(2) << "Done creating indexes for ns: " << _nss.ns() << ", stats: " << _stats.toString(); + _progressMeter.finished(); + _releaseResources(); return Status::OK(); }, |