diff options
Diffstat (limited to 'searchcore')
10 files changed, 30 insertions, 28 deletions
diff --git a/searchcore/src/apps/proton/proton.cpp b/searchcore/src/apps/proton/proton.cpp index b37eb5ac0cf..f80558a1bc6 100644 --- a/searchcore/src/apps/proton/proton.cpp +++ b/searchcore/src/apps/proton/proton.cpp @@ -8,6 +8,7 @@ #include <vespa/metrics/metricmanager.h> #include <vespa/vespalib/util/signalhandler.h> #include <vespa/vespalib/util/programoptions.h> +#include <vespa/vespalib/util/time.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/config/common/exceptions.h> #include <vespa/fastos/app.h> @@ -198,7 +199,7 @@ App::Main() LOG(info, "Sleeping 900 seconds due to proton state"); int sleepLeft = 900; while (!(SIG::INT.check() || SIG::TERM.check()) && sleepLeft > 0) { - FastOS_Thread::Sleep(1000); + std::this_thread::sleep_for(1000ms); --sleepLeft; } EV_STOPPING("proton", "shutdown after stop on io errors"); @@ -226,7 +227,7 @@ App::Main() } EV_STARTED("proton"); while (!(SIG::INT.check() || SIG::TERM.check() || (spiProton && spiProton->getNode().attemptedStopped()))) { - FastOS_Thread::Sleep(1000); + std::this_thread::sleep_for(1000ms); if (spiProton && spiProton->configUpdated()) { storage::ResumeGuard guard(spiProton->getNode().pause()); spiProton->updateConfig(); @@ -240,7 +241,7 @@ App::Main() if (spiProton) { // report down state to cluster controller. spiProton->getNode().notifyPartitionDown(0, "proton state string is " + stateString); - FastOS_Thread::Sleep(1000); + std::this_thread::sleep_for(1000ms); } EV_STOPPING("proton", "shutdown after new stop on io errors"); return 1; diff --git a/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp b/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp index 3b3b5f412d2..dcd3dce218b 100644 --- a/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp +++ b/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp @@ -6,8 +6,10 @@ #include <vespa/fnet/frt/frt.h> #include <vespa/vespalib/util/host_name.h> #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/time.h> #include <vespa/fastos/app.h> #include <sys/time.h> +#include <thread> #include <vespa/log/log.h> LOG_SETUP("vespa-proton-cmd"); @@ -115,7 +117,7 @@ public: slobrok::api::MirrorAPI sbmirror(_frt->supervisor(), sbcfg); for (int timeout = 1; timeout < 20; timeout++) { if (!sbmirror.ready()) { - FastOS_Thread::Sleep(50*timeout); + std::this_thread::sleep_for(50ms*timeout); } } if (!sbmirror.ready()) { @@ -123,12 +125,9 @@ public: "ERROR: no data from service location broker\n"); exit(1); } - slobrok::api::MirrorAPI::SpecList specs = - sbmirror.lookup(rtcPattern); - slobrok::api::MirrorAPI::SpecList specs2 = - sbmirror.lookup(rtcPattern2); - slobrok::api::MirrorAPI::SpecList specs3 = - sbmirror.lookup(rtcPattern3); + slobrok::api::MirrorAPI::SpecList specs = sbmirror.lookup(rtcPattern); + slobrok::api::MirrorAPI::SpecList specs2 = sbmirror.lookup(rtcPattern2); + slobrok::api::MirrorAPI::SpecList specs3 = sbmirror.lookup(rtcPattern3); int found = 0; std::string service; @@ -167,7 +166,7 @@ public: slobrok::api::MirrorAPI sbmirror(_frt->supervisor(), sbcfg); for (int timeout = 1; timeout < 20; timeout++) { if (!sbmirror.ready()) { - FastOS_Thread::Sleep(50*timeout); + std::this_thread::sleep_for(50ms*timeout); } } if (!sbmirror.ready()) { diff --git a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp index f5aa74d85e1..5775c31b205 100644 --- a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp +++ b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp @@ -7,6 +7,7 @@ #include <vespa/searchlib/transactionlog/translogserver.h> #include <vespa/vespalib/util/programoptions.h> #include <vespa/vespalib/util/xmlstream.h> +#include <vespa/vespalib/util/time.h> #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/fieldvalue/document.h> @@ -14,6 +15,7 @@ #include <vespa/config/helper/configgetter.hpp> #include <vespa/fastos/app.h> #include <iostream> +#include <thread> #include <vespa/log/log.h> LOG_SETUP("vespa-transactionlog-inspect"); @@ -491,7 +493,7 @@ protected: return 1; } for (size_t i = 0; !callback.isEof() && (i < 60 * 60); i++ ) { - FastOS_Thread::Sleep(1000); + std::this_thread::sleep_for(1s); } return 0; } diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index fdd53d629ad..dfac2edad61 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -1064,7 +1064,7 @@ TEST_F("require that document pruner is active", MyFrozenBucket::UP frozen3(new MyFrozenBucket(f._mc, bucketId3)); f.setPruneConfig(DocumentDBPruneRemovedDocumentsConfig(0.2, 900.0)); for (uint32_t i = 0; i < 6; ++i) { - FastOS_Thread::Sleep(100); + std::this_thread::sleep_for(100ms); ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC)); if (f._removed.getNumUsedLids() != 10u) break; @@ -1073,7 +1073,7 @@ TEST_F("require that document pruner is active", EXPECT_EQUAL(10u, f._removed.getDocumentCount()); frozen3.reset(); for (uint32_t i = 0; i < 600; ++i) { - FastOS_Thread::Sleep(100); + std::this_thread::sleep_for(100ms); ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC)); if (f._removed.getNumUsedLids() != 10u) break; @@ -1089,7 +1089,7 @@ TEST_F("require that heartbeats are scheduled", f.startMaintenance(); f.setHeartBeatConfig(DocumentDBHeartBeatConfig(0.2)); for (uint32_t i = 0; i < 600; ++i) { - FastOS_Thread::Sleep(100); + std::this_thread::sleep_for(100ms); if (f._fh.getHeartBeats() != 0u) break; } @@ -1104,7 +1104,7 @@ TEST_F("require that periodic session prunings are scheduled", f.startMaintenance(); f.setGroupingSessionPruneInterval(0.2); for (uint32_t i = 0; i < 600; ++i) { - FastOS_Thread::Sleep(100); + std::this_thread::sleep_for(100ms); if (f._gsp.isInvoked) { break; } @@ -1233,7 +1233,7 @@ TEST_F("require that a blocked job is unblocked and executed after thaw bucket", EXPECT_FALSE(myJob2.isBlocked()); bool done1 = myJob1._latch.await(TIMEOUT_MS); EXPECT_TRUE(done1); - FastOS_Thread::Sleep(2000); + std::this_thread::sleep_for(2s); EXPECT_EQUAL(0u, myJob2._runCnt); } @@ -1245,7 +1245,7 @@ TEST_F("require that blocked jobs are not executed", MaintenanceControllerFixtur f._mc.registerJobInMasterThread(std::move(job)); f._injectDefaultJobs = false; f.startMaintenance(); - FastOS_Thread::Sleep(2000); + std::this_thread::sleep_for(2s); EXPECT_EQUAL(0u, myJob._runCnt); } diff --git a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp index bfd4450b1f2..c18d393b98f 100644 --- a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp +++ b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp @@ -685,7 +685,7 @@ assertThatHandlersInCurrentSet(FlushEngine & engine, const std::vector<const cha { FlushEngine::FlushMetaSet current1 = engine.getCurrentlyFlushingSet(); while ((current1.size() < targets.size()) || !asserCorrectHandlers(current1, targets)) { - FastOS_Thread::Sleep(1); + std::this_thread::sleep_for(1ms); current1 = engine.getCurrentlyFlushingSet(); } } 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 d86a750794f..870be2ab409 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 @@ -175,7 +175,7 @@ struct ProtonConfigOwner : public proton::IProtonConfigurer while (timer.elapsed().ms() < timeout) { if (getConfigured()) return true; - FastOS_Thread::Sleep(100); + std::this_thread::sleep_for(100ms); } return getConfigured(); } 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 37f1664841a..8a4cb1682a6 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,10 +1,9 @@ // Copyright 2017 Yahoo Holdings. 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/timer.h> +#include <vespa/vespalib/util/scheduledexecutor.h> #include <vespa/vespalib/util/lambdatask.h> #include <filesystem> -#include <unistd.h> using vespalib::makeLambdaTask; @@ -32,7 +31,7 @@ DiskMemUsageSampler::setConfig(const Config &config) _filter.setConfig(config.filterConfig); _sampleInterval = config.sampleInterval; sampleUsage(); - _periodicTimer = std::make_unique<vespalib::Timer>(); + _periodicTimer = std::make_unique<vespalib::ScheduledExecutor>(); _periodicTimer->scheduleAtFixedRate(makeLambdaTask([this]() { sampleUsage(); }), _sampleInterval, _sampleInterval); 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 5a439e69003..2ab13f2f48a 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 @@ -4,7 +4,7 @@ #include "disk_mem_usage_filter.h" -namespace vespalib { class Timer; } +namespace vespalib { class ScheduledExecutor; } namespace proton { @@ -15,7 +15,7 @@ class DiskMemUsageSampler { DiskMemUsageFilter _filter; std::filesystem::path _path; double _sampleInterval; - std::unique_ptr<vespalib::Timer> _periodicTimer; + std::unique_ptr<vespalib::ScheduledExecutor> _periodicTimer; void sampleUsage(); void sampleDiskUsage(); diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp index a2672cc7972..893748ae49e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp @@ -6,7 +6,7 @@ #include "i_blockable_maintenance_job.h" #include <vespa/searchcorespi/index/i_thread_service.h> #include <vespa/vespalib/util/closuretask.h> -#include <vespa/vespalib/util/timer.h> +#include <vespa/vespalib/util/scheduledexecutor.h> #include <vespa/log/log.h> LOG_SETUP(".proton.server.maintenancecontroller"); @@ -167,7 +167,7 @@ MaintenanceController::restart() if (!_started || _stopping || !_readySubDB.valid()) { return; } - _periodicTimer.reset(new vespalib::Timer()); + _periodicTimer = std::make_unique<vespalib::ScheduledExecutor>(); addJobsToPeriodicTimer(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h index 24c1c18959e..3cfdeba4d34 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h @@ -8,6 +8,7 @@ #include "ibucketfreezelistener.h" #include <vespa/searchcore/proton/common/doctypename.h> #include <mutex> +#include <vespa/vespalib/util/scheduledexecutor.h> namespace vespalib { class Timer; @@ -77,7 +78,7 @@ private: MaintenanceDocumentSubDB _readySubDB; MaintenanceDocumentSubDB _remSubDB; MaintenanceDocumentSubDB _notReadySubDB; - std::unique_ptr<vespalib::Timer> _periodicTimer; + std::unique_ptr<vespalib::ScheduledExecutor> _periodicTimer; DocumentDBMaintenanceConfigSP _config; FrozenBuckets _frozenBuckets; bool _started; |