diff options
author | Waley Chen <waleycz@gmail.com> | 2016-03-29 17:41:59 -0400 |
---|---|---|
committer | Waley Chen <waleycz@gmail.com> | 2016-03-30 00:15:02 -0400 |
commit | 58a490d466b31f70384b7173aa50fb32ac487563 (patch) | |
tree | c3d836d0305ac569639388828bb98bc2a8076be5 | |
parent | 2cc6e175738a5e18635c28f2bd68c1d6f679e0fc (diff) | |
download | mongo-58a490d466b31f70384b7173aa50fb32ac487563.tar.gz |
SERVER-23243 Extract time-keeping from Listener
Step 1: getClockSource() -> getPreciseClockSource()
-rw-r--r-- | src/mongo/db/catalog/collection_info_cache.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/ftdc/collector.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/ftdc/controller.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/ftdc/controller_test.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/service_context.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/service_context.h | 2 | ||||
-rw-r--r-- | src/mongo/s/sharding_initialization.cpp | 7 | ||||
-rw-r--r-- | src/mongo/s/sharding_test_fixture.cpp | 2 |
8 files changed, 17 insertions, 15 deletions
diff --git a/src/mongo/db/catalog/collection_info_cache.cpp b/src/mongo/db/catalog/collection_info_cache.cpp index 0f1e6409c4b..383099aefd8 100644 --- a/src/mongo/db/catalog/collection_info_cache.cpp +++ b/src/mongo/db/catalog/collection_info_cache.cpp @@ -53,7 +53,7 @@ CollectionInfoCache::CollectionInfoCache(Collection* collection) _keysComputed(false), _planCache(new PlanCache(collection->ns().ns())), _querySettings(new QuerySettings()), - _indexUsageTracker(getGlobalServiceContext()->getClockSource()) {} + _indexUsageTracker(getGlobalServiceContext()->getPreciseClockSource()) {} const UpdateIndexData& CollectionInfoCache::getIndexKeys(OperationContext* txn) const { diff --git a/src/mongo/db/ftdc/collector.cpp b/src/mongo/db/ftdc/collector.cpp index 7a9e54ea6cf..8a391598f79 100644 --- a/src/mongo/db/ftdc/collector.cpp +++ b/src/mongo/db/ftdc/collector.cpp @@ -55,7 +55,7 @@ std::tuple<BSONObj, Date_t> FTDCCollectorCollection::collect(Client* client) { BSONObjBuilder builder; - Date_t start = client->getServiceContext()->getClockSource()->now(); + Date_t start = client->getServiceContext()->getPreciseClockSource()->now(); Date_t end; bool firstLoop = true; @@ -69,7 +69,7 @@ std::tuple<BSONObj, Date_t> FTDCCollectorCollection::collect(Client* client) { Date_t now = start; if (!firstLoop) { - now = client->getServiceContext()->getClockSource()->now(); + now = client->getServiceContext()->getPreciseClockSource()->now(); } firstLoop = false; @@ -84,7 +84,7 @@ std::tuple<BSONObj, Date_t> FTDCCollectorCollection::collect(Client* client) { collector->collect(txn.get(), subObjBuilder); } - end = client->getServiceContext()->getClockSource()->now(); + end = client->getServiceContext()->getPreciseClockSource()->now(); subObjBuilder.appendDate(kFTDCCollectEndField, end); } diff --git a/src/mongo/db/ftdc/controller.cpp b/src/mongo/db/ftdc/controller.cpp index 65819c7e380..3639be9ebed 100644 --- a/src/mongo/db/ftdc/controller.cpp +++ b/src/mongo/db/ftdc/controller.cpp @@ -162,7 +162,7 @@ void FTDCController::doLoop() { while (true) { // Compute the next interval to run regardless of how we were woken up // Skipping an interval due to a race condition with a config signal is harmless. - auto now = getGlobalServiceContext()->getClockSource()->now(); + auto now = getGlobalServiceContext()->getPreciseClockSource()->now(); // Get next time to run at auto next_time = FTDCUtil::roundTime(now, _config.period); diff --git a/src/mongo/db/ftdc/controller_test.cpp b/src/mongo/db/ftdc/controller_test.cpp index 37f406a2f39..365f06580cd 100644 --- a/src/mongo/db/ftdc/controller_test.cpp +++ b/src/mongo/db/ftdc/controller_test.cpp @@ -68,21 +68,22 @@ public: BSONObjBuilder b2; b2.appendDate(kFTDCCollectStartField, - getGlobalServiceContext()->getClockSource()->now()); + getGlobalServiceContext()->getPreciseClockSource()->now()); { BSONObjBuilder subObjBuilder(b2.subobjStart(name())); subObjBuilder.appendDate(kFTDCCollectStartField, - getGlobalServiceContext()->getClockSource()->now()); + getGlobalServiceContext()->getPreciseClockSource()->now()); generateDocument(subObjBuilder, _counter); subObjBuilder.appendDate(kFTDCCollectEndField, - getGlobalServiceContext()->getClockSource()->now()); + getGlobalServiceContext()->getPreciseClockSource()->now()); } - b2.appendDate(kFTDCCollectEndField, getGlobalServiceContext()->getClockSource()->now()); + b2.appendDate(kFTDCCollectEndField, + getGlobalServiceContext()->getPreciseClockSource()->now()); _docs.emplace_back(b2.obj()); } diff --git a/src/mongo/db/service_context.cpp b/src/mongo/db/service_context.cpp index 7fe0e237bdc..1a6f3751096 100644 --- a/src/mongo/db/service_context.cpp +++ b/src/mongo/db/service_context.cpp @@ -147,7 +147,7 @@ TickSource* ServiceContext::getTickSource() const { return _tickSource.get(); } -ClockSource* ServiceContext::getClockSource() const { +ClockSource* ServiceContext::getPreciseClockSource() const { return _clockSource.get(); } diff --git a/src/mongo/db/service_context.h b/src/mongo/db/service_context.h index 4e63046726f..08b4b55bdf5 100644 --- a/src/mongo/db/service_context.h +++ b/src/mongo/db/service_context.h @@ -312,7 +312,7 @@ public: * Returns the tick/clock source set in this context. */ TickSource* getTickSource() const; - ClockSource* getClockSource() const; + ClockSource* getPreciseClockSource() const; /** * Replaces the current tick/clock source with a new one. In other words, the old source will be diff --git a/src/mongo/s/sharding_initialization.cpp b/src/mongo/s/sharding_initialization.cpp index 617afbd017d..0ee24301e20 100644 --- a/src/mongo/s/sharding_initialization.cpp +++ b/src/mongo/s/sharding_initialization.cpp @@ -75,8 +75,8 @@ std::unique_ptr<CatalogManager> makeCatalogManager(ServiceContext* service, std::unique_ptr<SecureRandom> rng(SecureRandom::create()); std::string distLockProcessId = str::stream() << thisHost.toString() << ':' - << durationCount<Seconds>(service->getClockSource()->now().toDurationSinceEpoch()) << ':' - << static_cast<int32_t>(rng->nextInt64()); + << durationCount<Seconds>(service->getPreciseClockSource()->now().toDurationSinceEpoch()) + << ':' << static_cast<int32_t>(rng->nextInt64()); auto distLockCatalog = stdx::make_unique<DistLockCatalogImpl>(shardRegistry); auto distLockManager = @@ -197,7 +197,8 @@ Status initializeGlobalShardingState(OperationContext* txn, const ConnectionStri shardRegistry->startup(); grid.init(std::move(catalogManager), std::move(shardRegistry), - stdx::make_unique<ClusterCursorManager>(getGlobalServiceContext()->getClockSource())); + stdx::make_unique<ClusterCursorManager>( + getGlobalServiceContext()->getPreciseClockSource())); while (!inShutdown()) { try { diff --git a/src/mongo/s/sharding_test_fixture.cpp b/src/mongo/s/sharding_test_fixture.cpp index c5bc4158f7d..9af49ce4d8e 100644 --- a/src/mongo/s/sharding_test_fixture.cpp +++ b/src/mongo/s/sharding_test_fixture.cpp @@ -133,7 +133,7 @@ void ShardingTestFixture::setUp() { // from there until we get rid of it. grid.init(std::move(cm), std::move(shardRegistry), - stdx::make_unique<ClusterCursorManager>(_service->getClockSource())); + stdx::make_unique<ClusterCursorManager>(_service->getPreciseClockSource())); } void ShardingTestFixture::tearDown() { |