diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-19 23:22:55 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-20 21:55:01 +0000 |
commit | cf3b20dba22718b533eac6854cde86b6538958af (patch) | |
tree | 9a0e795cd74d2721140c48012f794298dfef7420 /searchcore | |
parent | 64b7c822099d7cda921699e380c4d95608a1ab00 (diff) |
FastOS_Time -> std::chrono.
Diffstat (limited to 'searchcore')
17 files changed, 40 insertions, 48 deletions
diff --git a/searchcore/src/apps/proton/proton.cpp b/searchcore/src/apps/proton/proton.cpp index 7d63d8910ba..a805506b381 100644 --- a/searchcore/src/apps/proton/proton.cpp +++ b/searchcore/src/apps/proton/proton.cpp @@ -27,7 +27,7 @@ struct Params ~Params(); }; -Params::~Params() {} +Params::~Params() = default; class App : public FastOS_Application { @@ -174,7 +174,7 @@ App::Main() std::unique_ptr<search::StateFile> stateFile; std::unique_ptr<search::SigBusHandler> sigBusHandler; std::unique_ptr<search::IOErrorHandler> ioErrorHandler; - protonUP = std::make_unique<proton::Proton>(params.identity, _argc > 0 ? _argv[0] : "proton", params.subscribeTimeout); + protonUP = std::make_unique<proton::Proton>(params.identity, _argc > 0 ? _argv[0] : "proton", std::chrono::milliseconds(params.subscribeTimeout)); proton::Proton & proton = *protonUP; proton::BootstrapConfig::SP configSnapshot = proton.init(); if (proton.hasAbortedInit()) { @@ -220,7 +220,7 @@ App::Main() std::unique_ptr<ProtonServiceLayerProcess> spiProton; if ( ! params.serviceidentity.empty()) { spiProton.reset(new ProtonServiceLayerProcess(params.serviceidentity, proton, downPersistence.get())); - spiProton->setupConfig(params.subscribeTimeout); + spiProton->setupConfig(std::chrono::milliseconds(params.subscribeTimeout)); spiProton->createNode(); EV_STARTED("servicelayer"); } diff --git a/searchcore/src/apps/tests/persistenceconformance_test.cpp b/searchcore/src/apps/tests/persistenceconformance_test.cpp index 98ed9e3c4f3..ba0d2047b88 100644 --- a/searchcore/src/apps/tests/persistenceconformance_test.cpp +++ b/searchcore/src/apps/tests/persistenceconformance_test.cpp @@ -42,6 +42,7 @@ using namespace cloud::config::filedistribution; using namespace vespa::config::search::core; using namespace vespa::config::search::summary; using namespace vespa::config::search; +using namespace std::chrono_literals; using vespa::config::content::core::BucketspacesConfig; using std::shared_ptr; @@ -189,7 +190,7 @@ public: std::make_shared<BucketspacesConfig>(), tuneFileDocDB, HwInfo())); mgr.forwardConfig(b); - mgr.nextGeneration(0); + mgr.nextGeneration(0ms); return DocumentDB::SP( new DocumentDB(_baseDir, mgr.getConfig(), diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp index 26abd6be914..7db4b6fc9dd 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp @@ -45,6 +45,7 @@ using namespace search::engine; using namespace search::index; using namespace search::transactionlog; using namespace search; +using namespace std::chrono_literals; using document::DocumenttypesConfig; using document::test::makeBucketSpace; @@ -210,7 +211,7 @@ public: std::make_shared<BucketspacesConfig>(), _tuneFileDocumentDB, _hwInfo); _configMgr.forwardConfig(b); - _configMgr.nextGeneration(0); + _configMgr.nextGeneration(0ms); if (! FastOS_File::MakeDirectory((std::string("tmpdb/") + docTypeName).c_str())) { LOG_ABORT("should not be reached"); } 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 76b6bf55534..c26bb975a7a 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 @@ -43,6 +43,7 @@ using namespace search::transactionlog; using namespace search; using namespace searchcorespi; using namespace vespalib; +using namespace std::chrono_literals; using document::test::makeBucketSpace; using proton::bucketdb::BucketDBHandler; @@ -278,7 +279,7 @@ struct MyConfigSnapshot config::DirSpec spec(cfgDir); DocumentDBConfigHelper mgr(spec, "searchdocument"); mgr.forwardConfig(_bootstrap); - mgr.nextGeneration(1); + mgr.nextGeneration(1ms); _cfg = mgr.getConfig(); } }; diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp index 2c9a2b300eb..4064fc24105 100644 --- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp @@ -6,7 +6,6 @@ #include <vespa/fastos/file.h> #include <vespa/document/test/make_bucket_space.h> #include <vespa/searchcore/proton/attribute/flushableattribute.h> -#include <vespa/searchcore/proton/common/feedtoken.h> #include <vespa/searchcore/proton/common/statusreport.h> #include <vespa/searchcore/proton/docsummary/summaryflushtarget.h> #include <vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.h> @@ -31,6 +30,7 @@ using namespace cloud::config::filedistribution; using namespace proton; using namespace vespalib::slime; +using namespace std::chrono_literals; using document::DocumentType; using document::DocumentTypeRepo; @@ -103,7 +103,7 @@ Fixture::Fixture() std::make_shared<BucketspacesConfig>(), tuneFileDocumentDB, HwInfo())); mgr.forwardConfig(b); - mgr.nextGeneration(0); + mgr.nextGeneration(0ms); _db.reset(new DocumentDB(".", mgr.getConfig(), "tcp/localhost:9014", _queryLimiter, _clock, DocTypeName("typea"), makeBucketSpace(), *b->getProtonConfigSP(), _myDBOwner, _summaryExecutor, _summaryExecutor, _tls, _dummy, diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp index 581db62fce5..d2d9f573326 100644 --- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp +++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp @@ -25,6 +25,7 @@ using namespace search::index; using namespace search; using namespace vespa::config::search::core; using namespace vespa::config::search; +using namespace std::chrono_literals; using vespa::config::content::core::BucketspacesConfig; using proton::matching::RankingConstants; @@ -48,10 +49,10 @@ makeBaseConfigSnapshot() std::make_shared<BucketspacesConfig>(), std::make_shared<TuneFileDocumentDB>(), HwInfo())); dbcm.forwardConfig(b); - dbcm.nextGeneration(0); + dbcm.nextGeneration(0ms); DocumentDBConfig::SP snap = dbcm.getConfig(); snap->setConfigId(myId); - ASSERT_TRUE(snap.get() != NULL); + ASSERT_TRUE(snap); return snap; } diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index e6df649af93..c732da58dd7 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -26,8 +26,6 @@ #include <vespa/searchcore/proton/test/disk_mem_usage_notifier.h> #include <vespa/searchcore/proton/test/mock_attribute_manager.h> #include <vespa/searchcore/proton/test/test.h> -#include <vespa/searchlib/attribute/attributecontext.h> -#include <vespa/searchlib/attribute/attributeguard.h> #include <vespa/searchlib/common/gatecallback.h> #include <vespa/searchlib/common/idocumentmetastore.h> #include <vespa/searchlib/index/docbuilder.h> @@ -70,8 +68,7 @@ typedef std::set<BucketId> BucketIdSet; constexpr int TIMEOUT_MS = 60000; constexpr double TIMEOUT_SEC = 60.0; -namespace -{ +namespace { void sampleThreadId(FastOS_ThreadId *threadId) @@ -806,12 +803,9 @@ MyExecutor::isIdle() bool MyExecutor::waitIdle(double timeout) { - FastOS_Time startTime; - startTime.SetNow(); + fastos::StopWatch timer; while (!isIdle()) { - FastOS_Time cTime; - cTime.SetNow(); - if (cTime.Secs() - startTime.Secs() >= timeout) + if (timer.elapsed().sec() >= timeout) return false; } return true; 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 fb80f6f55b4..d86a750794f 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 @@ -13,7 +13,7 @@ #include <vespa/fileacquirer/config-filedistributorrpc.h> #include <vespa/vespalib/util/varholder.h> #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/fastos/time.h> +#include <vespa/fastos/timestamp.h> #include <vespa/config-bucketspaces.h> #include <vespa/config-attributes.h> #include <vespa/config-imported-fields.h> @@ -29,6 +29,7 @@ using namespace vespa::config::search::core; using namespace vespa::config::search::summary; using namespace vespa::config::search; using namespace cloud::config::filedistribution; +using namespace std::chrono_literals; using vespa::config::content::core::BucketspacesConfig; using vespa::config::content::core::BucketspacesConfigBuilder; @@ -169,10 +170,9 @@ struct ProtonConfigOwner : public proton::IProtonConfigurer VarHolder<std::shared_ptr<ProtonConfigSnapshot>> _config; ProtonConfigOwner() : _configured(false), _config() { } - bool waitUntilConfigured(int timeout) { - FastOS_Time timer; - timer.SetNow(); - while (timer.MilliSecsToNow() < timeout) { + bool waitUntilConfigured(int64_t timeout) { + fastos::StopWatch timer; + while (timer.elapsed().ms() < timeout) { if (getConfigured()) return true; FastOS_Thread::Sleep(100); @@ -290,7 +290,7 @@ TEST_FF("require that documentdb config manager builds schema with imported attr TEST_FFF("require that proton config fetcher follows changes to bootstrap", ConfigTestFixture("search"), ProtonConfigOwner(), - ProtonConfigFetcher(ConfigUri(f1.configId, f1.context), f2, 60000)) { + ProtonConfigFetcher(ConfigUri(f1.configId, f1.context), f2, 60000ms)) { f3.start(); ASSERT_TRUE(f2._configured); ASSERT_TRUE(f1.configEqual(f2.getBootstrapConfig())); @@ -305,7 +305,7 @@ TEST_FFF("require that proton config fetcher follows changes to bootstrap", TEST_FFF("require that proton config fetcher follows changes to doctypes", ConfigTestFixture("search"), ProtonConfigOwner(), - ProtonConfigFetcher(ConfigUri(f1.configId, f1.context), f2, 60000)) { + ProtonConfigFetcher(ConfigUri(f1.configId, f1.context), f2, 60000ms)) { f3.start(); f2._configured = false; @@ -325,7 +325,7 @@ TEST_FFF("require that proton config fetcher follows changes to doctypes", TEST_FFF("require that proton config fetcher reconfigures dbowners", ConfigTestFixture("search"), ProtonConfigOwner(), - ProtonConfigFetcher(ConfigUri(f1.configId, f1.context), f2, 60000)) { + ProtonConfigFetcher(ConfigUri(f1.configId, f1.context), f2, 60000ms)) { f3.start(); ASSERT_FALSE(f2.getDocumentDBConfig("typea")); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h index 19f89466e39..24d922418b8 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h @@ -5,10 +5,9 @@ #include <vespa/vespalib/stllike/string.h> #include <vespa/searchlib/common/indexmetainfo.h> #include <vespa/searchlib/common/serialnum.h> -#include <memory> +#include <vespa/fastos/timestamp.h> #include <mutex> #include <condition_variable> -#include <vespa/fastos/time.h> namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp b/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp index 642d5a40ac7..ed5ce24143d 100644 --- a/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp @@ -1,9 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "hw_info_sampler.h" -#include <vespa/config/common/configholder.h> #include <vespa/config/config.h> -#include <vespa/config/file/filesource.h> #include <vespa/config/print/fileconfigwriter.h> #include <vespa/fastos/file.h> #include <vespa/searchcore/config/config-hwinfo.h> @@ -59,7 +57,7 @@ std::unique_ptr<HwinfoConfig> readConfig(const vespalib::string &path) { FileSpec spec(path + "/" + "hwinfo.cfg"); ConfigSubscriber s(spec); std::unique_ptr<ConfigHandle<HwinfoConfig>> handle = s.subscribe<HwinfoConfig>("hwinfo"); - s.nextConfig(0); + s.nextConfigNow(); return handle->getConfig(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp index ef31da34683..20d11c43a68 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp @@ -10,7 +10,6 @@ #include <vespa/config/file_acquirer/file_acquirer.h> #include <vespa/config/helper/legacy.h> #include <vespa/config-attributes.h> -#include <vespa/config-imported-fields.h> #include <vespa/config-indexschema.h> #include <vespa/config-summary.h> #include <vespa/searchcommon/common/schemaconfigurer.h> @@ -378,7 +377,7 @@ DocumentDBConfigHelper::DocumentDBConfigHelper(const DirSpec &spec, const vespal DocumentDBConfigHelper::~DocumentDBConfigHelper() = default; bool -DocumentDBConfigHelper::nextGeneration(int timeoutInMillis) +DocumentDBConfigHelper::nextGeneration(std::chrono::milliseconds timeoutInMillis) { ConfigSnapshot snapshot(_retriever->getBootstrapConfigs(timeoutInMillis)); if (snapshot.empty()) diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h index bd1cb66de43..c4dabe7e563 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h @@ -53,7 +53,7 @@ public: DocumentDBConfigHelper(const config::DirSpec &spec, const vespalib::string &docTypeName); ~DocumentDBConfigHelper(); - bool nextGeneration(int timeoutInMillis); + bool nextGeneration(std::chrono::milliseconds timeoutInMillis); DocumentDBConfig::SP getConfig() const; void forwardConfig(const std::shared_ptr<BootstrapConfig> & config); private: diff --git a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp index 748c02503f1..395eb5a0ea2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp @@ -42,6 +42,7 @@ using vespa::config::content::core::BucketspacesConfig; using vespalib::nbostream; typedef IndexMetaInfo::SnapshotList SnapshotList; +using namespace std::chrono_literals; namespace proton { @@ -381,7 +382,7 @@ FileConfigManager::loadConfig(const DocumentDBConfig ¤tSnapshot, bucketspaces,currentSnapshot.getTuneFileDocumentDBSP(), sampler.hwInfo()); dbc.forwardConfig(bootstrap); - dbc.nextGeneration(0); + dbc.nextGeneration(0ms); loadedSnapshot = dbc.getConfig(); loadedSnapshot->setConfigId(_configId); diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index a8f5cb32375..6e0a3991001 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -175,7 +175,7 @@ Proton::ProtonFileHeaderContext::setClusterName(const vespalib::string & cluster Proton::Proton(const config::ConfigUri & configUri, const vespalib::string &progName, - uint64_t subscribeTimeout) + std::chrono::milliseconds subscribeTimeout) : IProtonConfigurerOwner(), search::engine::MonitorServer(), IDocumentDBOwner(), @@ -221,12 +221,10 @@ Proton::Proton(const config::ConfigUri & configUri, _initStarted(false), _initComplete(false), _initDocumentDbsInSequence(false), - _documentDBReferenceRegistry(), + _documentDBReferenceRegistry(std::make_shared<DocumentDBReferenceRegistry>()), _nodeUpLock(), _nodeUp() -{ - _documentDBReferenceRegistry = std::make_shared<DocumentDBReferenceRegistry>(); -} +{ } BootstrapConfig::SP Proton::init() diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h index 487a596e7e6..410f45162e4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton.h @@ -155,7 +155,7 @@ public: Proton(const config::ConfigUri & configUri, const vespalib::string &progName, - uint64_t subscribeTimeout); + std::chrono::milliseconds subscribeTimeout); ~Proton() override; /** diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp index ff39ed89999..ef0185e60b3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp @@ -17,7 +17,7 @@ using namespace std::chrono_literals; namespace proton { -ProtonConfigFetcher::ProtonConfigFetcher(const config::ConfigUri & configUri, IProtonConfigurer &owner, uint64_t subscribeTimeout) +ProtonConfigFetcher::ProtonConfigFetcher(const config::ConfigUri & configUri, IProtonConfigurer &owner, std::chrono::milliseconds subscribeTimeout) : _bootstrapConfigManager(configUri.getConfigId()), _retriever(_bootstrapConfigManager.createConfigKeySet(), configUri.getContext(), subscribeTimeout), _owner(owner), @@ -111,7 +111,7 @@ ProtonConfigFetcher::fetchConfigs() LOG(debug, "Waiting for new config generation"); bool configured = false; while (!configured) { - ConfigSnapshot bootstrapSnapshot = _retriever.getBootstrapConfigs(5000); + ConfigSnapshot bootstrapSnapshot = _retriever.getBootstrapConfigs(5000ms); if (_retriever.isClosed()) return; LOG(debug, "Fetching snapshot"); @@ -162,7 +162,7 @@ void ProtonConfigFetcher::start() { fetchConfigs(); - if (_threadPool.NewThread(this, NULL) == NULL) { + if (_threadPool.NewThread(this, nullptr) == nullptr) { throw vespalib::IllegalStateException( "Failed starting thread for proton config fetcher"); } @@ -182,7 +182,6 @@ ProtonConfigFetcher::rememberDocumentTypeRepo(std::shared_ptr<const document::Do { // Ensure that previous document type repo is kept alive, and also // any document type repo that was current within last 10 minutes. - using namespace std::chrono_literals; if (repo == _currentDocumentTypeRepo) { return; // no change } diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h index 252d8e6dc0e..13582a6f96c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h @@ -27,8 +27,8 @@ class ProtonConfigFetcher : public FastOS_Runnable public: using BootstrapConfigSP = std::shared_ptr<BootstrapConfig>; - ProtonConfigFetcher(const config::ConfigUri & configUri, IProtonConfigurer &owner, uint64_t subscribeTimeout); - ~ProtonConfigFetcher(); + ProtonConfigFetcher(const config::ConfigUri & configUri, IProtonConfigurer &owner, std::chrono::milliseconds subscribeTimeout); + ~ProtonConfigFetcher() override; /** * Get the current config generation. */ |