diff options
Diffstat (limited to 'src')
19 files changed, 50 insertions, 107 deletions
diff --git a/src/mongo/db/query/plan_yield_policy.cpp b/src/mongo/db/query/plan_yield_policy.cpp index 575ebf664b8..b03ec44920b 100644 --- a/src/mongo/db/query/plan_yield_policy.cpp +++ b/src/mongo/db/query/plan_yield_policy.cpp @@ -35,28 +35,16 @@ #include "mongo/db/operation_context.h" #include "mongo/db/query/query_knobs.h" #include "mongo/db/query/query_yield.h" -#include "mongo/db/service_context.h" #include "mongo/util/scopeguard.h" -#include "mongo/util/time_support.h" namespace mongo { PlanYieldPolicy::PlanYieldPolicy(PlanExecutor* exec, PlanExecutor::YieldPolicy policy) : _policy(policy), _forceYield(false), - _elapsedTracker(exec->getOpCtx()->getServiceContext()->getFastClockSource(), - internalQueryExecYieldIterations, - Milliseconds(internalQueryExecYieldPeriodMS)), + _elapsedTracker(internalQueryExecYieldIterations, internalQueryExecYieldPeriodMS), _planYielding(exec) {} - -PlanYieldPolicy::PlanYieldPolicy(PlanExecutor::YieldPolicy policy, ClockSource* cs) - : _policy(policy), - _forceYield(false), - _elapsedTracker( - cs, internalQueryExecYieldIterations, Milliseconds(internalQueryExecYieldPeriodMS)), - _planYielding(nullptr) {} - bool PlanYieldPolicy::shouldYield() { if (!allowedToYield()) return false; diff --git a/src/mongo/db/query/plan_yield_policy.h b/src/mongo/db/query/plan_yield_policy.h index ec6dca7a0f2..0de47c608cd 100644 --- a/src/mongo/db/query/plan_yield_policy.h +++ b/src/mongo/db/query/plan_yield_policy.h @@ -34,7 +34,6 @@ namespace mongo { -class ClockSource; class RecordFetcher; class PlanYieldPolicy { @@ -45,12 +44,6 @@ public: * locks. */ PlanYieldPolicy(PlanExecutor* exec, PlanExecutor::YieldPolicy policy); - /** - * Only used in dbtests since we don't have access to a PlanExecutor. Since we don't have - * access to the PlanExecutor to grab a ClockSource from, we pass in a ClockSource directly - * in the constructor instead. - */ - PlanYieldPolicy(PlanExecutor::YieldPolicy policy, ClockSource* cs); /** * Used by YIELD_AUTO plan executors in order to check whether it is time to yield. diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp index c70a869a4f1..4fdef19c6b6 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp @@ -43,7 +43,6 @@ #include "mongo/db/index/index_descriptor.h" #include "mongo/db/query/internal_plans.h" #include "mongo/db/s/start_chunk_clone_request.h" -#include "mongo/db/service_context.h" #include "mongo/executor/remote_command_request.h" #include "mongo/executor/remote_command_response.h" #include "mongo/executor/task_executor.h" @@ -55,7 +54,6 @@ #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" #include "mongo/util/scopeguard.h" -#include "mongo/util/time_support.h" namespace mongo { namespace { @@ -397,9 +395,7 @@ Status MigrationChunkClonerSourceLegacy::nextCloneBatch(OperationContext* txn, BSONArrayBuilder* arrBuilder) { dassert(txn->lockState()->isCollectionLockedForMode(_args.getNss().ns(), MODE_IS)); - ElapsedTracker tracker(txn->getServiceContext()->getFastClockSource(), - internalQueryExecYieldIterations, - Milliseconds(internalQueryExecYieldPeriodMS)); + ElapsedTracker tracker(internalQueryExecYieldIterations, internalQueryExecYieldPeriodMS); stdx::lock_guard<stdx::mutex> sl(_mutex); diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine_test.cpp index 903e70b5037..def552757b1 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine_test.cpp @@ -51,7 +51,7 @@ private: std::unique_ptr<EphemeralForTestEngine> _engine; }; -KVHarnessHelper* KVHarnessHelper::create(ClockSource* cs) { +KVHarnessHelper* KVHarnessHelper::create() { return new EphemeralForTestKVHarnessHelper(); } } diff --git a/src/mongo/db/storage/kv/SConscript b/src/mongo/db/storage/kv/SConscript index 2d4a63498fa..b00678c3d26 100644 --- a/src/mongo/db/storage/kv/SConscript +++ b/src/mongo/db/storage/kv/SConscript @@ -89,7 +89,6 @@ env.Library( '$BUILD_DIR/mongo/db/service_context', '$BUILD_DIR/mongo/db/storage/storage_options', '$BUILD_DIR/mongo/unittest/unittest', - '$BUILD_DIR/mongo/util/clock_source_mock', 'kv_engine_core', ], LIBDEPS_TAGS=[ diff --git a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp index ae6964d6d98..c225fb7ada3 100644 --- a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp +++ b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp @@ -30,6 +30,7 @@ #include "mongo/db/storage/kv/kv_engine_test_harness.h" + #include "mongo/db/operation_context_noop.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/storage/kv/kv_catalog.h" @@ -37,7 +38,6 @@ #include "mongo/db/storage/record_store.h" #include "mongo/db/storage/sorted_data_interface.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/clock_source_mock.h" namespace mongo { @@ -49,12 +49,10 @@ class MyOperationContext : public OperationContextNoop { public: MyOperationContext(KVEngine* engine) : OperationContextNoop(engine->newRecoveryUnit()) {} }; - -const std::unique_ptr<ClockSource> clock = stdx::make_unique<ClockSourceMock>(); } TEST(KVEngineTestHarness, SimpleRS1) { - unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create(clock.get())); + unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create()); KVEngine* engine = helper->getEngine(); ASSERT(engine); @@ -92,7 +90,7 @@ TEST(KVEngineTestHarness, SimpleRS1) { } TEST(KVEngineTestHarness, Restart1) { - unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create(clock.get())); + unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create()); KVEngine* engine = helper->getEngine(); ASSERT(engine); @@ -136,7 +134,7 @@ TEST(KVEngineTestHarness, Restart1) { TEST(KVEngineTestHarness, SimpleSorted1) { - unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create(clock.get())); + unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create()); KVEngine* engine = helper->getEngine(); ASSERT(engine); @@ -164,7 +162,7 @@ TEST(KVEngineTestHarness, SimpleSorted1) { } TEST(KVCatalogTest, Coll1) { - unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create(clock.get())); + unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create()); KVEngine* engine = helper->getEngine(); unique_ptr<RecordStore> rs; @@ -208,7 +206,7 @@ TEST(KVCatalogTest, Coll1) { TEST(KVCatalogTest, Idx1) { - unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create(clock.get())); + unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create()); KVEngine* engine = helper->getEngine(); unique_ptr<RecordStore> rs; @@ -281,7 +279,7 @@ TEST(KVCatalogTest, Idx1) { } TEST(KVCatalogTest, DirectoryPerDb1) { - unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create(clock.get())); + unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create()); KVEngine* engine = helper->getEngine(); unique_ptr<RecordStore> rs; @@ -323,7 +321,7 @@ TEST(KVCatalogTest, DirectoryPerDb1) { } TEST(KVCatalogTest, Split1) { - unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create(clock.get())); + unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create()); KVEngine* engine = helper->getEngine(); unique_ptr<RecordStore> rs; @@ -365,7 +363,7 @@ TEST(KVCatalogTest, Split1) { } TEST(KVCatalogTest, DirectoryPerAndSplit1) { - unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create(clock.get())); + unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create()); KVEngine* engine = helper->getEngine(); unique_ptr<RecordStore> rs; diff --git a/src/mongo/db/storage/kv/kv_engine_test_harness.h b/src/mongo/db/storage/kv/kv_engine_test_harness.h index a5f61060765..15ed43a1249 100644 --- a/src/mongo/db/storage/kv/kv_engine_test_harness.h +++ b/src/mongo/db/storage/kv/kv_engine_test_harness.h @@ -33,9 +33,6 @@ #include "mongo/db/storage/kv/kv_engine.h" namespace mongo { - -class ClockSource; - class KVHarnessHelper { public: virtual ~KVHarnessHelper() {} @@ -45,6 +42,6 @@ public: virtual KVEngine* restartEngine() = 0; - static KVHarnessHelper* create(ClockSource* cs); + static KVHarnessHelper* create(); }; } diff --git a/src/mongo/db/storage/kv/kv_engine_test_snapshots.cpp b/src/mongo/db/storage/kv/kv_engine_test_snapshots.cpp index 6ff5cb2eeb3..0af84c354de 100644 --- a/src/mongo/db/storage/kv/kv_engine_test_snapshots.cpp +++ b/src/mongo/db/storage/kv/kv_engine_test_snapshots.cpp @@ -36,9 +36,7 @@ #include "mongo/db/storage/kv/kv_engine.h" #include "mongo/db/storage/record_store.h" #include "mongo/db/storage/snapshot_manager.h" -#include "mongo/stdx/memory.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/clock_source_mock.h" namespace mongo { namespace { @@ -173,8 +171,7 @@ public: } void setUp() override { - service.setFastClockSource(stdx::make_unique<ClockSourceMock>()); - helper.reset(KVHarnessHelper::create(service.getFastClockSource())); + helper.reset(KVHarnessHelper::create()); engine = helper->getEngine(); snapshotManager = helper->getEngine()->getSnapshotManager(); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_init.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_init.cpp index fc60f082ea6..783983aa93b 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_init.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_init.cpp @@ -63,16 +63,14 @@ public: size_t cacheMB = WiredTigerUtil::getCacheSizeMB(wiredTigerGlobalOptions.cacheSizeGB); const bool ephemeral = false; - WiredTigerKVEngine* kv = - new WiredTigerKVEngine(getCanonicalName().toString(), - params.dbpath, - getGlobalServiceContext()->getFastClockSource(), - wiredTigerGlobalOptions.engineConfig, - cacheMB, - params.dur, - ephemeral, - params.repair, - params.readOnly); + WiredTigerKVEngine* kv = new WiredTigerKVEngine(getCanonicalName().toString(), + params.dbpath, + wiredTigerGlobalOptions.engineConfig, + cacheMB, + params.dur, + ephemeral, + params.repair, + params.readOnly); kv->setRecordStoreExtraOptions(wiredTigerGlobalOptions.collectionConfig); kv->setSortedDataInterfaceExtraOptions(wiredTigerGlobalOptions.indexConfig); // Intentionally leaked. diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index d57415233f8..d8547c421f9 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -170,7 +170,6 @@ TicketServerParameter openReadTransactionParam(&openReadTransaction, WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, const std::string& path, - ClockSource* cs, const std::string& extraOpenOptions, size_t cacheSizeMB, bool durable, @@ -180,7 +179,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, : _eventHandler(WiredTigerUtil::defaultEventHandlers()), _canonicalName(canonicalName), _path(path), - _sizeStorerSyncTracker(cs, 100000, Seconds(60)), + _sizeStorerSyncTracker(100000, 60 * 1000), _durable(durable), _ephemeral(ephemeral), _readOnly(readOnly) { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h index 16ca9311cd3..6daafffe12d 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h @@ -44,7 +44,6 @@ namespace mongo { -class ClockSource; class JournalListener; class WiredTigerSessionCache; class WiredTigerSizeStorer; @@ -53,7 +52,6 @@ class WiredTigerKVEngine final : public KVEngine { public: WiredTigerKVEngine(const std::string& canonicalName, const std::string& path, - ClockSource* cs, const std::string& extraOpenOptions, size_t cacheSizeGB, bool durable, diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp index 7f18c8f8478..ae93eecc93b 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp @@ -39,9 +39,9 @@ namespace mongo { class WiredTigerKVHarnessHelper : public KVHarnessHelper { public: - WiredTigerKVHarnessHelper(ClockSource* cs) : _clock(cs), _dbpath("wt-kv-harness") { + WiredTigerKVHarnessHelper() : _dbpath("wt-kv-harness") { _engine.reset(new WiredTigerKVEngine( - kWiredTigerEngineName, _dbpath.path(), _clock, "", 1, false, false, false, false)); + kWiredTigerEngineName, _dbpath.path(), "", 1, false, false, false, false)); } virtual ~WiredTigerKVHarnessHelper() { @@ -51,7 +51,7 @@ public: virtual KVEngine* restartEngine() { _engine.reset(NULL); _engine.reset(new WiredTigerKVEngine( - kWiredTigerEngineName, _dbpath.path(), _clock, "", 1, false, false, false, false)); + kWiredTigerEngineName, _dbpath.path(), "", 1, false, false, false, false)); return _engine.get(); } @@ -60,12 +60,11 @@ public: } private: - ClockSource* _clock; unittest::TempDir _dbpath; std::unique_ptr<WiredTigerKVEngine> _engine; }; -KVHarnessHelper* KVHarnessHelper::create(ClockSource* cs) { - return new WiredTigerKVHarnessHelper(cs); +KVHarnessHelper* KVHarnessHelper::create() { + return new WiredTigerKVHarnessHelper(); } } diff --git a/src/mongo/dbtests/SConscript b/src/mongo/dbtests/SConscript index 7f5a55f45ed..6192a75b556 100644 --- a/src/mongo/dbtests/SConscript +++ b/src/mongo/dbtests/SConscript @@ -117,7 +117,6 @@ dbtest = env.Program( "$BUILD_DIR/mongo/bson/mutable/mutable_bson_test_utils", "$BUILD_DIR/mongo/platform/platform", "$BUILD_DIR/mongo/db/serveronly", - '$BUILD_DIR/mongo/util/clock_source_mock', "$BUILD_DIR/mongo/util/concurrency/rwlock", "$BUILD_DIR/mongo/util/net/network", "mocklib", diff --git a/src/mongo/dbtests/plan_ranking.cpp b/src/mongo/dbtests/plan_ranking.cpp index a9dc89e1144..9c9d52bccf4 100644 --- a/src/mongo/dbtests/plan_ranking.cpp +++ b/src/mongo/dbtests/plan_ranking.cpp @@ -50,12 +50,9 @@ #include "mongo/db/query/query_planner_test_lib.h" #include "mongo/db/query/stage_builder.h" #include "mongo/dbtests/dbtests.h" -#include "mongo/stdx/memory.h" -#include "mongo/util/clock_source_mock.h" -namespace mongo { -const std::unique_ptr<ClockSource> clockSource = stdx::make_unique<ClockSourceMock>(); +namespace mongo { // How we access the external setParameter testing bool. extern std::atomic<bool> internalQueryForceIntersectionPlans; // NOLINT @@ -132,7 +129,7 @@ public: _mps->addPlan(solutions[i], root, ws.get()); } // This is what sets a backup plan, should we test for it. - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(NULL, PlanExecutor::YIELD_MANUAL); _mps->pickBestPlan(&yieldPolicy); ASSERT(_mps->bestPlanChosen()); diff --git a/src/mongo/dbtests/query_stage_cached_plan.cpp b/src/mongo/dbtests/query_stage_cached_plan.cpp index 32550bc2172..865ee18dacc 100644 --- a/src/mongo/dbtests/query_stage_cached_plan.cpp +++ b/src/mongo/dbtests/query_stage_cached_plan.cpp @@ -47,11 +47,9 @@ #include "mongo/db/query/query_planner_params.h" #include "mongo/dbtests/dbtests.h" #include "mongo/stdx/memory.h" -#include "mongo/util/clock_source_mock.h" namespace QueryStageCachedPlan { -const std::unique_ptr<ClockSource> clockSource = stdx::make_unique<ClockSourceMock>(); static const NamespaceString nss("unittests.QueryStageCachedPlan"); class QueryStageCachedPlanBase { @@ -143,7 +141,7 @@ public: &_txn, collection, &_ws, cq.get(), plannerParams, decisionWorks, mockChild.release()); // This should succeed after triggering a replan. - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(nullptr, PlanExecutor::YIELD_MANUAL); ASSERT_OK(cachedPlanStage.pickBestPlan(&yieldPolicy)); // Make sure that we get 2 legit results back. @@ -212,7 +210,7 @@ public: &_txn, collection, &_ws, cq.get(), plannerParams, decisionWorks, mockChild.release()); // This should succeed after triggering a replan. - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(nullptr, PlanExecutor::YIELD_MANUAL); ASSERT_OK(cachedPlanStage.pickBestPlan(&yieldPolicy)); // Make sure that we get 2 legit results back. diff --git a/src/mongo/dbtests/query_stage_multiplan.cpp b/src/mongo/dbtests/query_stage_multiplan.cpp index ae5b128824a..250eb5c380f 100644 --- a/src/mongo/dbtests/query_stage_multiplan.cpp +++ b/src/mongo/dbtests/query_stage_multiplan.cpp @@ -51,12 +51,9 @@ #include "mongo/db/query/stage_builder.h" #include "mongo/dbtests/dbtests.h" #include "mongo/stdx/memory.h" -#include "mongo/util/clock_source_mock.h" namespace mongo { -const std::unique_ptr<ClockSource> clockSource = stdx::make_unique<ClockSourceMock>(); - // How we access the external setParameter testing bool. extern std::atomic<bool> internalQueryForceIntersectionPlans; // NOLINT @@ -174,7 +171,7 @@ public: mps->addPlan(createQuerySolution(), secondRoot.release(), sharedWs.get()); // Plan 0 aka the first plan aka the index scan should be the best. - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(NULL, PlanExecutor::YIELD_MANUAL); mps->pickBestPlan(&yieldPolicy); ASSERT(mps->bestPlanChosen()); ASSERT_EQUALS(0, mps->bestPlanIdx()); @@ -258,7 +255,7 @@ public: } // This sets a backup plan. - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(NULL, PlanExecutor::YIELD_MANUAL); mps->pickBestPlan(&yieldPolicy); ASSERT(mps->bestPlanChosen()); ASSERT(mps->hasBackupPlan()); diff --git a/src/mongo/dbtests/query_stage_subplan.cpp b/src/mongo/dbtests/query_stage_subplan.cpp index b703c0bf74c..09f27a679e4 100644 --- a/src/mongo/dbtests/query_stage_subplan.cpp +++ b/src/mongo/dbtests/query_stage_subplan.cpp @@ -43,11 +43,9 @@ #include "mongo/db/query/canonical_query.h" #include "mongo/db/query/get_executor.h" #include "mongo/dbtests/dbtests.h" -#include "mongo/util/clock_source_mock.h" namespace QueryStageSubplan { -const std::unique_ptr<ClockSource> clockSource = stdx::make_unique<ClockSourceMock>(); static const NamespaceString nss("unittests.QueryStageSubplan"); class QueryStageSubplanBase { @@ -126,7 +124,7 @@ public: new SubplanStage(&_txn, collection, &ws, plannerParams, cq.get())); // Plan selection should succeed due to falling back on regular planning. - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(NULL, PlanExecutor::YIELD_MANUAL); ASSERT_OK(subplan->pickBestPlan(&yieldPolicy)); } }; @@ -167,7 +165,7 @@ public: std::unique_ptr<SubplanStage> subplan( new SubplanStage(&_txn, collection, &ws, plannerParams, cq.get())); - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(NULL, PlanExecutor::YIELD_MANUAL); ASSERT_OK(subplan->pickBestPlan(&yieldPolicy)); // Nothing is in the cache yet, so neither branch should have been planned from @@ -223,7 +221,7 @@ public: std::unique_ptr<SubplanStage> subplan( new SubplanStage(&_txn, collection, &ws, plannerParams, cq.get())); - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(nullptr, PlanExecutor::YIELD_MANUAL); ASSERT_OK(subplan->pickBestPlan(&yieldPolicy)); // Nothing is in the cache yet, so neither branch should have been planned from @@ -280,7 +278,7 @@ public: std::unique_ptr<SubplanStage> subplan( new SubplanStage(&_txn, collection, &ws, plannerParams, cq.get())); - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(nullptr, PlanExecutor::YIELD_MANUAL); ASSERT_OK(subplan->pickBestPlan(&yieldPolicy)); // Nothing is in the cache yet, so neither branch should have been planned from @@ -535,7 +533,7 @@ public: new SubplanStage(&_txn, collection, &ws, plannerParams, cq.get())); // Plan selection should succeed due to falling back on regular planning. - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(nullptr, PlanExecutor::YIELD_MANUAL); ASSERT_OK(subplan->pickBestPlan(&yieldPolicy)); // Work the stage until it produces all results. @@ -593,7 +591,7 @@ public: std::unique_ptr<SubplanStage> subplan( new SubplanStage(&_txn, collection, &ws, plannerParams, cq.get())); - PlanYieldPolicy yieldPolicy(PlanExecutor::YIELD_MANUAL, clockSource.get()); + PlanYieldPolicy yieldPolicy(nullptr, PlanExecutor::YIELD_MANUAL); ASSERT_OK(subplan->pickBestPlan(&yieldPolicy)); size_t numResults = 0; diff --git a/src/mongo/util/elapsed_tracker.cpp b/src/mongo/util/elapsed_tracker.cpp index 660a52bf134..0d0b2026fb7 100644 --- a/src/mongo/util/elapsed_tracker.cpp +++ b/src/mongo/util/elapsed_tracker.cpp @@ -32,27 +32,24 @@ #include "mongo/util/elapsed_tracker.h" -#include "mongo/util/clock_source.h" +#include "mongo/util/net/listen.h" namespace mongo { -ElapsedTracker::ElapsedTracker(ClockSource* cs, - int32_t hitsBetweenMarks, - Milliseconds msBetweenMarks) - : _clock(cs), - _hitsBetweenMarks(hitsBetweenMarks), +ElapsedTracker::ElapsedTracker(int32_t hitsBetweenMarks, int32_t msBetweenMarks) + : _hitsBetweenMarks(hitsBetweenMarks), _msBetweenMarks(msBetweenMarks), _pings(0), - _last(cs->now()) {} + _last(Listener::getElapsedTimeMillis()) {} bool ElapsedTracker::intervalHasElapsed() { if (++_pings >= _hitsBetweenMarks) { _pings = 0; - _last = _clock->now(); + _last = Listener::getElapsedTimeMillis(); return true; } - const auto now = _clock->now(); + long long now = Listener::getElapsedTimeMillis(); if (now - _last > _msBetweenMarks) { _pings = 0; _last = now; @@ -64,7 +61,7 @@ bool ElapsedTracker::intervalHasElapsed() { void ElapsedTracker::resetLastTime() { _pings = 0; - _last = _clock->now(); + _last = Listener::getElapsedTimeMillis(); } } // namespace mongo diff --git a/src/mongo/util/elapsed_tracker.h b/src/mongo/util/elapsed_tracker.h index ee087d75c84..2b14d0abf83 100644 --- a/src/mongo/util/elapsed_tracker.h +++ b/src/mongo/util/elapsed_tracker.h @@ -32,16 +32,12 @@ #include <cstdint> -#include "mongo/util/time_support.h" - namespace mongo { -class ClockSource; - /** Keep track of elapsed time. After a set amount of time, tells you to do something. */ class ElapsedTracker { public: - ElapsedTracker(ClockSource* cs, int32_t hitsBetweenMarks, Milliseconds msBetweenMarks); + ElapsedTracker(int32_t hitsBetweenMarks, int32_t msBetweenMarks); /** * Call this for every iteration. @@ -52,13 +48,12 @@ public: void resetLastTime(); private: - ClockSource* const _clock; const int32_t _hitsBetweenMarks; - const Milliseconds _msBetweenMarks; + const int32_t _msBetweenMarks; int32_t _pings; - Date_t _last; + int64_t _last; }; } // namespace mongo |