From cf3b20dba22718b533eac6854cde86b6538958af Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Tue, 19 Nov 2019 23:22:55 +0000 Subject: FastOS_Time -> std::chrono. --- storageserver/src/apps/storaged/storage.cpp | 30 +++++++++++----------- storageserver/src/tests/storageservertest.cpp | 6 +++-- .../vespa/storageserver/app/distributorprocess.cpp | 11 +++----- .../vespa/storageserver/app/distributorprocess.h | 2 +- .../src/vespa/storageserver/app/process.cpp | 4 +-- .../src/vespa/storageserver/app/process.h | 7 ++--- 6 files changed, 30 insertions(+), 30 deletions(-) (limited to 'storageserver') diff --git a/storageserver/src/apps/storaged/storage.cpp b/storageserver/src/apps/storaged/storage.cpp index b1eafcbad93..0748cc3cb1e 100644 --- a/storageserver/src/apps/storaged/storage.cpp +++ b/storageserver/src/apps/storaged/storage.cpp @@ -11,21 +11,21 @@ * application, but as little as possible else. */ -#include +#include "forcelink.h" #include -#include #include -#include "forcelink.h" #include #include #include -#include #include #include +#include +#include #include LOG_SETUP("vds.application"); +using namespace std::chrono_literals; namespace storage { namespace { @@ -39,7 +39,7 @@ Process::UP createProcess(vespalib::stringref configId) { } else switch (serverConfig->persistenceProvider.type) { case vespa::config::content::core::StorServerConfig::PersistenceProvider::Type::STORAGE: case vespa::config::content::core::StorServerConfig::PersistenceProvider::Type::DUMMY: - return Process::UP(new DummyServiceLayerProcess(configId)); + return std::make_unique(configId); default: throw vespalib::IllegalStateException("Unknown persistence provider.", VESPA_STRLOC); } @@ -59,7 +59,7 @@ class StorageApp : public FastOS_Application, public: StorageApp(); - ~StorageApp(); + ~StorageApp() override; void handleSignal(int signal) { LOG(info, "Got signal %d, waiting for lock", signal); @@ -96,7 +96,7 @@ StorageApp::StorageApp() "abruptly killing the process."); } -StorageApp::~StorageApp() {} +StorageApp::~StorageApp() = default; bool StorageApp::Init() { @@ -118,13 +118,13 @@ bool StorageApp::Init() } namespace { - storage::StorageApp *sigtramp = 0; + storage::StorageApp *sigtramp = nullptr; uint32_t _G_signalCount = 0; void killHandler(int sig) { if (_G_signalCount == 0) { _G_signalCount++; - if (sigtramp == 0) _exit(EXIT_FAILURE); + if (sigtramp == nullptr) _exit(EXIT_FAILURE); // note: this is not totally safe, sigtramp is not protected by a lock sigtramp->handleSignal(sig); } else if (_G_signalCount > 2) { @@ -143,8 +143,8 @@ namespace { usr_action.sa_handler = killHandler; usr_action.sa_mask = block_mask; usr_action.sa_flags = 0; - sigaction (SIGTERM, &usr_action, NULL); - sigaction (SIGINT, &usr_action, NULL); + sigaction (SIGTERM, &usr_action, nullptr); + sigaction (SIGINT, &usr_action, nullptr); } } @@ -162,7 +162,7 @@ int StorageApp::Main() { try{ _process = createProcess(_configId); - _process->setupConfig(600000); + _process->setupConfig(600000ms); _process->createNode(); } catch (const spi::HandledException & e) { LOG(warning, "Died due to known cause: %s", e.what()); @@ -192,7 +192,7 @@ int StorageApp::Main() } // Wait until we get a kill signal. vespalib::MonitorGuard lock(_signalLock); - lock.wait(1000); + lock.wait(1000ms); handleSignals(); } LOG(debug, "Server was attempted stopped, shutting down"); @@ -200,7 +200,7 @@ int StorageApp::Main() // time than given timeout. vespalib::ShutdownGuard shutdownGuard(_maxShutdownTime); LOG(debug, "Attempting proper shutdown"); - _process.reset(0); + _process.reset(); LOG(debug, "Completed controlled shutdown."); return 0; } @@ -212,7 +212,7 @@ int main(int argc, char **argv) storage::StorageApp app; storage::sigtramp = &app; int retval = app.Entry(argc,argv); - storage::sigtramp = NULL; + storage::sigtramp = nullptr; LOG(debug, "Exiting"); return retval; } diff --git a/storageserver/src/tests/storageservertest.cpp b/storageserver/src/tests/storageservertest.cpp index 5e50fff8f94..2f165c69470 100644 --- a/storageserver/src/tests/storageservertest.cpp +++ b/storageserver/src/tests/storageservertest.cpp @@ -11,6 +11,8 @@ LOG_SETUP(".storageservertest"); +using namespace std::chrono_literals; + namespace storage { struct StorageServerTest : public ::testing::Test { @@ -61,7 +63,7 @@ struct Storage : public Node { Distributor::Distributor(vdstestlib::DirConfig& config) : _process(config.getConfigId()) { - _process.setupConfig(60000); + _process.setupConfig(60000ms); _process.createNode(); } @@ -70,7 +72,7 @@ Distributor::~Distributor() = default; Storage::Storage(vdstestlib::DirConfig& config) : _process(config.getConfigId()) { - _process.setupConfig(60000); + _process.setupConfig(60000ms); _process.createNode(); _component.reset(new StorageComponent( getContext().getComponentRegister(), "test")); diff --git a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp index ff4b2e98cca..938ca63b50f 100644 --- a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp +++ b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp @@ -28,7 +28,7 @@ DistributorProcess::shutdown() } void -DistributorProcess::setupConfig(uint64_t subscribeTimeout) +DistributorProcess::setupConfig(milliseconds subscribeTimeout) { using vespa::config::content::core::StorServerConfig; using vespa::config::content::core::StorDistributormanagerConfig; @@ -39,13 +39,10 @@ DistributorProcess::setupConfig(uint64_t subscribeTimeout) if (stor_config->persistenceProvider.type != StorServerConfig::PersistenceProvider::Type::STORAGE) { _activeFlag = DistributorNode::NEED_ACTIVE_BUCKET_STATES_SET; } - auto dist_config = config::ConfigGetter::getConfig( - _configUri.getConfigId(), _configUri.getContext(), subscribeTimeout); + auto dist_config = config::ConfigGetter::getConfig(_configUri.getConfigId(), _configUri.getContext(), subscribeTimeout); _use_btree_database = dist_config->useBtreeDatabase; - _distributorConfigHandler - = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); - _visitDispatcherConfigHandler - = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); + _distributorConfigHandler = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); + _visitDispatcherConfigHandler = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); Process::setupConfig(subscribeTimeout); } diff --git a/storageserver/src/vespa/storageserver/app/distributorprocess.h b/storageserver/src/vespa/storageserver/app/distributorprocess.h index 57193f77e42..48fa331ba54 100644 --- a/storageserver/src/vespa/storageserver/app/distributorprocess.h +++ b/storageserver/src/vespa/storageserver/app/distributorprocess.h @@ -27,7 +27,7 @@ public: ~DistributorProcess() override; void shutdown() override; - void setupConfig(uint64_t subscribeTimeout) override; + void setupConfig(milliseconds subscribeTimeout) override; void createNode() override; bool configUpdated() override; void updateConfig() override; diff --git a/storageserver/src/vespa/storageserver/app/process.cpp b/storageserver/src/vespa/storageserver/app/process.cpp index 0ebce27eebb..df5e8f4a10e 100644 --- a/storageserver/src/vespa/storageserver/app/process.cpp +++ b/storageserver/src/vespa/storageserver/app/process.cpp @@ -19,7 +19,7 @@ Process::Process(const config::ConfigUri & configUri) { } void -Process::setupConfig(uint64_t subscribeTimeout) +Process::setupConfig(milliseconds subscribeTimeout) { _documentHandler = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); if (!_configSubscriber.nextConfig()) { @@ -32,7 +32,7 @@ Process::setupConfig(uint64_t subscribeTimeout) bool Process::configUpdated() { - _configSubscriber.nextGeneration(0); + _configSubscriber.nextGenerationNow(); if (_documentHandler->isChanged()) { LOG(info, "Document config detected changed"); return true; diff --git a/storageserver/src/vespa/storageserver/app/process.h b/storageserver/src/vespa/storageserver/app/process.h index e8f7fd62ccf..a5c5b656677 100644 --- a/storageserver/src/vespa/storageserver/app/process.h +++ b/storageserver/src/vespa/storageserver/app/process.h @@ -38,12 +38,13 @@ private: std::vector _repos; public: - typedef std::unique_ptr UP; + using UP = std::unique_ptr; + using milliseconds = std::chrono::milliseconds; Process(const config::ConfigUri & configUri); virtual ~Process() {} - virtual void setupConfig(uint64_t subscribeTimeout); + virtual void setupConfig(milliseconds subscribeTimeout); virtual void createNode() = 0; virtual bool configUpdated(); virtual void updateConfig(); @@ -54,7 +55,7 @@ public: virtual StorageNode& getNode() = 0; virtual StorageNodeContext& getContext() = 0; - virtual int64_t getGeneration() const override; + int64_t getGeneration() const override; }; } // storage -- cgit v1.2.3