diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-06 23:04:43 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-16 23:48:45 +0000 |
commit | a200bf7708ad94661d1fc8da8776b3884ff78ef5 (patch) | |
tree | d9af222fa3376f1e8e77ab50b0c2bd8254560b88 /searchcore/src | |
parent | 2f8e6f0cb74ef77a645e7543975aca736f7649a9 (diff) |
fastos::TimeStamp -> vespalib::duration
Diffstat (limited to 'searchcore/src')
42 files changed, 237 insertions, 280 deletions
diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 1ad6b6cdc43..7b512ad2e78 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -144,7 +144,7 @@ struct MyDocumentDBReferenceResolver : public IDocumentDBReferenceResolver { std::unique_ptr<ImportedAttributesRepo> resolve(const search::IAttributeManager &, const search::IAttributeManager &, const std::shared_ptr<search::IDocumentMetaStoreContext> &, - fastos::TimeStamp) override { + vespalib::duration) override { return std::make_unique<ImportedAttributesRepo>(); } void teardown(const search::IAttributeManager &) override { } diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index 7dca5493b15..7139eb0d82d 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -115,7 +115,7 @@ struct MyDocumentDBReferenceResolver : public IDocumentDBReferenceResolver { std::unique_ptr<ImportedAttributesRepo> resolve(const search::IAttributeManager &, const search::IAttributeManager &, const std::shared_ptr<search::IDocumentMetaStoreContext> &, - fastos::TimeStamp) override { + vespalib::duration) override { return std::make_unique<ImportedAttributesRepo>(); } void teardown(const search::IAttributeManager &) override { } diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp index d2d9f573326..2782117d8ae 100644 --- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp +++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp @@ -175,10 +175,7 @@ TEST_F("requireThatVisibilityDelayIsPropagated", cm.setProtonConfig(ProtonConfigSP(new ProtonConfig(protonConfigBuilder))); cm.loadConfig(*esnap, 70, esnap); } - EXPECT_EQUAL(61.0, esnap->getMaintenanceConfigSP()->getVisibilityDelay().sec()); + EXPECT_EQUAL(61s, esnap->getMaintenanceConfigSP()->getVisibilityDelay()); } - - TEST_MAIN() { TEST_RUN_ALL(); } - diff --git a/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp b/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp index 8c1ad7bf551..3f39c872ea7 100644 --- a/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp +++ b/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp @@ -33,17 +33,17 @@ struct MyMaintenanceJob : public IBlockableMaintenanceJob size_t _runIdx; bool _blocked; MyMaintenanceJob(size_t numRuns) - : IBlockableMaintenanceJob("myjob", 10, 20), + : IBlockableMaintenanceJob("myjob", 10s, 20s), _runGates(getGateVector(numRuns)), _runIdx(0), _blocked(false) {} void block() { setBlocked(BlockedReason::RESOURCE_LIMITS); } void unBlock() { unBlock(BlockedReason::RESOURCE_LIMITS); } - virtual void setBlocked(BlockedReason) override { _blocked = true; } - virtual void unBlock(BlockedReason) override { _blocked = false; } - virtual bool isBlocked() const override { return _blocked; } - virtual bool run() override { + void setBlocked(BlockedReason) override { _blocked = true; } + void unBlock(BlockedReason) override { _blocked = false; } + bool isBlocked() const override { return _blocked; } + bool run() override { _runGates[_runIdx++]->await(5000); return _runIdx == _runGates.size(); } @@ -90,8 +90,8 @@ struct Fixture TEST_F("require that maintenance job name, delay and interval are preserved", Fixture) { EXPECT_EQUAL("myjob", f._trackedJob->getName()); - EXPECT_EQUAL(10, f._trackedJob->getDelay()); - EXPECT_EQUAL(20, f._trackedJob->getInterval()); + EXPECT_EQUAL(10s, f._trackedJob->getDelay()); + EXPECT_EQUAL(20s, f._trackedJob->getInterval()); } TEST_F("require that maintenance job that needs 1 run is tracked", Fixture) diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp index 93f3299e121..50d4106282c 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp @@ -26,10 +26,10 @@ using BlockedReason = IBlockableMaintenanceJob::BlockedReason; using TimePoint = LidUsageStats::TimePoint; constexpr uint32_t SUBDB_ID = 2; -constexpr double JOB_DELAY = 1.0; +constexpr vespalib::duration JOB_DELAY = 1s; constexpr uint32_t ALLOWED_LID_BLOAT = 1; constexpr double ALLOWED_LID_BLOAT_FACTOR = 0.3; -constexpr double REMOVE_BATCH_BLOCK_DELAY = 20.0; +constexpr vespalib::duration REMOVE_BATCH_BLOCK_DELAY = 20s; constexpr uint32_t MAX_DOCS_TO_SCAN = 100; constexpr double RESOURCE_LIMIT_FACTOR = 1.0; constexpr uint32_t MAX_OUTSTANDING_MOVE_OPS = 10; @@ -257,7 +257,7 @@ struct JobTestBase : public ::testing::Test { double allowedLidBloatFactor = ALLOWED_LID_BLOAT_FACTOR, uint32_t maxDocsToScan = MAX_DOCS_TO_SCAN, double resourceLimitFactor = RESOURCE_LIMIT_FACTOR, - double interval = JOB_DELAY, + vespalib::duration interval = JOB_DELAY, bool nodeRetired = false, uint32_t maxOutstandingMoveOps = MAX_OUTSTANDING_MOVE_OPS) { @@ -366,13 +366,13 @@ struct JobTest : public JobTestBase { double allowedLidBloatFactor = ALLOWED_LID_BLOAT_FACTOR, uint32_t maxDocsToScan = MAX_DOCS_TO_SCAN, double resourceLimitFactor = RESOURCE_LIMIT_FACTOR, - double interval = JOB_DELAY, + vespalib::duration interval = JOB_DELAY, bool nodeRetired = false, uint32_t maxOutstandingMoveOps = MAX_OUTSTANDING_MOVE_OPS) { JobTestBase::init(allowedLidBloat, allowedLidBloatFactor, maxDocsToScan, resourceLimitFactor, interval, nodeRetired, maxOutstandingMoveOps); _jobRunner = std::make_unique<MyDirectJobRunner>(*_job); } - void init_with_interval(double interval) { + void init_with_interval(vespalib::duration interval) { init(ALLOWED_LID_BLOAT, ALLOWED_LID_BLOAT_FACTOR, MAX_DOCS_TO_SCAN, RESOURCE_LIMIT_FACTOR, interval); } void init_with_node_retired(bool retired) { @@ -580,16 +580,16 @@ TEST_F(JobTest, resource_limit_factor_adjusts_limit) TEST_F(JobTest, delay_is_set_based_on_interval_and_is_max_300_secs) { - init_with_interval(301); - EXPECT_EQ(300, _job->getDelay()); - EXPECT_EQ(301, _job->getInterval()); + init_with_interval(301s); + EXPECT_EQ(300s, _job->getDelay()); + EXPECT_EQ(301s, _job->getInterval()); } TEST_F(JobTest, delay_is_set_based_on_interval_and_can_be_less_than_300_secs) { - init_with_interval(299); - EXPECT_EQ(299, _job->getDelay()); - EXPECT_EQ(299, _job->getInterval()); + init_with_interval(299s); + EXPECT_EQ(299s, _job->getDelay()); + EXPECT_EQ(299s, _job->getInterval()); } TEST_F(JobTest, job_is_disabled_when_node_is_retired) @@ -649,7 +649,7 @@ TEST_F(JobTest, job_is_re_enabled_when_remove_batch_is_no_longer_ongoing) EXPECT_TRUE(run()); // job is disabled assertJobContext(2, 9, 1, 0, 0); - _handler->set_last_remove_batch(last_remove_batch - std::chrono::seconds(static_cast<long>(REMOVE_BATCH_BLOCK_DELAY))); + _handler->set_last_remove_batch(last_remove_batch - REMOVE_BATCH_BLOCK_DELAY); EXPECT_FALSE(run()); // job executed as normal (with more work to do) assertJobContext(3, 8, 2, 0, 0); } diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index 0720f59471b..ae72637ec59 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -67,7 +67,7 @@ typedef BucketId::List BucketIdVector; typedef std::set<BucketId> BucketIdSet; constexpr int TIMEOUT_MS = 60000; -constexpr double TIMEOUT_SEC = 60.0; +constexpr vespalib::duration TIMEOUT_SEC = 60s; namespace { @@ -251,7 +251,7 @@ public: ~MyExecutor(); bool isIdle(); - bool waitIdle(double timeout); + bool waitIdle(vespalib::duration timeout); }; @@ -281,8 +281,8 @@ struct MySimpleJob : public BlockableMaintenanceJob vespalib::CountDownLatch _latch; size_t _runCnt; - MySimpleJob(double delay, - double interval, + MySimpleJob(vespalib::duration delay, + vespalib::duration interval, uint32_t finishCount) : BlockableMaintenanceJob("my_job", delay, interval), _latch(finishCount), @@ -300,8 +300,8 @@ struct MySimpleJob : public BlockableMaintenanceJob struct MySplitJob : public MySimpleJob { - MySplitJob(double delay, - double interval, + MySplitJob(vespalib::duration delay, + vespalib::duration interval, uint32_t finishCount) : MySimpleJob(delay, interval, finishCount) { @@ -318,8 +318,8 @@ struct MyLongRunningJob : public BlockableMaintenanceJob { vespalib::Gate _firstRun; - MyLongRunningJob(double delay, - double interval) + MyLongRunningJob(vespalib::duration delay, + vespalib::duration interval) : BlockableMaintenanceJob("long_running_job", delay, interval), _firstRun() { @@ -380,51 +380,24 @@ public: MaintenanceControllerFixture(); - virtual - ~MaintenanceControllerFixture(); - - void - syncSubDBs(); - - void commit() override { - } - - void commitAndWait() override { - } - - void - performSyncSubDBs(); - - void - notifyClusterStateChanged(); - - void - performNotifyClusterStateChanged(); - - void - startMaintenance(); + virtual ~MaintenanceControllerFixture(); + void syncSubDBs(); + void commit() override { } + void commitAndWait() override { } + void performSyncSubDBs(); + void notifyClusterStateChanged(); + void performNotifyClusterStateChanged(); + void startMaintenance(); void injectMaintenanceJobs(); + void performStartMaintenance(); + void stopMaintenance(); + void forwardMaintenanceConfig(); + void performForwardMaintenanceConfig(); - void - performStartMaintenance(); + void insertDocs(const test::UserDocuments &docs, MyDocumentSubDB &subDb); - void - stopMaintenance(); - - void - forwardMaintenanceConfig(); - - void - performForwardMaintenanceConfig(); - - void - insertDocs(const test::UserDocuments &docs, - MyDocumentSubDB &subDb); - - void - removeDocs(const test::UserDocuments &docs, - Timestamp timestamp); + void removeDocs(const test::UserDocuments &docs, Timestamp timestamp); void setPruneConfig(const DocumentDBPruneRemovedDocumentsConfig &pruneConfig) @@ -463,7 +436,7 @@ public: } void - setGroupingSessionPruneInterval(double groupingSessionPruneInterval) + setGroupingSessionPruneInterval(vespalib::duration groupingSessionPruneInterval) { DocumentDBMaintenanceConfig::SP newCfg(new DocumentDBMaintenanceConfig( @@ -800,11 +773,11 @@ MyExecutor::isIdle() bool -MyExecutor::waitIdle(double timeout) +MyExecutor::waitIdle(vespalib::duration timeout) { - fastos::StopWatch timer; + vespalib::Timer timer; while (!isIdle()) { - if (timer.elapsed().sec() >= timeout) + if (timer.elapsed() >= timeout) return false; } return true; @@ -1062,7 +1035,7 @@ TEST_F("require that document pruner is active", EXPECT_EQUAL(10u, f._removed.getNumUsedLids()); EXPECT_EQUAL(10u, f._removed.getDocumentCount()); MyFrozenBucket::UP frozen3(new MyFrozenBucket(f._mc, bucketId3)); - f.setPruneConfig(DocumentDBPruneRemovedDocumentsConfig(0.2, 900.0)); + f.setPruneConfig(DocumentDBPruneRemovedDocumentsConfig(200ms, 900s)); for (uint32_t i = 0; i < 6; ++i) { std::this_thread::sleep_for(100ms); ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC)); @@ -1087,7 +1060,7 @@ TEST_F("require that heartbeats are scheduled", { f.notifyClusterStateChanged(); f.startMaintenance(); - f.setHeartBeatConfig(DocumentDBHeartBeatConfig(0.2)); + f.setHeartBeatConfig(DocumentDBHeartBeatConfig(200ms)); for (uint32_t i = 0; i < 600; ++i) { std::this_thread::sleep_for(100ms); if (f._fh.getHeartBeats() != 0u) @@ -1102,7 +1075,7 @@ TEST_F("require that periodic session prunings are scheduled", ASSERT_FALSE(f._gsp.isInvoked); f.notifyClusterStateChanged(); f.startMaintenance(); - f.setGroupingSessionPruneInterval(0.2); + f.setGroupingSessionPruneInterval(200ms); for (uint32_t i = 0; i < 600; ++i) { std::this_thread::sleep_for(100ms); if (f._gsp.isInvoked) { @@ -1182,7 +1155,7 @@ TEST_F("require that active bucket is not moved until de-activated", Maintenance TEST_F("require that a simple maintenance job is executed", MaintenanceControllerFixture) { - IMaintenanceJob::UP job(new MySimpleJob(0.2, 0.2, 3)); + IMaintenanceJob::UP job(new MySimpleJob(200ms, 200ms, 3)); MySimpleJob &myJob = static_cast<MySimpleJob &>(*job); f._mc.registerJobInMasterThread(std::move(job)); f._injectDefaultJobs = false; @@ -1194,7 +1167,7 @@ TEST_F("require that a simple maintenance job is executed", MaintenanceControlle TEST_F("require that a split maintenance job is executed", MaintenanceControllerFixture) { - IMaintenanceJob::UP job(new MySplitJob(0.2, TIMEOUT_SEC * 2, 3)); + IMaintenanceJob::UP job(new MySplitJob(200ms, TIMEOUT_SEC * 2, 3)); MySplitJob &myJob = static_cast<MySplitJob &>(*job); f._mc.registerJobInMasterThread(std::move(job)); f._injectDefaultJobs = false; @@ -1239,7 +1212,7 @@ TEST_F("require that a blocked job is unblocked and executed after thaw bucket", TEST_F("require that blocked jobs are not executed", MaintenanceControllerFixture) { - IMaintenanceJob::UP job(new MySimpleJob(0.2, 0.2, 0)); + IMaintenanceJob::UP job(new MySimpleJob(200ms, 200ms, 0)); MySimpleJob &myJob = static_cast<MySimpleJob &>(*job); myJob.block(); f._mc.registerJobInMasterThread(std::move(job)); @@ -1253,7 +1226,7 @@ TEST_F("require that maintenance controller state list jobs", MaintenanceControl { { IMaintenanceJob::UP job1(new MySimpleJob(TIMEOUT_SEC * 2, TIMEOUT_SEC * 2, 0)); - IMaintenanceJob::UP job2(new MyLongRunningJob(0.2, 0.2)); + IMaintenanceJob::UP job2(new MyLongRunningJob(200ms, 200ms)); MyLongRunningJob &longRunningJob = static_cast<MyLongRunningJob &>(*job2); f._mc.registerJobInMasterThread(std::move(job1)); f._mc.registerJobInMasterThread(std::move(job2)); @@ -1365,9 +1338,9 @@ TEST_F("require that maintenance jobs are run by correct executor", MaintenanceC } void -assertPruneRemovedDocumentsConfig(double expDelay, double expInterval, double interval, MaintenanceControllerFixture &f) +assertPruneRemovedDocumentsConfig(vespalib::duration expDelay, vespalib::duration expInterval, vespalib::duration interval, MaintenanceControllerFixture &f) { - f.setPruneConfig(DocumentDBPruneRemovedDocumentsConfig(interval, 1000)); + f.setPruneConfig(DocumentDBPruneRemovedDocumentsConfig(interval, 1000s)); const auto *job = findJob(f._mc.getJobList(), "prune_removed_documents.searchdocument"); EXPECT_EQUAL(expDelay, job->getJob().getDelay()); EXPECT_EQUAL(expInterval, job->getJob().getInterval()); @@ -1375,8 +1348,8 @@ assertPruneRemovedDocumentsConfig(double expDelay, double expInterval, double in TEST_F("require that delay for prune removed documents is set based on interval and is max 300 secs", MaintenanceControllerFixture) { - assertPruneRemovedDocumentsConfig(300, 301, 301, f); - assertPruneRemovedDocumentsConfig(299, 299, 299, f); + assertPruneRemovedDocumentsConfig(300s, 301s, 301s, f); + assertPruneRemovedDocumentsConfig(299s, 299s, 299s, f); } TEST_MAIN() diff --git a/searchcore/src/tests/proton/documentdb/move_operation_limiter/move_operation_limiter_test.cpp b/searchcore/src/tests/proton/documentdb/move_operation_limiter/move_operation_limiter_test.cpp index df9aaab675c..77150370406 100644 --- a/searchcore/src/tests/proton/documentdb/move_operation_limiter/move_operation_limiter_test.cpp +++ b/searchcore/src/tests/proton/documentdb/move_operation_limiter/move_operation_limiter_test.cpp @@ -12,20 +12,20 @@ using namespace proton; struct MyBlockableMaintenanceJob : public IBlockableMaintenanceJob { bool blocked; MyBlockableMaintenanceJob() - : IBlockableMaintenanceJob("my_job", 1.0, 1.0), + : IBlockableMaintenanceJob("my_job", 1s, 1s), blocked(false) {} - virtual void setBlocked(BlockedReason reason) override { + void setBlocked(BlockedReason reason) override { ASSERT_TRUE(reason == BlockedReason::OUTSTANDING_OPS); EXPECT_FALSE(blocked); blocked = true; } - virtual void unBlock(BlockedReason reason) override { + void unBlock(BlockedReason reason) override { ASSERT_TRUE(reason == BlockedReason::OUTSTANDING_OPS); EXPECT_TRUE(blocked); blocked = false; } - virtual bool run() override { return true; } + bool run() override { return true; } }; struct Fixture { diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp index 870be2ab409..ec31e980a2e 100644 --- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp +++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp @@ -364,7 +364,7 @@ TEST_FF("require that prune removed documents interval can be set based on age", f1.protonBuilder.pruneremoveddocumentsinterval = 0; f1.addDocType("test"); auto config = getDocumentDBConfig(f1, f2); - EXPECT_EQUAL(20, config->getMaintenanceConfigSP()->getPruneRemovedDocumentsConfig().getInterval()); + EXPECT_EQUAL(20s, config->getMaintenanceConfigSP()->getPruneRemovedDocumentsConfig().getInterval()); } TEST_FF("require that docstore config computes cachesize automatically if unset", diff --git a/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp b/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp index 062586b1d0f..b77d9b3f5ab 100644 --- a/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp +++ b/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp @@ -230,18 +230,18 @@ struct Fixture { oldAttrMgr.addReferenceAttribute("parent2_ref"); oldAttrMgr.addReferenceAttribute("parent3_ref"); } - ImportedAttributesRepo::UP resolve(fastos::TimeStamp visibilityDelay, bool useReferences) { + ImportedAttributesRepo::UP resolve(vespalib::duration visibilityDelay, bool useReferences) { DocumentDBReferenceResolver resolver(registry, docModel.childDocType, importedFieldsCfg, docModel.childDocType, _gidToLidChangeListenerRefCount, _attributeFieldWriter, useReferences); return resolver.resolve(attrMgr, oldAttrMgr, std::shared_ptr<search::IDocumentMetaStoreContext>(), visibilityDelay); } - ImportedAttributesRepo::UP resolve(fastos::TimeStamp visibilityDelay) { + ImportedAttributesRepo::UP resolve(vespalib::duration visibilityDelay) { return resolve(visibilityDelay, true); } ImportedAttributesRepo::UP resolveReplay() { - return resolve(fastos::TimeStamp(0), false); + return resolve(vespalib::duration::zero(), false); } ImportedAttributesRepo::UP resolve() { - return resolve(fastos::TimeStamp(0)); + return resolve(vespalib::duration::zero()); } void teardown() { DocumentDBReferenceResolver resolver(registry, docModel.childDocType, importedFieldsCfg, docModel.childDocType, _gidToLidChangeListenerRefCount, _attributeFieldWriter, false); @@ -306,7 +306,7 @@ TEST_F("require that imported attributes are instantiated without search cache a TEST_F("require that imported attributes are instantiated with search cache if visibility delay > 0", Fixture) { - auto repo = f.resolve(fastos::TimeStamp::Seconds(1.0)); + auto repo = f.resolve(1s); EXPECT_EQUAL(2u, repo->size()); f.assertImportedAttribute("imported_a", "ref", "target_a", true, repo->get("imported_a")); f.assertImportedAttribute("imported_b", "other_ref", "target_b", true, repo->get("imported_b")); diff --git a/searchcore/src/tests/proton/server/visibility_handler/visibility_handler_test.cpp b/searchcore/src/tests/proton/server/visibility_handler/visibility_handler_test.cpp index 33ee3eb6105..ca8d0a1d26a 100644 --- a/searchcore/src/tests/proton/server/visibility_handler/visibility_handler_test.cpp +++ b/searchcore/src/tests/proton/server/visibility_handler/visibility_handler_test.cpp @@ -16,7 +16,6 @@ using proton::test::ThreadingServiceObserver; using proton::IFeedView; using proton::VisibilityHandler; using vespalib::makeLambdaTask; -using fastos::TimeStamp; namespace { @@ -28,7 +27,7 @@ public: : _serialNum(0u) { } - virtual SerialNum getSerialNum() const override { return _serialNum; } + SerialNum getSerialNum() const override { return _serialNum; } void setSerialNum(SerialNum serialNum) { _serialNum = serialNum; } }; @@ -98,14 +97,14 @@ public: } void - testCommit(double visibilityDelay, bool internal, + testCommit(vespalib::duration visibilityDelay, bool internal, uint32_t expForceCommitCount, SerialNum expCommittedSerialNum, uint32_t expMasterExecuteCnt, uint32_t expAttributeFieldWriterSyncCnt, SerialNum currSerialNum = 10u) { _getSerialNum.setSerialNum(currSerialNum); - _visibilityHandler.setVisibilityDelay(TimeStamp::Seconds(visibilityDelay)); + _visibilityHandler.setVisibilityDelay(visibilityDelay); if (internal) { VisibilityHandler *visibilityHandler = &_visibilityHandler; auto task = makeLambdaTask([=]() { visibilityHandler->commit(); }); @@ -121,7 +120,7 @@ public: } void - testCommitAndWait(double visibilityDelay, bool internal, + testCommitAndWait(vespalib::duration visibilityDelay, bool internal, uint32_t expForceCommitCount, SerialNum expCommittedSerialNum, uint32_t expMasterExecuteCnt, @@ -129,11 +128,10 @@ public: SerialNum currSerialNum = 10u) { _getSerialNum.setSerialNum(currSerialNum); - _visibilityHandler.setVisibilityDelay(TimeStamp::Seconds(visibilityDelay)); + _visibilityHandler.setVisibilityDelay(visibilityDelay); if (internal) { VisibilityHandler *visibilityHandler = &_visibilityHandler; - auto task = - makeLambdaTask([=]() { visibilityHandler->commitAndWait(); }); + auto task = makeLambdaTask([=]() { visibilityHandler->commitAndWait(); }); _writeService.master().execute(std::move(task)); _writeService.master().sync(); } else { @@ -150,62 +148,62 @@ public: TEST_F("Check external commit with zero visibility delay", Fixture) { - f.testCommit(0.0, false, 0u, 0u, 0u, 0u); + f.testCommit(0s, false, 0u, 0u, 0u, 0u); } TEST_F("Check external commit with nonzero visibility delay", Fixture) { - f.testCommit(1.0, false, 1u, 10u, 1u, 0u); + f.testCommit(1s, false, 1u, 10u, 1u, 0u); } TEST_F("Check external commit with nonzero visibility delay and no new feed operation", Fixture) { - f.testCommit(1.0, false, 1u, 0u, 1u, 0u, 0u); + f.testCommit(1s, false, 1u, 0u, 1u, 0u, 0u); } TEST_F("Check internal commit with zero visibility delay", Fixture) { - f.testCommit(0.0, true, 0u, 0u, 1u, 0u); + f.testCommit(0s, true, 0u, 0u, 1u, 0u); } TEST_F("Check internal commit with nonzero visibility delay", Fixture) { - f.testCommit(1.0, true, 1u, 10u, 1u, 0u); + f.testCommit(1s, true, 1u, 10u, 1u, 0u); } TEST_F("Check internal commit with nonzero visibility delay and no new feed operation", Fixture) { - f.testCommit(1.0, true, 1u, 0u, 1u, 0u, 0u); + f.testCommit(1s, true, 1u, 0u, 1u, 0u, 0u); } TEST_F("Check external commitAndWait with zero visibility delay", Fixture) { - f.testCommitAndWait(0.0, false, 0u, 0u, 0u, 1u); + f.testCommitAndWait(0s, false, 0u, 0u, 0u, 1u); } TEST_F("Check external commitAndWait with nonzero visibility delay", Fixture) { - f.testCommitAndWait(1.0, false, 1u, 10u, 1u, 1u); + f.testCommitAndWait(1s, false, 1u, 10u, 1u, 1u); } TEST_F("Check external commitAndWait with nonzero visibility delay and no new feed operation", Fixture) { - f.testCommitAndWait(1.0, false, 0u, 0u, 0u, 1u, 0u); + f.testCommitAndWait(1s, false, 0u, 0u, 0u, 1u, 0u); } TEST_F("Check internal commitAndWait with zero visibility delay", Fixture) { - f.testCommitAndWait(0.0, true, 0u, 0u, 1u, 1u); + f.testCommitAndWait(0s, true, 0u, 0u, 1u, 1u); } TEST_F("Check internal commitAndWait with nonzero visibility delay", Fixture) { - f.testCommitAndWait(1.0, true, 1u, 10u, 1u, 1u); + f.testCommitAndWait(1s, true, 1u, 10u, 1u, 1u); } TEST_F("Check internal commitAndWait with nonzero visibility delay and no new feed operation", Fixture) { - f.testCommitAndWait(1.0, true, 0u, 0u, 1u, 1u, 0u); + f.testCommitAndWait(1s, true, 0u, 0u, 1u, 1u, 0u); } TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.cpp index 5ba6a805a8e..0cdb97271b1 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.cpp @@ -6,19 +6,16 @@ namespace proton::documentmetastore { LidReuseDelayerConfig::LidReuseDelayerConfig() - : _visibilityDelay(0), + : _visibilityDelay(vespalib::duration::zero()), _hasIndexedOrAttributeFields(false) { } -LidReuseDelayerConfig::LidReuseDelayerConfig(const DocumentDBConfig & - configSnapshot) +LidReuseDelayerConfig::LidReuseDelayerConfig(const DocumentDBConfig & configSnapshot) : _visibilityDelay(configSnapshot.getMaintenanceConfigSP()->getVisibilityDelay()), _hasIndexedOrAttributeFields(configSnapshot.getSchemaSP()->getNumIndexFields() > 0 || configSnapshot.getSchemaSP()->getNumAttributeFields() > 0) { } - -} // namespace proton::documentmetastore - +} diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.h index a11f5ff1f24..867eccb6b20 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.h @@ -2,7 +2,7 @@ #pragma once -#include <vespa/fastos/timestamp.h> +#include <vespa/vespalib/util/time.h> namespace proton { class DocumentDBConfig; } @@ -14,12 +14,12 @@ namespace proton::documentmetastore { class LidReuseDelayerConfig { private: - fastos::TimeStamp _visibilityDelay; - bool _hasIndexedOrAttributeFields; + vespalib::duration _visibilityDelay; + bool _hasIndexedOrAttributeFields; public: LidReuseDelayerConfig(); explicit LidReuseDelayerConfig(const DocumentDBConfig &configSnapshot); - fastos::TimeStamp visibilityDelay() const { return _visibilityDelay; } + vespalib::duration visibilityDelay() const { return _visibilityDelay; } bool hasIndexedOrAttributeFields() const { return _hasIndexedOrAttributeFields; } }; diff --git a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp index 0d83eea261a..592dc26623d 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp +++ b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp @@ -182,14 +182,14 @@ ImportedAttributesRepo::UP DocumentDBReferenceResolver::resolve(const IAttributeManager &newAttrMgr, const IAttributeManager &oldAttrMgr, const std::shared_ptr<search::IDocumentMetaStoreContext> &documentMetaStore, - fastos::TimeStamp visibilityDelay) + vespalib::duration visibilityDelay) { detectOldListeners(oldAttrMgr); if (_useReferences) { connectReferenceAttributesToGidMapper(newAttrMgr); listenToGidToLidChanges(newAttrMgr); } - return createImportedAttributesRepo(newAttrMgr, documentMetaStore, (visibilityDelay > 0)); + return createImportedAttributesRepo(newAttrMgr, documentMetaStore, (visibilityDelay > vespalib::duration::zero())); } void diff --git a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.h b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.h index c23669cfc12..6ac804f538a 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.h +++ b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.h @@ -52,13 +52,13 @@ public: MonitoredRefCount &refCount, search::ISequencedTaskExecutor &attributeFieldWriter, bool useReferences); - ~DocumentDBReferenceResolver(); + ~DocumentDBReferenceResolver() override; - virtual std::unique_ptr<ImportedAttributesRepo> resolve(const search::IAttributeManager &newAttrMgr, - const search::IAttributeManager &oldAttrMgr, - const std::shared_ptr<search::IDocumentMetaStoreContext> &documentMetaStore, - fastos::TimeStamp visibilityDelay) override; - virtual void teardown(const search::IAttributeManager &oldAttrMgr) override; + std::unique_ptr<ImportedAttributesRepo> resolve(const search::IAttributeManager &newAttrMgr, + const search::IAttributeManager &oldAttrMgr, + const std::shared_ptr<search::IDocumentMetaStoreContext> &documentMetaStore, + vespalib::duration visibilityDelay) override; + void teardown(const search::IAttributeManager &oldAttrMgr) override; }; } diff --git a/searchcore/src/vespa/searchcore/proton/reference/i_document_db_reference_resolver.h b/searchcore/src/vespa/searchcore/proton/reference/i_document_db_reference_resolver.h index 8db24855de4..681538d9e34 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/i_document_db_reference_resolver.h +++ b/searchcore/src/vespa/searchcore/proton/reference/i_document_db_reference_resolver.h @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/fastos/timestamp.h> +#include <vespa/vespalib/util/time.h> #include <memory> namespace search { class IAttributeManager; struct IDocumentMetaStoreContext; } @@ -18,7 +18,7 @@ struct IDocumentDBReferenceResolver { virtual std::unique_ptr<ImportedAttributesRepo> resolve(const search::IAttributeManager &newAttrMgr, const search::IAttributeManager &oldAttrMgr, const std::shared_ptr<search::IDocumentMetaStoreContext> &documentMetaStore, - fastos::TimeStamp visibilityDelay) = 0; + vespalib::duration visibilityDelay) = 0; virtual void teardown(const search::IAttributeManager &oldAttrMgr) = 0; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/blockable_maintenance_job.cpp b/searchcore/src/vespa/searchcore/proton/server/blockable_maintenance_job.cpp index 50f638c4dd6..d8b5aa7b129 100644 --- a/searchcore/src/vespa/searchcore/proton/server/blockable_maintenance_job.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/blockable_maintenance_job.cpp @@ -27,15 +27,15 @@ BlockableMaintenanceJob::internalNotifyDiskMemUsage(const DiskMemUsageState &sta } BlockableMaintenanceJob::BlockableMaintenanceJob(const vespalib::string &name, - double delay, - double interval) + vespalib::duration delay, + vespalib::duration interval) : BlockableMaintenanceJob(name, delay, interval, BlockableMaintenanceJobConfig()) { } BlockableMaintenanceJob::BlockableMaintenanceJob(const vespalib::string &name, - double delay, - double interval, + vespalib::duration delay, + vespalib::duration interval, const BlockableMaintenanceJobConfig &config) : IBlockableMaintenanceJob(name, delay, interval), _mutex(), diff --git a/searchcore/src/vespa/searchcore/proton/server/blockable_maintenance_job.h b/searchcore/src/vespa/searchcore/proton/server/blockable_maintenance_job.h index 72405855690..db7b8d05ca2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/blockable_maintenance_job.h +++ b/searchcore/src/vespa/searchcore/proton/server/blockable_maintenance_job.h @@ -22,11 +22,11 @@ private: using LockGuard = std::lock_guard<std::mutex>; using ReasonSet = std::unordered_set<BlockedReason>; - mutable std::mutex _mutex; - ReasonSet _blockReasons; - bool _blocked; + mutable std::mutex _mutex; + ReasonSet _blockReasons; + bool _blocked; IMaintenanceJobRunner *_runner; - double _resourceLimitFactor; + double _resourceLimitFactor; void updateBlocked(const LockGuard &guard); @@ -37,23 +37,23 @@ protected: public: BlockableMaintenanceJob(const vespalib::string &name, - double delay, - double interval); + vespalib::duration delay, + vespalib::duration interval); BlockableMaintenanceJob(const vespalib::string &name, - double delay, - double interval, + vespalib::duration delay, + vespalib::duration interval, const BlockableMaintenanceJobConfig &config); - virtual ~BlockableMaintenanceJob(); + ~BlockableMaintenanceJob() override; bool isBlocked(BlockedReason reason); void considerRun(); - virtual void setBlocked(BlockedReason reason) override; - virtual void unBlock(BlockedReason reason) override; - virtual bool isBlocked() const override; - virtual void registerRunner(IMaintenanceJobRunner *runner) override { _runner = runner; } + void setBlocked(BlockedReason reason) override; + void unBlock(BlockedReason reason) override; + bool isBlocked() const override; + void registerRunner(IMaintenanceJobRunner *runner) override { _runner = runner; } }; diff --git a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp index 4848c5a5d47..17b8b9e30e0 100644 --- a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp @@ -162,7 +162,7 @@ BucketMoveJob(const IBucketStateCalculator::SP &calc, const BlockableMaintenanceJobConfig &blockableConfig, const vespalib::string &docTypeName, document::BucketSpace bucketSpace) - : BlockableMaintenanceJob("move_buckets." + docTypeName, 0.0, 0.0, blockableConfig), + : BlockableMaintenanceJob("move_buckets." + docTypeName, vespalib::duration::zero(), vespalib::duration::zero(), blockableConfig), IClusterStateChangedHandler(), IBucketFreezeListener(), bucketdb::IBucketCreateListener(), diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp index 8a4cb1682a6..10ee33df019 100644 --- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp @@ -9,11 +9,10 @@ using vespalib::makeLambdaTask; namespace proton { -DiskMemUsageSampler::DiskMemUsageSampler(const std::string &path_in, - const Config &config) +DiskMemUsageSampler::DiskMemUsageSampler(const std::string &path_in, const Config &config) : _filter(config.hwInfo), _path(path_in), - _sampleInterval(60.0), + _sampleInterval(60s), _periodicTimer() { setConfig(config); diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.h b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.h index 2ab13f2f48a..ba204cc1d0f 100644 --- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.h +++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.h @@ -2,6 +2,7 @@ #pragma once +#include <vespa/vespalib/util/time.h> #include "disk_mem_usage_filter.h" namespace vespalib { class ScheduledExecutor; } @@ -14,7 +15,7 @@ namespace proton { class DiskMemUsageSampler { DiskMemUsageFilter _filter; std::filesystem::path _path; - double _sampleInterval; + vespalib::duration _sampleInterval; std::unique_ptr<vespalib::ScheduledExecutor> _periodicTimer; void sampleUsage(); @@ -23,19 +24,19 @@ class DiskMemUsageSampler { public: struct Config { DiskMemUsageFilter::Config filterConfig; - double sampleInterval; + vespalib::duration sampleInterval; HwInfo hwInfo; Config() : filterConfig(), - sampleInterval(60.0), + sampleInterval(60s), hwInfo() { } Config(double memoryLimit_in, double diskLimit_in, - double sampleInterval_in, + vespalib::duration sampleInterval_in, const HwInfo &hwInfo_in) : filterConfig(memoryLimit_in, diskLimit_in), sampleInterval(sampleInterval_in), diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_flush_config.h b/searchcore/src/vespa/searchcore/proton/server/document_db_flush_config.h index 316d0716477..438b2b13759 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_db_flush_config.h +++ b/searchcore/src/vespa/searchcore/proton/server/document_db_flush_config.h @@ -1,6 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include <cstdint> + namespace proton { /* diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_maintenance_config.cpp b/searchcore/src/vespa/searchcore/proton/server/document_db_maintenance_config.cpp index b470a390b50..976b5b3e763 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_db_maintenance_config.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/document_db_maintenance_config.cpp @@ -4,19 +4,18 @@ namespace proton { -constexpr double MAX_DELAY_SEC = 300; +constexpr vespalib::duration MAX_DELAY_SEC = 300s; DocumentDBPruneConfig:: DocumentDBPruneConfig() : _delay(MAX_DELAY_SEC), - _interval(21600.0), - _age(1209600.0) + _interval(21600s), + _age(1209600s) { } DocumentDBPruneConfig:: -DocumentDBPruneConfig(double interval, - double age) +DocumentDBPruneConfig(vespalib::duration interval, vespalib::duration age) : _delay(std::min(MAX_DELAY_SEC, interval)), _interval(interval), _age(age) @@ -33,11 +32,11 @@ operator==(const DocumentDBPruneConfig &rhs) const } DocumentDBHeartBeatConfig::DocumentDBHeartBeatConfig() - : _interval(60.0) + : _interval(60s) { } -DocumentDBHeartBeatConfig::DocumentDBHeartBeatConfig(double interval) +DocumentDBHeartBeatConfig::DocumentDBHeartBeatConfig(vespalib::duration interval) : _interval(interval) { } @@ -51,19 +50,19 @@ operator==(const DocumentDBHeartBeatConfig &rhs) const DocumentDBLidSpaceCompactionConfig::DocumentDBLidSpaceCompactionConfig() : _delay(MAX_DELAY_SEC), - _interval(3600), + _interval(3600s), _allowedLidBloat(1000000000), _allowedLidBloatFactor(1.0), - _remove_batch_block_delay(5.0), + _remove_batch_block_delay(5s), _disabled(false), _maxDocsToScan(10000) { } -DocumentDBLidSpaceCompactionConfig::DocumentDBLidSpaceCompactionConfig(double interval, +DocumentDBLidSpaceCompactionConfig::DocumentDBLidSpaceCompactionConfig(vespalib::duration interval, uint32_t allowedLidBloat, double allowedLidBloatFactor, - double remove_batch_block_delay, + vespalib::duration remove_batch_block_delay, bool disabled, uint32_t maxDocsToScan) : _delay(std::min(MAX_DELAY_SEC, interval)), @@ -116,25 +115,24 @@ BlockableMaintenanceJobConfig::operator==(const BlockableMaintenanceJobConfig &r DocumentDBMaintenanceConfig::DocumentDBMaintenanceConfig() : _pruneRemovedDocuments(), _heartBeat(), - _sessionCachePruneInterval(900.0), + _sessionCachePruneInterval(900s), _visibilityDelay(0), _lidSpaceCompaction(), _attributeUsageFilterConfig(), - _attributeUsageSampleInterval(60.0), + _attributeUsageSampleInterval(60s), _blockableJobConfig(), _flushConfig() { } DocumentDBMaintenanceConfig:: -DocumentDBMaintenanceConfig(const DocumentDBPruneRemovedDocumentsConfig & - pruneRemovedDocuments, +DocumentDBMaintenanceConfig(const DocumentDBPruneRemovedDocumentsConfig &pruneRemovedDocuments, const DocumentDBHeartBeatConfig &heartBeat, - double groupingSessionPruneInterval, - fastos::TimeStamp visibilityDelay, + vespalib::duration groupingSessionPruneInterval, + vespalib::duration visibilityDelay, const DocumentDBLidSpaceCompactionConfig &lidSpaceCompaction, const AttributeUsageFilterConfig &attributeUsageFilterConfig, - double attributeUsageSampleInterval, + vespalib::duration attributeUsageSampleInterval, const BlockableMaintenanceJobConfig &blockableJobConfig, const DocumentDBFlushConfig &flushConfig) : _pruneRemovedDocuments(pruneRemovedDocuments), diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_maintenance_config.h b/searchcore/src/vespa/searchcore/proton/server/document_db_maintenance_config.h index 4b458765f3c..283d66e8295 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_db_maintenance_config.h +++ b/searchcore/src/vespa/searchcore/proton/server/document_db_maintenance_config.h @@ -1,28 +1,28 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/vespalib/stllike/string.h> -#include <vespa/searchcore/proton/attribute/attribute_usage_filter_config.h> -#include <vespa/fastos/timestamp.h> #include "document_db_flush_config.h" +#include <vespa/searchcore/proton/attribute/attribute_usage_filter_config.h> +#include <vespa/vespalib/stllike/string.h> +#include <vespa/vespalib/util/time.h> namespace proton { class DocumentDBPruneConfig { private: - double _delay; - double _interval; - double _age; + vespalib::duration _delay; + vespalib::duration _interval; + vespalib::duration _age; public: DocumentDBPruneConfig(); - DocumentDBPruneConfig(double interval, double age); + DocumentDBPruneConfig(vespalib::duration interval, vespalib::duration age); bool operator==(const DocumentDBPruneConfig &rhs) const; - double getDelay() const { return _delay; } - double getInterval() const { return _interval; } - double getAge() const { return _age; } + vespalib::duration getDelay() const { return _delay; } + vespalib::duration getInterval() const { return _interval; } + vespalib::duration getAge() const { return _age; } }; typedef DocumentDBPruneConfig DocumentDBPruneRemovedDocumentsConfig; @@ -30,43 +30,43 @@ typedef DocumentDBPruneConfig DocumentDBPruneRemovedDocumentsConfig; class DocumentDBHeartBeatConfig { private: - double _interval; + vespalib::duration _interval; public: DocumentDBHeartBeatConfig(); - DocumentDBHeartBeatConfig(double interval); + DocumentDBHeartBeatConfig(vespalib::duration interval); bool operator==(const DocumentDBHeartBeatConfig &rhs) const; - double getInterval() const { return _interval; } + vespalib::duration getInterval() const { return _interval; } }; class DocumentDBLidSpaceCompactionConfig { private: - double _delay; - double _interval; - uint32_t _allowedLidBloat; - double _allowedLidBloatFactor; - double _remove_batch_block_delay; - bool _disabled; - uint32_t _maxDocsToScan; + vespalib::duration _delay; + vespalib::duration _interval; + uint32_t _allowedLidBloat; + double _allowedLidBloatFactor; + vespalib::duration _remove_batch_block_delay; + bool _disabled; + uint32_t _maxDocsToScan; public: DocumentDBLidSpaceCompactionConfig(); - DocumentDBLidSpaceCompactionConfig(double interval, + DocumentDBLidSpaceCompactionConfig(vespalib::duration interval, uint32_t allowedLidBloat, double allowwedLidBloatFactor, - double remove_batch_block_delay, + vespalib::duration remove_batch_block_delay, bool disabled, uint32_t maxDocsToScan = 10000); static DocumentDBLidSpaceCompactionConfig createDisabled(); bool operator==(const DocumentDBLidSpaceCompactionConfig &rhs) const; - double getDelay() const { return _delay; } - double getInterval() const { return _interval; } + vespalib::duration getDelay() const { return _delay; } + vespalib::duration getInterval() const { return _interval; } uint32_t getAllowedLidBloat() const { return _allowedLidBloat; } double getAllowedLidBloatFactor() const { return _allowedLidBloatFactor; } - double get_remove_batch_block_delay() const { return _remove_batch_block_delay; } + vespalib::duration get_remove_batch_block_delay() const { return _remove_batch_block_delay; } bool isDisabled() const { return _disabled; } uint32_t getMaxDocsToScan() const { return _maxDocsToScan; } }; @@ -93,11 +93,11 @@ public: private: DocumentDBPruneRemovedDocumentsConfig _pruneRemovedDocuments; DocumentDBHeartBeatConfig _heartBeat; - double _sessionCachePruneInterval; - fastos::TimeStamp _visibilityDelay; + vespalib::duration _sessionCachePruneInterval; + vespalib::duration _visibilityDelay; DocumentDBLidSpaceCompactionConfig _lidSpaceCompaction; AttributeUsageFilterConfig _attributeUsageFilterConfig; - double _attributeUsageSampleInterval; + vespalib::duration _attributeUsageSampleInterval; BlockableMaintenanceJobConfig _blockableJobConfig; DocumentDBFlushConfig _flushConfig; @@ -106,11 +106,11 @@ public: DocumentDBMaintenanceConfig(const DocumentDBPruneRemovedDocumentsConfig &pruneRemovedDocuments, const DocumentDBHeartBeatConfig &heartBeat, - double sessionCachePruneInterval, - fastos::TimeStamp visibilityDelay, + vespalib::duration sessionCachePruneInterval, + vespalib::duration visibilityDelay, const DocumentDBLidSpaceCompactionConfig &lidSpaceCompaction, const AttributeUsageFilterConfig &attributeUsageFilterConfig, - double attributeUsageSampleInterval, + vespalib::duration attributeUsageSampleInterval, const BlockableMaintenanceJobConfig &blockableJobConfig, const DocumentDBFlushConfig &flushConfig); @@ -123,17 +123,18 @@ public: const DocumentDBHeartBeatConfig &getHeartBeatConfig() const { return _heartBeat; } - double getSessionCachePruneInterval() const { + vespalib::duration getSessionCachePruneInterval() const { return _sessionCachePruneInterval; } - fastos::TimeStamp getVisibilityDelay() const { return _visibilityDelay; } + vespalib::duration getVisibilityDelay() const { return _visibilityDelay; } + bool hasVisibilityDelay() const { return _visibilityDelay > vespalib::duration::zero(); } const DocumentDBLidSpaceCompactionConfig &getLidSpaceCompactionConfig() const { return _lidSpaceCompaction; } const AttributeUsageFilterConfig &getAttributeUsageFilterConfig() const { return _attributeUsageFilterConfig; } - double getAttributeUsageSampleInterval() const { + vespalib::duration getAttributeUsageSampleInterval() const { return _attributeUsageSampleInterval; } const BlockableMaintenanceJobConfig &getBlockableJobConfig() const { diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 1532ab35c26..1b182c3e618 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -13,7 +13,6 @@ #include "maintenance_jobs_injector.h" #include "reconfig_params.h" #include <vespa/document/repo/documenttyperepo.h> -#include <vespa/searchcommon/common/schemaconfigurer.h> #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/attribute/imported_attributes_repo.h> #include <vespa/searchcore/proton/common/eventlogger.h> @@ -26,12 +25,10 @@ #include <vespa/searchcore/proton/metrics/metricswireservice.h> #include <vespa/searchcore/proton/reference/document_db_reference_resolver.h> #include <vespa/searchcore/proton/reference/i_document_db_reference_registry.h> -#include <vespa/searchcore/proton/reference/i_document_db_reference_resolver.h> #include <vespa/searchlib/attribute/attributefactory.h> #include <vespa/searchlib/attribute/configconverter.h> #include <vespa/searchlib/engine/docsumreply.h> #include <vespa/searchlib/engine/searchreply.h> -#include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/closuretask.h> #include <vespa/vespalib/util/exceptions.h> @@ -42,7 +39,6 @@ LOG_SETUP(".proton.server.documentdb"); using vespa::config::search::AttributesConfig; using vespa::config::search::core::ProtonConfig; -using search::index::SchemaBuilder; using vespalib::JSONStringer; using vespalib::Executor; using vespalib::IllegalStateException; @@ -212,9 +208,9 @@ DocumentDB::DocumentDB(const vespalib::string &baseDir, _lidSpaceCompactionHandlers.push_back(std::make_unique<LidSpaceCompactionHandler>(_maintenanceController.getNotReadySubDB(), _docTypeName.getName())); _writeFilter.setConfig(loaded_config->getMaintenanceConfigSP()->getAttributeUsageFilterConfig()); - fastos::TimeStamp visibilityDelay = loaded_config->getMaintenanceConfigSP()->getVisibilityDelay(); + vespalib::duration visibilityDelay = loaded_config->getMaintenanceConfigSP()->getVisibilityDelay(); _visibility.setVisibilityDelay(visibilityDelay); - if (_visibility.getVisibilityDelay() > 0) { + if (_visibility.hasVisibilityDelay()) { _writeService.setTaskLimit(_writeServiceConfig.semiUnboundTaskLimit(), _writeServiceConfig.defaultTaskLimit()); } } @@ -453,11 +449,11 @@ DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum // Flush changes to attributes and memory index, cf. visibilityDelay _feedView.get()->forceCommit(elidedConfigSave ? serialNum : serialNum - 1); _writeService.sync(); - fastos::TimeStamp visibilityDelay = configSnapshot->getMaintenanceConfigSP()->getVisibilityDelay(); + vespalib::duration visibilityDelay = configSnapshot->getMaintenanceConfigSP()->getVisibilityDelay(); hasVisibilityDelayChanged = (visibilityDelay != _visibility.getVisibilityDelay()); _visibility.setVisibilityDelay(visibilityDelay); } - if (_visibility.getVisibilityDelay() > 0) { + if (_visibility.hasVisibilityDelay()) { _writeService.setTaskLimit(_writeServiceConfig.semiUnboundTaskLimit(), _writeServiceConfig.defaultTaskLimit()); } else { _writeService.setTaskLimit(_writeServiceConfig.defaultTaskLimit(), _writeServiceConfig.defaultTaskLimit()); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb_commit_job.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb_commit_job.cpp index 51126faa090..81979bbfb94 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb_commit_job.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb_commit_job.cpp @@ -5,8 +5,8 @@ namespace proton { -DocumentDBCommitJob::DocumentDBCommitJob(ICommitable & committer, fastos::TimeStamp visibilityDelay) : - IMaintenanceJob("documentdb_commit", visibilityDelay.sec(), visibilityDelay.sec()), +DocumentDBCommitJob::DocumentDBCommitJob(ICommitable & committer, vespalib::duration visibilityDelay) : + IMaintenanceJob("documentdb_commit", visibilityDelay, visibilityDelay), _committer(committer) { } diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb_commit_job.h b/searchcore/src/vespa/searchcore/proton/server/documentdb_commit_job.h index 62307566857..c375d513276 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb_commit_job.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb_commit_job.h @@ -2,7 +2,7 @@ #pragma once #include "i_maintenance_job.h" -#include <vespa/fastos/timestamp.h> +#include <vespa/vespalib/util/time.h> namespace proton { @@ -17,7 +17,7 @@ private: ICommitable & _committer; public: - DocumentDBCommitJob(ICommitable & committer, fastos::TimeStamp visibilityDelay); + DocumentDBCommitJob(ICommitable & committer, vespalib::duration visibilityDelay); bool run() override; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp index 20d11c43a68..b15f72b5391 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp @@ -26,7 +26,6 @@ using namespace vespa::config::search::summary; using namespace vespa::config::search; using document::DocumentTypeRepo; -using fastos::TimeStamp; using search::TuneFileDocumentDB; using search::index::Schema; using search::index::SchemaBuilder; @@ -105,7 +104,7 @@ buildMaintenanceConfig(const BootstrapConfig::SP &bootstrapConfig, typedef ProtonConfig::Documentdb DdbConfig; ProtonConfig &proton(bootstrapConfig->getProtonConfig()); - TimeStamp visibilityDelay; + vespalib::duration visibilityDelay; bool isDocumentTypeGlobal = false; // Use document type to find document db config in proton config uint32_t index; @@ -114,13 +113,14 @@ buildMaintenanceConfig(const BootstrapConfig::SP &bootstrapConfig, if (docTypeName == ddbConfig.inputdoctypename) break; } - double pruneRemovedDocumentsAge = proton.pruneremoveddocumentsage; - double pruneRemovedDocumentsInterval = (proton.pruneremoveddocumentsinterval == 0) ? - (pruneRemovedDocumentsAge / 100) : proton.pruneremoveddocumentsinterval; + vespalib::duration pruneRemovedDocumentsAge = vespalib::from_s(proton.pruneremoveddocumentsage); + vespalib::duration pruneRemovedDocumentsInterval = (proton.pruneremoveddocumentsinterval == 0) + ? (pruneRemovedDocumentsAge / 100) + : vespalib::from_s(proton.pruneremoveddocumentsinterval); if (index < proton.documentdb.size()) { const DdbConfig &ddbConfig = proton.documentdb[index]; - visibilityDelay = TimeStamp::Seconds(std::min(proton.maxvisibilitydelay, ddbConfig.visibilitydelay)); + visibilityDelay = vespalib::from_s(std::min(proton.maxvisibilitydelay, ddbConfig.visibilitydelay)); isDocumentTypeGlobal = ddbConfig.global; } return std::make_shared<DocumentDBMaintenanceConfig>( @@ -128,18 +128,18 @@ buildMaintenanceConfig(const BootstrapConfig::SP &bootstrapConfig, pruneRemovedDocumentsInterval, pruneRemovedDocumentsAge), DocumentDBHeartBeatConfig(), - proton.grouping.sessionmanager.pruning.interval, + vespalib::from_s(proton.grouping.sessionmanager.pruning.interval), visibilityDelay, DocumentDBLidSpaceCompactionConfig( - proton.lidspacecompaction.interval, + vespalib::from_s(proton.lidspacecompaction.interval), proton.lidspacecompaction.allowedlidbloat, proton.lidspacecompaction.allowedlidbloatfactor, - proton.lidspacecompaction.removebatchblockdelay, + vespalib::from_s(proton.lidspacecompaction.removebatchblockdelay), isDocumentTypeGlobal), AttributeUsageFilterConfig( proton.writefilter.attribute.enumstorelimit, proton.writefilter.attribute.multivaluelimit), - proton.writefilter.sampleinterval, + vespalib::from_s(proton.writefilter.sampleinterval), BlockableMaintenanceJobConfig( proton.maintenancejobs.resourcelimitfactor, proton.maintenancejobs.maxoutstandingmoveops), diff --git a/searchcore/src/vespa/searchcore/proton/server/i_blockable_maintenance_job.h b/searchcore/src/vespa/searchcore/proton/server/i_blockable_maintenance_job.h index 9544485cc86..c70a6c502f1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/i_blockable_maintenance_job.h +++ b/searchcore/src/vespa/searchcore/proton/server/i_blockable_maintenance_job.h @@ -2,7 +2,6 @@ #pragma once #include "i_maintenance_job.h" -#include <string> namespace proton { @@ -20,8 +19,8 @@ public: }; IBlockableMaintenanceJob(const vespalib::string &name, - double delay, - double interval) + vespalib::duration delay, + vespalib::duration interval) : IMaintenanceJob(name, delay, interval) {} diff --git a/searchcore/src/vespa/searchcore/proton/server/i_maintenance_job.h b/searchcore/src/vespa/searchcore/proton/server/i_maintenance_job.h index e32fd01df63..6d0739e1aed 100644 --- a/searchcore/src/vespa/searchcore/proton/server/i_maintenance_job.h +++ b/searchcore/src/vespa/searchcore/proton/server/i_maintenance_job.h @@ -2,6 +2,7 @@ #pragma once #include <vespa/vespalib/stllike/string.h> +#include <vespa/vespalib/util/time.h> namespace proton { @@ -15,16 +16,16 @@ class IMaintenanceJobRunner; class IMaintenanceJob { private: - const vespalib::string _name; - const double _delay; - const double _interval; + const vespalib::string _name; + const vespalib::duration _delay; + const vespalib::duration _interval; public: typedef std::unique_ptr<IMaintenanceJob> UP; IMaintenanceJob(const vespalib::string &name, - double delay, - double interval) + vespalib::duration delay, + vespalib::duration interval) : _name(name), _delay(delay), _interval(interval) @@ -33,8 +34,8 @@ public: virtual ~IMaintenanceJob() {} virtual const vespalib::string &getName() const { return _name; } - virtual double getDelay() const { return _delay; } - virtual double getInterval() const { return _interval; } + virtual vespalib::duration getDelay() const { return _delay; } + virtual vespalib::duration getInterval() const { return _interval; } virtual bool isBlocked() const { return false; } virtual IBlockableMaintenanceJob *asBlockable() { return nullptr; } diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.cpp index c20ddd77887..6ab7fe373c4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.cpp @@ -28,8 +28,8 @@ convertAllJobsToSlime(const std::vector<MaintenanceJobRunner::SP> &jobs, Cursor Cursor &object = array.addObject(); const IMaintenanceJob &job = jobRunner->getJob(); object.setString("name", job.getName()); - object.setDouble("delay", job.getDelay()); - object.setDouble("interval", job.getInterval()); + object.setDouble("delay", vespalib::to_s(job.getDelay())); + object.setDouble("interval", vespalib::to_s(job.getInterval())); object.setBool("blocked", job.isBlocked()); } } diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp index b9a5bb65e45..acbd8c5e61a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp @@ -107,7 +107,7 @@ MaintenanceJobsInjector::injectJobs(MaintenanceController &controller, typedef IMaintenanceJob::UP MUP; controller.registerJobInMasterThread(MUP(new HeartBeatJob(hbHandler, config.getHeartBeatConfig()))); controller.registerJobInDefaultPool(MUP(new PruneSessionCacheJob(scPruner, config.getSessionCachePruneInterval()))); - if (config.getVisibilityDelay() > 0) { + if (config.hasVisibilityDelay()) { controller.registerJobInMasterThread(MUP(new DocumentDBCommitJob(commit, config.getVisibilityDelay()))); } const MaintenanceDocumentSubDB &mRemSubDB(controller.getRemSubDB()); diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp index 893748ae49e..f29e54ba725 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp @@ -179,8 +179,8 @@ MaintenanceController::addJobsToPeriodicTimer() for (const auto &jw : _jobs) { const IMaintenanceJob &job = jw->getJob(); LOG(debug, "addJobsToPeriodicTimer(): docType='%s', job.name='%s', job.delay=%f, job.interval=%f", - _docTypeName.getName().c_str(), job.getName().c_str(), job.getDelay(), job.getInterval()); - if (job.getInterval() == 0.0) { + _docTypeName.getName().c_str(), job.getName().c_str(), vespalib::to_s(job.getDelay()), vespalib::to_s(job.getInterval())); + if (job.getInterval() == vespalib::duration::zero()) { jw->run(); continue; } diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index 48cede5943d..4daf3e895af 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -96,7 +96,7 @@ diskMemUsageSamplerConfig(const ProtonConfig &proton, const HwInfo &hwInfo) return DiskMemUsageSampler::Config( proton.writefilter.memorylimit, proton.writefilter.disklimit, - proton.writefilter.sampleinterval, + vespalib::from_s(proton.writefilter.sampleinterval), hwInfo); } diff --git a/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp b/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp index 70ed5b29541..afbabfcd0be 100644 --- a/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp @@ -5,7 +5,7 @@ namespace proton { using matching::ISessionCachePruner; -PruneSessionCacheJob::PruneSessionCacheJob(ISessionCachePruner &pruner, double jobInterval) +PruneSessionCacheJob::PruneSessionCacheJob(ISessionCachePruner &pruner, vespalib::duration jobInterval) : IMaintenanceJob("prune_session_cache", jobInterval, jobInterval), _pruner(pruner) { diff --git a/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.h b/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.h index 531707bf4f3..99a2a41f114 100644 --- a/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.h +++ b/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.h @@ -15,11 +15,9 @@ private: matching::ISessionCachePruner &_pruner; public: - PruneSessionCacheJob(matching::ISessionCachePruner &pruner, - double jobInterval); + PruneSessionCacheJob(matching::ISessionCachePruner &pruner, vespalib::duration jobInterval); - // Implements IMaintenanceJob - virtual bool run() override; + bool run() override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp index 8be58311798..43be4e9accd 100644 --- a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp @@ -37,8 +37,7 @@ PruneRemovedDocumentsJob(const Config &config, void -PruneRemovedDocumentsJob::flush(DocId lowLid, DocId nextLowLid, - const Timestamp ageLimit) +PruneRemovedDocumentsJob::flush(DocId lowLid, DocId nextLowLid, const Timestamp ageLimit) { if (_pruneLids.empty()) return; @@ -65,10 +64,9 @@ PruneRemovedDocumentsJob::flush(DocId lowLid, DocId nextLowLid, bool PruneRemovedDocumentsJob::run() { - uint64_t tshz = 1000000; vespalib::system_time now = vespalib::system_clock::now(); const Timestamp ageLimit(static_cast<Timestamp::Type> - ((vespalib::to_s(now.time_since_epoch()) - _cfgAgeLimit) * tshz)); + (vespalib::count_us(now.time_since_epoch() - _cfgAgeLimit))); DocId lid(_nextLid); const DocId olid(lid); const DocId docIdLimit(_metaStore.getCommittedDocIdLimit()); diff --git a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h index 42c5d964aed..76967635f4a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h +++ b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h @@ -20,7 +20,7 @@ class PruneRemovedDocumentsJob : public BlockableMaintenanceJob private: const IDocumentMetaStore &_metaStore; // external ownership uint32_t _subDbId; - double _cfgAgeLimit; + vespalib::duration _cfgAgeLimit; const vespalib::string &_docTypeName; IPruneRemovedDocumentsHandler &_handler; IFrozenBucketHandler &_frozenHandler; diff --git a/searchcore/src/vespa/searchcore/proton/server/sample_attribute_usage_job.cpp b/searchcore/src/vespa/searchcore/proton/server/sample_attribute_usage_job.cpp index 13f2934f161..1f5f29c7708 100644 --- a/searchcore/src/vespa/searchcore/proton/server/sample_attribute_usage_job.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/sample_attribute_usage_job.cpp @@ -13,8 +13,8 @@ SampleAttributeUsageJob(IAttributeManagerSP readyAttributeManager, IAttributeManagerSP notReadyAttributeManager, AttributeUsageFilter &attributeUsageFilter, const vespalib::string &docTypeName, - double interval) - : IMaintenanceJob("sample_attribute_usage." + docTypeName, 0.0, interval), + vespalib::duration interval) + : IMaintenanceJob("sample_attribute_usage." + docTypeName, vespalib::duration::zero(), interval), _readyAttributeManager(readyAttributeManager), _notReadyAttributeManager(notReadyAttributeManager), _attributeUsageFilter(attributeUsageFilter) diff --git a/searchcore/src/vespa/searchcore/proton/server/sample_attribute_usage_job.h b/searchcore/src/vespa/searchcore/proton/server/sample_attribute_usage_job.h index 4f2b6155cb1..72a0bf1a665 100644 --- a/searchcore/src/vespa/searchcore/proton/server/sample_attribute_usage_job.h +++ b/searchcore/src/vespa/searchcore/proton/server/sample_attribute_usage_job.h @@ -26,8 +26,8 @@ public: IAttributeManagerSP notReadyAttributeManager, AttributeUsageFilter &attributeUsageFilter, const vespalib::string &docTypeName, - double interval); - ~SampleAttributeUsageJob(); + vespalib::duration interval); + ~SampleAttributeUsageJob() override; bool run() override; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index 4f55d7fc127..9b2d846b2ed 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -394,14 +394,14 @@ StoreOnlyDocSubDB::updateLidReuseDelayer(const DocumentDBConfig * newConfigSnaps void StoreOnlyDocSubDB::updateLidReuseDelayer(const LidReuseDelayerConfig &config) { - bool immediateCommit = config.visibilityDelay() == 0; + bool immediateCommit = config.visibilityDelay() == vespalib::duration::zero(); /* * The lid reuse delayer should not have any pending lids stored at this * time, since DocumentDB::applyConfig() calls forceCommit() on the * feed view before applying the new config to the sub dbs. */ _lidReuseDelayer->setImmediateCommit(immediateCommit); - _commitTimeTracker.setVisibilityDelay(vespalib::from_s(config.visibilityDelay())); + _commitTimeTracker.setVisibilityDelay(config.visibilityDelay()); } IReprocessingTask::List diff --git a/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.cpp index 71197a5c530..fd2ad017a28 100644 --- a/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.cpp @@ -23,7 +23,7 @@ VisibilityHandler::VisibilityHandler(const IGetSerialNum & serial, void VisibilityHandler::commit() { - if (_visibilityDelay != 0) { + if (_visibilityDelay > vespalib::duration::zero()) { if (_writeService.master().isCurrentThread()) { performCommit(true); } else { @@ -35,7 +35,7 @@ void VisibilityHandler::commit() void VisibilityHandler::commitAndWait() { - if (_visibilityDelay != 0) { + if (_visibilityDelay > vespalib::duration::zero()) { if (_writeService.master().isCurrentThread()) { performCommit(false); } else { diff --git a/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h b/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h index 25add844d25..370af482c6a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h +++ b/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h @@ -2,12 +2,11 @@ #pragma once -#include <vespa/searchcore/proton/server/ifeedview.h> -#include <vespa/searchcore/proton/server/icommitable.h> -#include <vespa/searchcore/proton/server/igetserialnum.h> +#include "ifeedview.h" +#include "icommitable.h" +#include "igetserialnum.h" #include <vespa/searchcorespi/index/ithreadingservice.h> #include <vespa/vespalib/util/varholder.h> -#include <vespa/fastos/timestamp.h> #include <mutex> namespace proton { @@ -18,7 +17,6 @@ namespace proton { **/ class VisibilityHandler : public ICommitable { - typedef fastos::TimeStamp TimeStamp; using IThreadingService = searchcorespi::index::IThreadingService; typedef vespalib::ThreadExecutor ThreadExecutor; typedef vespalib::VarHolder<IFeedView::SP> FeedViewHolder; @@ -27,8 +25,9 @@ public: VisibilityHandler(const IGetSerialNum &serial, IThreadingService &threadingService, const FeedViewHolder &feedView); - void setVisibilityDelay(TimeStamp visibilityDelay) { _visibilityDelay = visibilityDelay; } - TimeStamp getVisibilityDelay() const { return _visibilityDelay; } + void setVisibilityDelay(vespalib::duration visibilityDelay) { _visibilityDelay = visibilityDelay; } + vespalib::duration getVisibilityDelay() const { return _visibilityDelay; } + bool hasVisibilityDelay() const { return _visibilityDelay > vespalib::duration::zero(); } void commit() override; virtual void commitAndWait() override; private: @@ -37,7 +36,7 @@ private: const IGetSerialNum & _serial; IThreadingService & _writeService; const FeedViewHolder & _feedView; - TimeStamp _visibilityDelay; + vespalib::duration _visibilityDelay; SerialNum _lastCommitSerialNum; std::mutex _lock; }; |