From c2ea426c8d955ff40873db1e7d06c482ca662e75 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Tue, 10 Dec 2019 00:54:16 +0000 Subject: Drop timestamp.h --- config/src/tests/configfetcher/configfetcher.cpp | 1 - .../src/tests/configretriever/configretriever.cpp | 1 - config/src/tests/frt/frt.cpp | 1 - config/src/tests/subscriber/subscriber.cpp | 1 - config/src/tests/subscription/subscription.cpp | 1 - configd/src/apps/sentinel/config-handler.cpp | 73 ++++++---------------- configd/src/apps/sentinel/metrics.cpp | 7 +-- configd/src/apps/sentinel/metrics.h | 4 +- configd/src/apps/sentinel/service.cpp | 19 +++--- configd/src/apps/sentinel/service.h | 9 +-- fastos/src/vespa/fastos/CMakeLists.txt | 1 - fastos/src/vespa/fastos/timestamp.cpp | 14 ----- fastos/src/vespa/fastos/timestamp.h | 11 ---- logd/src/logd/config_subscriber.cpp | 8 +-- logd/src/logd/config_subscriber.h | 9 +-- logd/src/logd/watcher.cpp | 45 +++++++------ messagebus_test/src/tests/speed/cpp-client.cpp | 1 - metrics/src/vespa/metrics/metricmanager.cpp | 4 +- metrics/src/vespa/metrics/metricsnapshot.h | 1 + metrics/src/vespa/metrics/state_api_adapter.cpp | 3 +- .../src/vespa/searchcommon/common/schema.h | 1 - .../proton_config_fetcher_test.cpp | 1 - .../proton/attribute/attribute_directory.h | 1 - .../proton/flushengine/flush_engine_explorer.cpp | 1 - .../flushengine/shrink_lid_space_flush_target.cpp | 1 - .../proton/matching/session_manager_explorer.cpp | 1 - .../tests/transactionlogstress/translogstress.cpp | 1 - searchlib/src/vespa/searchlib/docstore/filechunk.h | 1 - .../src/vespa/searchlib/docstore/idatastore.h | 1 - searchlib/src/vespa/searchlib/engine/trace.cpp | 1 - .../searchlib/test/fakedata/fake_match_loop.cpp | 1 - .../tests/distributor/garbagecollectiontest.cpp | 2 +- .../src/tests/distributor/statecheckerstest.cpp | 8 +-- storage/src/vespa/storage/bucketdb/bucketinfo.h | 13 +--- .../storage/config/distributorconfiguration.cpp | 15 +++-- .../storage/config/distributorconfiguration.h | 56 +++-------------- .../src/vespa/storage/distributor/statechecker.cpp | 3 +- .../vespa/storage/distributor/statecheckers.cpp | 4 +- storage/src/vespa/storage/visiting/commandqueue.h | 1 - .../src/vespa/storageapi/buckets/bucketinfo.h | 6 +- vespalib/src/tests/executor/stress_test.cpp | 1 - .../simple_thread_bundle/threading_speed_test.cpp | 1 - .../summary-feature-benchmark.cpp | 1 - 43 files changed, 102 insertions(+), 234 deletions(-) delete mode 100644 fastos/src/vespa/fastos/timestamp.cpp delete mode 100644 fastos/src/vespa/fastos/timestamp.h diff --git a/config/src/tests/configfetcher/configfetcher.cpp b/config/src/tests/configfetcher/configfetcher.cpp index 4a2a9153f52..856b1198ce8 100644 --- a/config/src/tests/configfetcher/configfetcher.cpp +++ b/config/src/tests/configfetcher/configfetcher.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include "config-my.h" #include diff --git a/config/src/tests/configretriever/configretriever.cpp b/config/src/tests/configretriever/configretriever.cpp index 756ee815d56..d929e816740 100644 --- a/config/src/tests/configretriever/configretriever.cpp +++ b/config/src/tests/configretriever/configretriever.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include "config-bootstrap.h" #include "config-foo.h" #include "config-bar.h" diff --git a/config/src/tests/frt/frt.cpp b/config/src/tests/frt/frt.cpp index 1925b87d600..cf1ff9eca37 100644 --- a/config/src/tests/frt/frt.cpp +++ b/config/src/tests/frt/frt.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "config-my.h" #include "config-bar.h" diff --git a/config/src/tests/subscriber/subscriber.cpp b/config/src/tests/subscriber/subscriber.cpp index 0fbf0d4bee8..9d5aeddaf37 100644 --- a/config/src/tests/subscriber/subscriber.cpp +++ b/config/src/tests/subscriber/subscriber.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include "config-foo.h" #include "config-bar.h" #include "config-baz.h" diff --git a/config/src/tests/subscription/subscription.cpp b/config/src/tests/subscription/subscription.cpp index 90dc678ecb7..9583111a2f7 100644 --- a/config/src/tests/subscription/subscription.cpp +++ b/config/src/tests/subscription/subscription.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include using namespace config; diff --git a/configd/src/apps/sentinel/config-handler.cpp b/configd/src/apps/sentinel/config-handler.cpp index 3e7b9ef0ea0..d4600471904 100644 --- a/configd/src/apps/sentinel/config-handler.cpp +++ b/configd/src/apps/sentinel/config-handler.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -44,24 +43,22 @@ ConfigHandler::ConfigHandler() _startMetrics(), _stateApi() { - _startMetrics.startedTime = fastos::time(); + _startMetrics.startedTime = vespalib::steady_clock::now(); } ConfigHandler::~ConfigHandler() { terminateServices(false); - std::list::iterator it; - for (it = _outputConnections.begin(); it != _outputConnections.end(); ++it) - { - delete *it; + for (OutputConnection * conn : _outputConnections) { + delete conn; } } void ConfigHandler::terminateServices(bool catchable, bool printDebug) { - for (ServiceMap::iterator it(_services.begin()), mt(_services.end()); it != mt; it++) { - Service *service = it->second.get(); + for (const auto & entry : _services) { + Service *service = entry.second.get(); if (printDebug && service->isRunning()) { LOG(info, "%s: killing", service->name().c_str()); } @@ -77,34 +74,10 @@ ConfigHandler::terminate() // Give them 58 seconds to exit cleanly, then terminate(false) all // of them. terminateServices(true); - struct timeval endTime; - gettimeofday(&endTime, nullptr); - endTime.tv_sec += 58; - struct timeval tv = {0, 0}; - - while (tv.tv_sec >= 0 && doWork()) { - gettimeofday(&tv, nullptr); - tv.tv_sec = endTime.tv_sec - tv.tv_sec; - tv.tv_usec = endTime.tv_usec - tv.tv_usec; - - if (tv.tv_usec >= 1000000) { - tv.tv_usec -= 1000000; - tv.tv_sec += 1; - } else if (tv.tv_usec < 0) { - tv.tv_usec += 100000; - tv.tv_sec -= 1; - } - - if (tv.tv_sec < 0) { - break; - } - - if (tv.tv_sec > 0 || tv.tv_usec > 200000) { - // Never wait more than 200ms per select regardless - tv.tv_sec = 0; - tv.tv_usec = 200000; - } + vespalib::steady_time endTime = vespalib::steady_clock::now() + 58s; + while ((vespalib::steady_clock::now() < endTime) && doWork()) { + struct timeval tv {0, 200000}; // Any child exiting will send SIGCHLD and break this select so // we handle the children exiting even quicker.. select(0, nullptr, nullptr, nullptr, &tv); @@ -112,8 +85,7 @@ ConfigHandler::terminate() for (int retry = 0; retry < 10 && doWork(); ++retry) { LOG(warning, "some services refuse to terminate cleanly, sending KILL"); terminateServices(false, true); - tv.tv_sec = 0; - tv.tv_usec = 200000; + struct timeval tv {0, 200000}; select(0, nullptr, nullptr, nullptr, &tv); } return !doWork(); @@ -146,9 +118,9 @@ ConfigHandler::doConfigure() for (unsigned int i = 0; i < config.service.size(); ++i) { const SentinelConfig::Service& serviceConfig = config.service[i]; const vespalib::string name(serviceConfig.name); - ServiceMap::iterator found(_services.find(name)); + auto found(_services.find(name)); if (found == _services.end()) { - services[name] = Service::UP(new Service(serviceConfig, config.application, _outputConnections, _startMetrics)); + services[name] = std::make_unique(serviceConfig, config.application, _outputConnections, _startMetrics); } else { found->second->reconfigure(serviceConfig); services[name] = std::move(found->second); @@ -182,8 +154,8 @@ ConfigHandler::doWork() _startMetrics.maybeLog(); // Check for active services. - for (ServiceMap::iterator it(_services.begin()), mt(_services.end()); it != mt; it++) { - if (it->second->isRunning()) { + for (const auto & service : _services) { + if (service.second->isRunning()) { return true; } } @@ -227,12 +199,8 @@ ConfigHandler::handleChildDeaths() void ConfigHandler::updateActiveFdset(fd_set *fds, int *maxNum) { - std::list::const_iterator - src = _outputConnections.begin(); // ### _Possibly put an assert here if fd is > 1023??? - while (src != _outputConnections.end()) { - OutputConnection *c = *src; - ++src; + for (OutputConnection *c : _outputConnections) { int fd = c->fd(); if (fd >= 0) { FD_SET(fd, fds); @@ -280,10 +248,9 @@ ConfigHandler::handleCommands() Service * ConfigHandler::serviceByPid(pid_t pid) { - for (ServiceMap::iterator it(_services.begin()), mt(_services.end()); it != mt; it++) { - Service *service = it->second.get(); - if (service->pid() == pid) { - return service; + for (const auto & service : _services) { + if (service.second->pid() == pid) { + return service.second.get(); } } for (const auto & it : _orphans) { @@ -298,7 +265,7 @@ ConfigHandler::serviceByPid(pid_t pid) Service * ConfigHandler::serviceByName(const vespalib::string & name) { - ServiceMap::iterator found(_services.find(name)); + auto found(_services.find(name)); if (found != _services.end()) { return found->second.get(); } @@ -316,8 +283,8 @@ ConfigHandler::handleCmd(const Cmd& cmd) size_t left = 65536; size_t pos = 0; retbuf[pos] = 0; - for (ServiceMap::iterator it(_services.begin()), mt(_services.end()); it != mt; it++) { - Service *service = it->second.get(); + for (const auto & entry : _services) { + const Service *service = entry.second.get(); const SentinelConfig::Service& config = service->serviceConfig(); int sz = snprintf(retbuf + pos, left, "%s state=%s mode=%s pid=%d exitstatus=%d id=\"%s\"\n", diff --git a/configd/src/apps/sentinel/metrics.cpp b/configd/src/apps/sentinel/metrics.cpp index bb10c94ae12..ed31e7a4d80 100644 --- a/configd/src/apps/sentinel/metrics.cpp +++ b/configd/src/apps/sentinel/metrics.cpp @@ -2,7 +2,6 @@ #include "metrics.h" #include -#include namespace config::sentinel { @@ -14,7 +13,7 @@ StartMetrics::StartMetrics() producer(metrics), currentlyRunningServices(0), totalRestartsCounter(0), - startedTime(fastos::time()), + startedTime(vespalib::steady_clock::now()), sentinel_restarts(metrics->counter("sentinel.restarts", "how many times sentinel restarted a service")), sentinel_totalRestarts(metrics->gauge("sentinel.totalRestarts", @@ -33,10 +32,10 @@ StartMetrics::~StartMetrics() = default; void StartMetrics::maybeLog() { - uint32_t curTime = fastos::time(); + vespalib::steady_time curTime = vespalib::steady_clock::now(); sentinel_totalRestarts.sample(totalRestartsCounter); sentinel_running.sample(currentlyRunningServices); - sentinel_uptime.sample(curTime - startedTime); + sentinel_uptime.sample(vespalib::to_s(curTime - startedTime)); } } diff --git a/configd/src/apps/sentinel/metrics.h b/configd/src/apps/sentinel/metrics.h index 2263d70fb60..365b7cc2ecf 100644 --- a/configd/src/apps/sentinel/metrics.h +++ b/configd/src/apps/sentinel/metrics.h @@ -1,8 +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 #include +#include namespace config::sentinel { @@ -15,7 +15,7 @@ struct StartMetrics { vespalib::metrics::Producer producer; unsigned long currentlyRunningServices; unsigned long totalRestartsCounter; - long startedTime; + vespalib::steady_time startedTime; Counter sentinel_restarts; Gauge sentinel_totalRestarts; Gauge sentinel_running; diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp index 22f9681a2ff..9f4196a2457 100644 --- a/configd/src/apps/sentinel/service.cpp +++ b/configd/src/apps/sentinel/service.cpp @@ -4,7 +4,6 @@ #include "output-connection.h" #include #include -#include #include #include @@ -44,7 +43,7 @@ Service::Service(const SentinelConfig::Service& service, const SentinelConfig::A _config(new SentinelConfig::Service(service)), _isAutomatic(true), _restartPenalty(0), - _last_start(0), + _last_start(vespalib::steady_time::min()), _application(application), _outputConnections(ocs), _metrics(metrics) @@ -157,8 +156,7 @@ Service::start() LOG(warning, "tried to start '%s' in REMOVING state", name().c_str()); return; } - time_t now = fastos::time(); - _last_start = now; + _last_start = vespalib::steady_clock::now(); // make a pipe, close the good ends of it, mark it close-on-exec // if exec fails, write a complaint on the fd (which will then be read @@ -323,8 +321,8 @@ Service::youExited(int status) if (! expectedDeath) { // make sure the service does not restart in a tight loop: - time_t now = fastos::time(); - unsigned int diff = now - _last_start; + vespalib::steady_time now = vespalib::steady_clock::now(); + vespalib::duration diff = now - _last_start; if (diff < MAX_RESTART_PENALTY) { incrementRestartPenalty(); } @@ -332,7 +330,7 @@ Service::youExited(int status) resetRestartPenalty(); } if (diff < _restartPenalty) { - LOG(info, "%s: will delay start by %u seconds", name().c_str(), _restartPenalty - diff); + LOG(info, "%s: will delay start by %2.3f seconds", name().c_str(), vespalib::to_s(_restartPenalty - diff)); } } if (_isAutomatic && !stop()) { @@ -421,8 +419,7 @@ bool Service::wantsRestart() const { if (_state == RESTARTING) { - time_t now = fastos::time(); - if (now > _last_start + _restartPenalty) { + if (vespalib::steady_clock::now() > _last_start + _restartPenalty) { return true; } } @@ -441,12 +438,12 @@ Service::setAutomatic(bool autoStatus) void Service::incrementRestartPenalty() { - _restartPenalty += 1; + _restartPenalty += 1s; _restartPenalty *= 2; if (_restartPenalty > MAX_RESTART_PENALTY) { _restartPenalty = MAX_RESTART_PENALTY; } - LOG(info, "%s: incremented restart penalty to %u seconds", name().c_str(), _restartPenalty); + LOG(info, "%s: incremented restart penalty to %2.3f seconds", name().c_str(), vespalib::to_s(_restartPenalty)); } diff --git a/configd/src/apps/sentinel/service.h b/configd/src/apps/sentinel/service.h index 5a188f217ff..7b7321fb5c6 100644 --- a/configd/src/apps/sentinel/service.h +++ b/configd/src/apps/sentinel/service.h @@ -3,6 +3,7 @@ #include "metrics.h" #include +#include #include #include @@ -27,9 +28,9 @@ private: SentinelConfig::Service *_config; bool _isAutomatic; - static const unsigned int MAX_RESTART_PENALTY = 1800; - unsigned int _restartPenalty; - time_t _last_start; + static constexpr vespalib::duration MAX_RESTART_PENALTY = 1800s; + vespalib::duration _restartPenalty; + vespalib::steady_time _last_start; void runChild(int pipes[2]) __attribute__((noreturn)); void ensureChildRuns(int fd); @@ -67,7 +68,7 @@ public: const SentinelConfig::Service& serviceConfig() const { return *_config; } void setAutomatic(bool autoStatus); bool isAutomatic() const { return _isAutomatic; } - void resetRestartPenalty() { _restartPenalty = 0; } + void resetRestartPenalty() { _restartPenalty = vespalib::duration::zero(); } void incrementRestartPenalty(); }; diff --git a/fastos/src/vespa/fastos/CMakeLists.txt b/fastos/src/vespa/fastos/CMakeLists.txt index fb5e7b2901e..1437f5c55f3 100644 --- a/fastos/src/vespa/fastos/CMakeLists.txt +++ b/fastos/src/vespa/fastos/CMakeLists.txt @@ -7,7 +7,6 @@ vespa_add_library(fastos_objects OBJECT linux_file.cpp process.cpp thread.cpp - timestamp.cpp unix_app.cpp unix_dynamiclibrary.cpp unix_file.cpp diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp deleted file mode 100644 index 5268453901d..00000000000 --- a/fastos/src/vespa/fastos/timestamp.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "timestamp.h" -#include - -using std::chrono::system_clock; - -namespace fastos { - -time_t -time() { - return system_clock::to_time_t(system_clock::now()); -} - -} diff --git a/fastos/src/vespa/fastos/timestamp.h b/fastos/src/vespa/fastos/timestamp.h deleted file mode 100644 index e050fe1bcbb..00000000000 --- a/fastos/src/vespa/fastos/timestamp.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include - -namespace fastos { - -time_t time(); - -} - diff --git a/logd/src/logd/config_subscriber.cpp b/logd/src/logd/config_subscriber.cpp index 1e6c9a040d3..3a6af0c54e4 100644 --- a/logd/src/logd/config_subscriber.cpp +++ b/logd/src/logd/config_subscriber.cpp @@ -50,7 +50,7 @@ ConfigSubscriber::configure(std::unique_ptr cfg) LOG(config, "bad rotate.size=%d must be positive", newconf.rotate.size); } if (newconf.rotate.age > 0) { - _rotate_age = newconf.rotate.age; + _rotate_age = std::chrono::seconds(newconf.rotate.age); } else { LOG(config, "bad rotate.age=%d must be positive", newconf.rotate.age); } @@ -60,7 +60,7 @@ ConfigSubscriber::configure(std::unique_ptr cfg) LOG(config, "bad remove.totalmegabytes=%d must be positive", newconf.remove.totalmegabytes); } if (newconf.remove.age > 0) { - _remove_age = newconf.remove.age; + _remove_age = std::chrono::hours(newconf.remove.age * 24); } else { LOG(config, "bad remove.age=%d must be positive", newconf.remove.age); } @@ -90,9 +90,9 @@ ConfigSubscriber::ConfigSubscriber(const config::ConfigUri& configUri) _state_port(0), _forward_filter(), _rotate_size(INT_MAX), - _rotate_age(INT_MAX), + _rotate_age(vespalib::duration::max()), _remove_meg(INT_MAX), - _remove_age(3650), + _remove_age(std::chrono::hours(30*24)), _use_logserver(true), _subscriber(configUri.getContext()), _handle(), diff --git a/logd/src/logd/config_subscriber.h b/logd/src/logd/config_subscriber.h index 507952319d6..fcda0ac1e11 100644 --- a/logd/src/logd/config_subscriber.h +++ b/logd/src/logd/config_subscriber.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace logdemon { @@ -20,9 +21,9 @@ private: int _state_port; ForwardMap _forward_filter; int _rotate_size; - int _rotate_age; + vespalib::duration _rotate_age; int _remove_meg; - int _remove_age; + vespalib::duration _remove_age; bool _use_logserver; config::ConfigSubscriber _subscriber; config::ConfigHandle::UP _handle; @@ -39,9 +40,9 @@ public: int getStatePort() const { return _state_port; } int getRotateSize() const { return _rotate_size; } - int getRotateAge() const { return _rotate_age; } + vespalib::duration getRotateAge() const { return _rotate_age; } int getRemoveMegabytes() const { return _remove_meg; } - int getRemoveAge() const { return _remove_age; } + vespalib::duration getRemoveAge() const { return _remove_age; } bool need_new_forwarder() const { return _need_new_forwarder; } std::unique_ptr make_forwarder(Metrics& metrics); diff --git a/logd/src/logd/watcher.cpp b/logd/src/logd/watcher.cpp index 2bb8973f052..00cfb4def16 100644 --- a/logd/src/logd/watcher.cpp +++ b/logd/src/logd/watcher.cpp @@ -4,15 +4,15 @@ #include "exceptions.h" #include "forwarder.h" #include "watcher.h" -#include #include -#include +#include #include #include #include #include #include +#include LOG_SETUP(""); namespace logdemon { @@ -164,7 +164,7 @@ Watcher::watchfile() vespalib::SigCatch catcher; int sleepcount = 0; - time_t created = 0; + vespalib::system_time created = vespalib::system_time::min(); again: // XXX should close and/or check _wfd first ? @@ -175,7 +175,7 @@ Watcher::watchfile() } bool rotate = false; - struct timeval rotStart; + vespalib::Timer rotTimer; off_t offset = 0; while (1) { @@ -184,8 +184,8 @@ Watcher::watchfile() LOG(error, "fstat(%s) failed: %s", filename, strerror(errno)); throw SomethingBad("fstat failed"); } - if (created == 0) { - created = sb.st_ctime; + if (created == vespalib::system_time::min()) { + created = vespalib::system_time(std::chrono::seconds(sb.st_ctime)); } if (already.valid) { if (sb.st_dev == already.st_dev && @@ -237,19 +237,19 @@ Watcher::watchfile() already.st_dev = sb.st_dev; already.st_ino = sb.st_ino; - time_t now = fastos::time(); + vespalib::system_time now = vespalib::system_clock::now(); bool wantrotate = (now > created + _confsubscriber.getRotateAge()) || (sb.st_size > _confsubscriber.getRotateSize()); if (rotate) { - int rotTime = elapsed(rotStart); - if (rotTime > 59 || (sb.st_size == offset && rotTime > 4)) { + vespalib::duration rotTime = rotTimer.elapsed(); + if (rotTime > 59s || (sb.st_size == offset && rotTime > 4s)) { removeOldLogs(filename); if (sb.st_size != offset) { - LOG(warning, "logfile rotation incomplete after %d s (dropping %" PRIu64 " bytes)", - rotTime, static_cast(sb.st_size - offset)); + LOG(warning, "logfile rotation incomplete after %2.3f s (dropping %" PRIu64 " bytes)", + vespalib::to_s(rotTime), static_cast(sb.st_size - offset)); } else { - LOG(debug, "logfile rotation complete after %d s", rotTime); + LOG(debug, "logfile rotation complete after %2.3f s", vespalib::to_s(rotTime)); } created = now; rotate = false; @@ -266,13 +266,14 @@ Watcher::watchfile() goto again; } else if (wantrotate) { rotate = true; - gettimeofday(&rotStart, 0); - LOG(debug, "preparing to rotate logfile, old logfile size %d, age %d seconds", - (int)offset, (int)(now-created)); + rotTimer = vespalib::Timer(); + LOG(debug, "preparing to rotate logfile, old logfile size %d, age %2.3f seconds", + (int)offset, vespalib::to_s(now-created)); char newfn[FILENAME_MAX]; int l = strlen(filename); strcpy(newfn, filename); - struct tm *nowtm = gmtime(&now); + time_t seconds = vespalib::to_s(now.time_since_epoch()); + struct tm *nowtm = gmtime(&seconds); if (strftime(newfn+l, FILENAME_MAX-l-1, "-%Y-%m-%d.%H-%M-%S", nowtm) < 10) { LOG(error, "could not strftime"); @@ -351,15 +352,13 @@ Watcher::removeOldLogs(const char *prefix) continue; } if (S_ISREG(sb.st_mode)) { - if (sb.st_mtime + - _confsubscriber.getRemoveAge() * 86400 < fastos::time()) - { - LOG(info, "removing %s, too old (%f days)", fname, - (double)(fastos::time()-sb.st_mtime)/86400.0); + vespalib::system_time mtime = vespalib::system_time(std::chrono::seconds(sb.st_mtime)); + vespalib::system_time now = vespalib::system_clock::now(); + if ((mtime + _confsubscriber.getRemoveAge()) < now) { + LOG(info, "removing %s, too old (%f days)", fname, vespalib::to_s(now - mtime)/86400.0); if (unlink(fname) != 0) { - LOG(warning, "cannot remove %s: %s", - fname, strerror(errno)); + LOG(warning, "cannot remove %s: %s", fname, strerror(errno)); } continue; } diff --git a/messagebus_test/src/tests/speed/cpp-client.cpp b/messagebus_test/src/tests/speed/cpp-client.cpp index db0dd4b23ae..b5829c76c08 100644 --- a/messagebus_test/src/tests/speed/cpp-client.cpp +++ b/messagebus_test/src/tests/speed/cpp-client.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include using namespace mbus; diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp index 74842801909..41c8b52d731 100644 --- a/metrics/src/vespa/metrics/metricmanager.cpp +++ b/metrics/src/vespa/metrics/metricmanager.cpp @@ -8,9 +8,9 @@ #include #include #include +#include #include #include -#include #include #include @@ -26,7 +26,7 @@ MetricManager::ConsumerSpec::~ConsumerSpec() = default; time_t MetricManager::Timer::getTime() const { - return fastos::time(); + return vespalib::to_s(vespalib::steady_clock::now().time_since_epoch()); } void diff --git a/metrics/src/vespa/metrics/metricsnapshot.h b/metrics/src/vespa/metrics/metricsnapshot.h index b00c001505c..7c9fe492ac1 100644 --- a/metrics/src/vespa/metrics/metricsnapshot.h +++ b/metrics/src/vespa/metrics/metricsnapshot.h @@ -11,6 +11,7 @@ #include #include #include +#include namespace metrics { diff --git a/metrics/src/vespa/metrics/state_api_adapter.cpp b/metrics/src/vespa/metrics/state_api_adapter.cpp index f2e5108872e..6abc4336446 100644 --- a/metrics/src/vespa/metrics/state_api_adapter.cpp +++ b/metrics/src/vespa/metrics/state_api_adapter.cpp @@ -3,7 +3,6 @@ #include "state_api_adapter.h" #include "metricmanager.h" #include -#include namespace metrics { @@ -30,7 +29,7 @@ StateApiAdapter::getTotalMetrics(const vespalib::string &consumer) _manager.updateMetrics(true); metrics::MetricLockGuard guard(_manager.getMetricLock()); _manager.checkMetricsAltered(guard); - time_t currentTime = fastos::time(); + time_t currentTime = vespalib::to_s(vespalib::steady_clock::now().time_since_epoch()); auto generated = std::make_unique( "Total metrics from start until current time", 0, _manager.getTotalMetricSnapshot(guard).getMetrics(), diff --git a/searchcommon/src/vespa/searchcommon/common/schema.h b/searchcommon/src/vespa/searchcommon/common/schema.h index 7561bf8b741..d71c14c90b1 100644 --- a/searchcommon/src/vespa/searchcommon/common/schema.h +++ b/searchcommon/src/vespa/searchcommon/common/schema.h @@ -6,7 +6,6 @@ #include #include #include -#include #include namespace vespalib { class asciistream; } 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 6301b8a343c..a947074a917 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,6 @@ #include #include #include -#include #include #include #include diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h index f759154eefe..ed370b000f3 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp index 3fd9abb6744..2a447957334 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp @@ -4,7 +4,6 @@ #include #include -#include using vespalib::slime::Cursor; using vespalib::slime::Inserter; diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.cpp index e7e005e2d95..e9c2554f13c 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.cpp +++ b/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.cpp @@ -2,7 +2,6 @@ #include "shrink_lid_space_flush_target.h" #include -#include namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp b/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp index c2835d2bb76..faf0cde4491 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp @@ -3,7 +3,6 @@ #include "session_manager_explorer.h" #include "sessionmanager.h" #include -#include using vespalib::slime::Inserter; using vespalib::slime::Cursor; diff --git a/searchlib/src/tests/transactionlogstress/translogstress.cpp b/searchlib/src/tests/transactionlogstress/translogstress.cpp index 247e1316a7b..a0e4b4884a9 100644 --- a/searchlib/src/tests/transactionlogstress/translogstress.cpp +++ b/searchlib/src/tests/transactionlogstress/translogstress.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.h b/searchlib/src/vespa/searchlib/docstore/filechunk.h index 5e3723c9522..0f139f507c6 100644 --- a/searchlib/src/vespa/searchlib/docstore/filechunk.h +++ b/searchlib/src/vespa/searchlib/docstore/filechunk.h @@ -13,7 +13,6 @@ #include #include #include -#include class FastOS_FileInterface; diff --git a/searchlib/src/vespa/searchlib/docstore/idatastore.h b/searchlib/src/vespa/searchlib/docstore/idatastore.h index 2ca693dde95..75e1bd2a5e1 100644 --- a/searchlib/src/vespa/searchlib/docstore/idatastore.h +++ b/searchlib/src/vespa/searchlib/docstore/idatastore.h @@ -3,7 +3,6 @@ #pragma once #include "data_store_file_chunk_stats.h" -#include #include #include #include diff --git a/searchlib/src/vespa/searchlib/engine/trace.cpp b/searchlib/src/vespa/searchlib/engine/trace.cpp index 705bd5782ab..d2942f2be6b 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.cpp +++ b/searchlib/src/vespa/searchlib/engine/trace.cpp @@ -2,7 +2,6 @@ #include "trace.h" #include -#include namespace search::engine { diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fake_match_loop.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fake_match_loop.cpp index 1b7f794826d..bd55acbed9e 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fake_match_loop.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fake_match_loop.cpp @@ -2,7 +2,6 @@ #include "fake_match_loop.h" #include "fakeposting.h" -#include #include #include #include diff --git a/storage/src/tests/distributor/garbagecollectiontest.cpp b/storage/src/tests/distributor/garbagecollectiontest.cpp index 88281f3ca20..65c1ac726b5 100644 --- a/storage/src/tests/distributor/garbagecollectiontest.cpp +++ b/storage/src/tests/distributor/garbagecollectiontest.cpp @@ -18,7 +18,7 @@ struct GarbageCollectionOperationTest : Test, DistributorTestUtil { createLinks(); enableDistributorClusterState("distributor:1 storage:2"); addNodesToBucketDB(document::BucketId(16, 1), "0=250/50/300,1=250/50/300"); - getConfig().setGarbageCollection("music.date < 34", 3600); + getConfig().setGarbageCollection("music.date < 34", 3600s); getClock().setAbsoluteTimeInSeconds(34); }; diff --git a/storage/src/tests/distributor/statecheckerstest.cpp b/storage/src/tests/distributor/statecheckerstest.cpp index 0c1ec1e77de..01c4ad1cf6a 100644 --- a/storage/src/tests/distributor/statecheckerstest.cpp +++ b/storage/src/tests/distributor/statecheckerstest.cpp @@ -1242,8 +1242,8 @@ std::string StateCheckersTest::testGarbageCollection( getBucketDatabase().update(e); GarbageCollectionStateChecker checker; - getConfig().setGarbageCollection("music", checkInterval); - getConfig().setLastGarbageCollectionChangeTime(lastChangeTime); + getConfig().setGarbageCollection("music", std::chrono::seconds(checkInterval)); + getConfig().setLastGarbageCollectionChangeTime(vespalib::steady_time(std::chrono::seconds(lastChangeTime))); NodeMaintenanceStatsTracker statsTracker; StateChecker::Context c(getExternalOperationHandler(), getDistributorBucketSpace(), statsTracker, makeDocumentBucket(e.getBucketId())); @@ -1315,8 +1315,8 @@ TEST_F(StateCheckersTest, gc_inhibited_when_ideal_node_in_maintenance) { getBucketDatabase().update(e); GarbageCollectionStateChecker checker; - getConfig().setGarbageCollection("music", 3600); - getConfig().setLastGarbageCollectionChangeTime(0); + getConfig().setGarbageCollection("music", 3600s); + getConfig().setLastGarbageCollectionChangeTime(vespalib::steady_time(vespalib::duration::zero())); NodeMaintenanceStatsTracker statsTracker; StateChecker::Context c(getExternalOperationHandler(), getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bucket)); diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.h b/storage/src/vespa/storage/bucketdb/bucketinfo.h index f0be700d204..9616a1fae6e 100644 --- a/storage/src/vespa/storage/bucketdb/bucketinfo.h +++ b/storage/src/vespa/storage/bucketdb/bucketinfo.h @@ -3,12 +3,11 @@ #include "bucketcopy.h" #include +#include namespace storage { -namespace distributor { - class DistributorTestUtil; -} +namespace distributor { class DistributorTestUtil; } enum class TrustedUpdate { UPDATE, @@ -190,10 +189,6 @@ public: */ bool removeNode(uint16_t node, TrustedUpdate update = TrustedUpdate::UPDATE); - void clearTrusted(uint16_t nodeIdx) { - getNodeInternal(nodeIdx)->clearTrusted(); - } - /** Clears all nodes from the bucket information. */ @@ -207,10 +202,6 @@ private: */ BucketCopy* getNodeInternal(uint16_t node); - const BucketCopy& getNodeRefInternal(uint16_t idx) const { - return _nodes[idx]; - } - void addNodeManual(const BucketCopy& newCopy) { _nodes.push_back(newCopy); } }; diff --git a/storage/src/vespa/storage/config/distributorconfiguration.cpp b/storage/src/vespa/storage/config/distributorconfiguration.cpp index e89b9e6b1aa..0b8564e561a 100644 --- a/storage/src/vespa/storage/config/distributorconfiguration.cpp +++ b/storage/src/vespa/storage/config/distributorconfiguration.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include @@ -23,14 +22,14 @@ DistributorConfiguration::DistributorConfiguration(StorageComponent& component) _maxIdealStateOperations(100), _idealStateChunkSize(1000), _maxNodesPerMerge(16), - _lastGarbageCollectionChange(0), + _lastGarbageCollectionChange(vespalib::duration::zero()), _garbageCollectionInterval(0), _minPendingMaintenanceOps(100), _maxPendingMaintenanceOps(1000), _maxVisitorsPerNodePerClientVisitor(4), _minBucketsPerVisitor(5), _maxClusterClockSkew(0), - _inhibitMergeSendingOnBusyNodeDuration(std::chrono::seconds(60)), + _inhibitMergeSendingOnBusyNodeDuration(60s), _simulated_db_pruning_latency(0), _simulated_db_merging_latency(0), _doInlineSplit(true), @@ -122,20 +121,20 @@ DistributorConfiguration::configure(const vespa::config::content::core::StorDist _minimalBucketSplit = config.minsplitcount; _maxNodesPerMerge = config.maximumNodesPerMerge; - _garbageCollectionInterval = config.garbagecollection.interval; + _garbageCollectionInterval = std::chrono::seconds(config.garbagecollection.interval); if (containsTimeStatement(config.garbagecollection.selectiontoremove)) { // Always changes. - _lastGarbageCollectionChange = 1; + _lastGarbageCollectionChange = vespalib::steady_time::min(); } else if (_garbageCollectionSelection != config.garbagecollection.selectiontoremove) { - _lastGarbageCollectionChange = fastos::time(); + _lastGarbageCollectionChange = vespalib::steady_clock::now(); } _garbageCollectionSelection = config.garbagecollection.selectiontoremove; // Don't garbage collect with empty selection. if (_garbageCollectionSelection.empty()) { - _garbageCollectionInterval = 0; + _garbageCollectionInterval = vespalib::duration::zero(); } _blockedStateCheckers.clear(); @@ -177,7 +176,7 @@ DistributorConfiguration::configure(const vespa::config::content::core::StorDist (int)_byteCountJoinLimit, (int)_minimalBucketSplit, _garbageCollectionSelection.c_str(), - (int)_garbageCollectionInterval, + (int)vespalib::to_s(_garbageCollectionInterval), (int)_maxIdealStateOperations); } diff --git a/storage/src/vespa/storage/config/distributorconfiguration.h b/storage/src/vespa/storage/config/distributorconfiguration.h index 3cb84943508..51ac7f8dae0 100644 --- a/storage/src/vespa/storage/config/distributorconfiguration.h +++ b/storage/src/vespa/storage/config/distributorconfiguration.h @@ -1,17 +1,15 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include -#include +#include "config-stor-distributormanager.h" +#include "config-stor-visitordispatcher.h" #include #include -#include +#include namespace storage { -namespace distributor { -struct DistributorTest; -} +namespace distributor { struct DistributorTest; } class DistributorConfiguration { public: @@ -40,33 +38,22 @@ public: void configure(const DistrConfig& config); void configure(const vespa::config::content::core::StorVisitordispatcherConfig& config); - - void setIdealStateChunkSize(uint32_t chunkSize) { - _idealStateChunkSize = chunkSize; - } - - uint32_t getIdealStateChunkSize() { - return _idealStateChunkSize; - } - uint32_t lastGarbageCollectionChangeTime() const { - return _lastGarbageCollectionChange; - } const std::string& getGarbageCollectionSelection() const { return _garbageCollectionSelection; } - uint32_t getGarbageCollectionInterval() const { + vespalib::duration getGarbageCollectionInterval() const { return _garbageCollectionInterval; } - void setGarbageCollection(const std::string& selection, uint32_t interval) { + void setGarbageCollection(const std::string& selection, vespalib::duration interval) { _garbageCollectionSelection = selection; _garbageCollectionInterval = interval; } - void setLastGarbageCollectionChangeTime(uint32_t lastChangeTime) { + void setLastGarbageCollectionChangeTime(vespalib::steady_time lastChangeTime) { _lastGarbageCollectionChange = lastChangeTime; } @@ -124,20 +111,6 @@ public: */ void setMinimalBucketSplit(int splitBits) { _minimalBucketSplit = splitBits; }; - /** - Sets the maximum number of ideal state operations a distributor should - schedule to each storage node. - - @param numOps The number of operations to schedule. - */ - void setMaxIdealStateOperations(uint32_t numOps) { - _maxIdealStateOperations = numOps; - }; - - uint32_t getMaxIdealStateOperations() { - return _maxIdealStateOperations; - } - void setMaintenancePriorities(const MaintenancePriorities& mp) { _maintenancePriorities = mp; } @@ -191,13 +164,6 @@ public: return _minBucketsPerVisitor; } - void setMaxVisitorsPerNodePerClientVisitor(uint32_t n) { - _maxVisitorsPerNodePerClientVisitor = n; - } - void setMinBucketsPerVisitor(uint32_t n) { - _minBucketsPerVisitor = n; - } - uint32_t getMaxNodesPerMerge() const { return _maxNodesPerMerge; } @@ -213,9 +179,7 @@ public: } using ReplicaCountingMode = DistrConfig::MinimumReplicaCountingMode; - void setMinimumReplicaCountingMode(ReplicaCountingMode mode) noexcept { - _minimumReplicaCountingMode = mode; - } + ReplicaCountingMode getMinimumReplicaCountingMode() const noexcept { return _minimumReplicaCountingMode; } @@ -276,8 +240,8 @@ private: std::string _garbageCollectionSelection; - uint32_t _lastGarbageCollectionChange; - uint32_t _garbageCollectionInterval; + vespalib::steady_time _lastGarbageCollectionChange; + vespalib::duration _garbageCollectionInterval; uint32_t _minPendingMaintenanceOps; uint32_t _maxPendingMaintenanceOps; diff --git a/storage/src/vespa/storage/distributor/statechecker.cpp b/storage/src/vespa/storage/distributor/statechecker.cpp index f7ef1122692..2740d275732 100644 --- a/storage/src/vespa/storage/distributor/statechecker.cpp +++ b/storage/src/vespa/storage/distributor/statechecker.cpp @@ -70,8 +70,7 @@ StateChecker::Context::Context(const DistributorComponent& c, distributorConfig(c.getDistributor().getConfig()), distribution(distributorBucketSpace.getDistribution()), gcTimeCalculator(c.getDistributor().getBucketIdHasher(), - std::chrono::seconds(distributorConfig - .getGarbageCollectionInterval())), + std::chrono::duration_cast(distributorConfig.getGarbageCollectionInterval())), component(c), db(distributorBucketSpace.getBucketDatabase()), stats(statsTracker) diff --git a/storage/src/vespa/storage/distributor/statecheckers.cpp b/storage/src/vespa/storage/distributor/statecheckers.cpp index dab2025bfbb..b1fa3056cb1 100644 --- a/storage/src/vespa/storage/distributor/statecheckers.cpp +++ b/storage/src/vespa/storage/distributor/statecheckers.cpp @@ -1119,7 +1119,7 @@ BucketStateStateChecker::check(StateChecker::Context& c) bool GarbageCollectionStateChecker::needsGarbageCollection(const Context& c) const { - if (c.entry->getNodeCount() == 0 || c.distributorConfig.getGarbageCollectionInterval() == 0) { + if (c.entry->getNodeCount() == 0 || c.distributorConfig.getGarbageCollectionInterval() == vespalib::duration::zero()) { return false; } if (containsMaintenanceNode(c.idealState, c)) { @@ -1147,7 +1147,7 @@ GarbageCollectionStateChecker::check(Context& c) << ", current time " << c.component.getClock().getTimeInSeconds().getTime() << ", configured interval " - << c.distributorConfig.getGarbageCollectionInterval() << "]"; + << vespalib::to_s(c.distributorConfig.getGarbageCollectionInterval()) << "]"; op->setPriority(c.distributorConfig.getMaintenancePriorities().garbageCollection); op->setDetailedReason(reason.c_str()); diff --git a/storage/src/vespa/storage/visiting/commandqueue.h b/storage/src/vespa/storage/visiting/commandqueue.h index ce309d55803..498cf14567d 100644 --- a/storage/src/vespa/storage/visiting/commandqueue.h +++ b/storage/src/vespa/storage/visiting/commandqueue.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/storageapi/src/vespa/storageapi/buckets/bucketinfo.h b/storageapi/src/vespa/storageapi/buckets/bucketinfo.h index c3aefd95ff3..a80595527e2 100644 --- a/storageapi/src/vespa/storageapi/buckets/bucketinfo.h +++ b/storageapi/src/vespa/storageapi/buckets/bucketinfo.h @@ -17,8 +17,7 @@ #include #include -namespace storage { -namespace api { +namespace storage::api { class BucketInfo : public vespalib::AsciiPrintable { @@ -87,5 +86,4 @@ public: void printXml(vespalib::XmlOutputStream&) const; }; -} // api -} // storage +} diff --git a/vespalib/src/tests/executor/stress_test.cpp b/vespalib/src/tests/executor/stress_test.cpp index 01787e2e14c..615e7addfd5 100644 --- a/vespalib/src/tests/executor/stress_test.cpp +++ b/vespalib/src/tests/executor/stress_test.cpp @@ -4,7 +4,6 @@ #include #include #include -#include using namespace vespalib; using namespace std::literals; diff --git a/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp b/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp index 50ee6296f16..71bae66ed2f 100644 --- a/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp +++ b/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp @@ -2,7 +2,6 @@ #include #include #include -#include using namespace vespalib; diff --git a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp index 1d011e507bb..dc31f4b8b42 100644 --- a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp +++ b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp @@ -2,7 +2,6 @@ #include #include #include -#include using namespace vespalib; using namespace vespalib::slime::convenience; -- cgit v1.2.3