diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-05-18 07:20:18 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-05-18 07:20:18 +0000 |
commit | 714346ca5e18851c784101537bcb9b0877d413a9 (patch) | |
tree | 121764ca0af5de204005d6b16d00a867f07fc5d8 | |
parent | f05f60b1ec40be6f3e60349d65da60bc41555db3 (diff) |
Move ScheduledExecutor to searchcore and drop fnet dependency in staging_vespalib in order to prepare collapsing stagingg vespalib into vespalib
13 files changed, 25 insertions, 23 deletions
diff --git a/searchcore/CMakeLists.txt b/searchcore/CMakeLists.txt index 8df693e8ea2..c0b86b509b3 100644 --- a/searchcore/CMakeLists.txt +++ b/searchcore/CMakeLists.txt @@ -80,6 +80,7 @@ vespa_define_module( src/tests/proton/common/hw_info_sampler src/tests/proton/common/operation_rate_tracker src/tests/proton/common/state_reporter_utils + src/tests/proton/common/timer src/tests/proton/docsummary src/tests/proton/document_iterator src/tests/proton/documentdb diff --git a/staging_vespalib/src/tests/timer/.gitignore b/searchcore/src/tests/proton/common/timer/.gitignore index 9031e40152a..9031e40152a 100644 --- a/staging_vespalib/src/tests/timer/.gitignore +++ b/searchcore/src/tests/proton/common/timer/.gitignore diff --git a/staging_vespalib/src/tests/timer/CMakeLists.txt b/searchcore/src/tests/proton/common/timer/CMakeLists.txt index 9fd12f11c7c..7afd366ed89 100644 --- a/staging_vespalib/src/tests/timer/CMakeLists.txt +++ b/searchcore/src/tests/proton/common/timer/CMakeLists.txt @@ -3,6 +3,6 @@ vespa_add_executable(staging_vespalib_timer_test_app TEST SOURCES timer_test.cpp DEPENDS - staging_vespalib + searchcore_pcommon ) vespa_add_test(NAME staging_vespalib_timer_test_app COMMAND staging_vespalib_timer_test_app) diff --git a/staging_vespalib/src/tests/timer/timer_test.cpp b/searchcore/src/tests/proton/common/timer/timer_test.cpp index 1f0ee81e4e6..9eea67623b6 100644 --- a/staging_vespalib/src/tests/timer/timer_test.cpp +++ b/searchcore/src/tests/proton/common/timer/timer_test.cpp @@ -1,12 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/vespalib/util/scheduledexecutor.h> +#include <vespa/searchcore/proton/common/scheduledexecutor.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/fnet/transport.h> #include <vespa/fastos/thread.h> -using namespace vespalib; using vespalib::Executor; typedef Executor::Task Task; @@ -28,7 +27,7 @@ TEST("testScheduling") { FastOS_ThreadPool threadPool(64_Ki); FNET_Transport transport; transport.Start(&threadPool); - ScheduledExecutor timer(transport); + proton::ScheduledExecutor timer(transport); timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch1), 100ms, 200ms); timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch2), 500ms, 500ms); EXPECT_TRUE(latch1.await(60s)); @@ -42,7 +41,7 @@ TEST("testReset") { FastOS_ThreadPool threadPool(64_Ki); FNET_Transport transport; transport.Start(&threadPool); - ScheduledExecutor timer(transport); + proton::ScheduledExecutor timer(transport); timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch1), 2s, 3s); timer.reset(); EXPECT_TRUE(!latch1.await(3s)); diff --git a/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt index 3f33871a0e2..25e9a469f93 100644 --- a/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt @@ -25,6 +25,7 @@ vespa_add_library(searchcore_pcommon STATIC selectpruner.cpp state_reporter_utils.cpp statusreport.cpp + scheduledexecutor.cpp DEPENDS searchcore_proton_metrics searchcore_fconfig diff --git a/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp b/searchcore/src/vespa/searchcore/proton/common/scheduledexecutor.cpp index 99254240f3c..4577477fb77 100644 --- a/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/scheduledexecutor.cpp @@ -4,7 +4,9 @@ #include <vespa/fnet/task.h> #include <vespa/fnet/transport.h> -namespace vespalib { +using vespalib::duration; + +namespace proton { using Task = vespalib::Executor::Task; @@ -30,7 +32,7 @@ public: void PerformTask() override { _task->run(); - Schedule(to_s(_interval)); + Schedule(vespalib::to_s(_interval)); } }; @@ -52,7 +54,7 @@ ScheduledExecutor::scheduleAtFixedRate(vespalib::Executor::Task::UP task, durati std::lock_guard guard(_lock); auto tTask = std::make_unique<TimerTask>(_transport.GetScheduler(), std::move(task), interval); _taskList.push_back(std::move(tTask)); - _taskList.back()->Schedule(to_s(delay)); + _taskList.back()->Schedule(vespalib::to_s(delay)); } void diff --git a/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.h b/searchcore/src/vespa/searchcore/proton/common/scheduledexecutor.h index 2c29ff52432..80c8b7edd15 100644 --- a/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.h +++ b/searchcore/src/vespa/searchcore/proton/common/scheduledexecutor.h @@ -8,7 +8,7 @@ class FNET_Transport; -namespace vespalib { +namespace proton { class TimerTask; @@ -21,9 +21,11 @@ class ScheduledExecutor { private: using TaskList = std::vector<std::unique_ptr<TimerTask>>; + using duration = vespalib::duration; + using Executor = vespalib::Executor; FNET_Transport & _transport; - std::mutex _lock; - TaskList _taskList; + std::mutex _lock; + TaskList _taskList; public: /** 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 6030fb3cceb..401de2e34a8 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 @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "disk_mem_usage_sampler.h" -#include <vespa/vespalib/util/scheduledexecutor.h> +#include <vespa/searchcore/proton/common/scheduledexecutor.h> #include <vespa/vespalib/util/lambdatask.h> #include <vespa/searchcore/proton/common/i_transient_resource_usage_provider.h> #include <filesystem> @@ -15,7 +15,7 @@ DiskMemUsageSampler::DiskMemUsageSampler(FNET_Transport & transport, const std:: _path(path_in), _sampleInterval(60s), _lastSampleTime(vespalib::steady_clock::now()), - _periodicTimer(std::make_unique<vespalib::ScheduledExecutor>(transport)), + _periodicTimer(std::make_unique<ScheduledExecutor>(transport)), _lock(), _transient_usage_providers() { 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 fa8ac48fa1f..b6ff46bc714 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 @@ -7,11 +7,10 @@ class FNET_Transport; -namespace vespalib { class ScheduledExecutor; } - namespace proton { class ITransientResourceUsageProvider; +class ScheduledExecutor; /* * Class to sample disk and memory usage used for filtering write operations. @@ -21,7 +20,7 @@ class DiskMemUsageSampler { std::filesystem::path _path; vespalib::duration _sampleInterval; vespalib::steady_time _lastSampleTime; - std::unique_ptr<vespalib::ScheduledExecutor> _periodicTimer; + std::unique_ptr<ScheduledExecutor> _periodicTimer; std::mutex _lock; std::vector<std::shared_ptr<const ITransientResourceUsageProvider>> _transient_usage_providers; diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp index 0df211b5a0b..5ca47d4d800 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp @@ -5,8 +5,8 @@ #include "document_db_maintenance_config.h" #include "i_blockable_maintenance_job.h" #include <vespa/searchcorespi/index/i_thread_service.h> +#include <vespa/searchcore/proton/common/scheduledexecutor.h> #include <vespa/vespalib/util/lambdatask.h> -#include <vespa/vespalib/util/scheduledexecutor.h> #include <vespa/fastos/thread.h> #include <thread> @@ -51,7 +51,7 @@ MaintenanceController::MaintenanceController(FNET_Transport & transport, _readySubDB(), _remSubDB(), _notReadySubDB(), - _periodicTimer(std::make_unique<vespalib::ScheduledExecutor>(transport)), + _periodicTimer(std::make_unique<ScheduledExecutor>(transport)), _config(), _state(State::INITIALIZING), _docTypeName(docTypeName), diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h index 8e5bb8d860c..763225045b2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h @@ -6,9 +6,9 @@ #include "i_maintenance_job.h" #include <vespa/searchcore/proton/common/doctypename.h> #include <vespa/vespalib/util/retain_guard.h> -#include <vespa/vespalib/util/scheduledexecutor.h> #include <mutex> +class FNET_Transport; namespace vespalib { @@ -26,6 +26,7 @@ namespace proton { class MaintenanceJobRunner; class DocumentDBMaintenanceConfig; +class ScheduledExecutor; /** * Class that controls the bucket moving between ready and notready sub databases @@ -88,7 +89,7 @@ private: MaintenanceDocumentSubDB _readySubDB; MaintenanceDocumentSubDB _remSubDB; MaintenanceDocumentSubDB _notReadySubDB; - std::unique_ptr<vespalib::ScheduledExecutor> _periodicTimer; + std::unique_ptr<ScheduledExecutor> _periodicTimer; DocumentDBMaintenanceConfigSP _config; State _state; const DocTypeName &_docTypeName; diff --git a/staging_vespalib/CMakeLists.txt b/staging_vespalib/CMakeLists.txt index ff152bcc2a1..04ad5f85b74 100644 --- a/staging_vespalib/CMakeLists.txt +++ b/staging_vespalib/CMakeLists.txt @@ -9,7 +9,6 @@ vespa_define_module( fastos vespalog vespalib - fnet TESTS src/tests/array @@ -36,7 +35,6 @@ vespa_define_module( src/tests/stllike src/tests/sequencedtaskexecutor src/tests/singleexecutor - src/tests/timer ${STAGING_VESPALIB_PROCESS_MEMORY_STATS_TESTDIR} src/tests/xmlserializable diff --git a/staging_vespalib/src/vespa/vespalib/util/CMakeLists.txt b/staging_vespalib/src/vespa/vespalib/util/CMakeLists.txt index 2912ac2397b..0bdfed505d3 100644 --- a/staging_vespalib/src/vespa/vespalib/util/CMakeLists.txt +++ b/staging_vespalib/src/vespa/vespalib/util/CMakeLists.txt @@ -21,7 +21,6 @@ vespa_add_library(staging_vespalib_vespalib_util OBJECT sequencedtaskexecutor.cpp sequencedtaskexecutorobserver.cpp shutdownguard.cpp - scheduledexecutor.cpp singleexecutor.cpp testclock.cpp xmlserializable.cpp |