aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-04 14:33:50 +0100
committerGitHub <noreply@github.com>2023-02-04 14:33:50 +0100
commit11b731d1a6b3a9e9bbf84bc94285a6c22d6910e1 (patch)
tree6f491512efa726cdd0859ba50aaa109a8015a1ed
parentbf18a82d03c17ee333fd00124c5b095085ab9737 (diff)
parentcccdf363f45e51827ba1c4d25e8486a44f81c912 (diff)
Merge pull request #25873 from vespa-engine/balder/gc-second-time
- SecondTime => vespalib::duration in registerMetricUpdateHook.
-rw-r--r--storage/src/vespa/storage/bucketdb/bucketmanager.cpp200
-rw-r--r--storage/src/vespa/storage/common/statusmetricconsumer.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/top_level_distributor.cpp2
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.cpp2
-rw-r--r--storage/src/vespa/storage/storageserver/communicationmanager.cpp2
-rw-r--r--storage/src/vespa/storage/storageserver/storagenode.cpp21
-rw-r--r--storage/src/vespa/storage/storageserver/storagenode.h1
-rw-r--r--storage/src/vespa/storage/visiting/visitormanager.cpp2
-rw-r--r--storage/src/vespa/storage/visiting/visitorthread.cpp3
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp18
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h8
-rw-r--r--storage/src/vespa/storageframework/generic/component/component.cpp16
-rw-r--r--storage/src/vespa/storageframework/generic/component/component.h52
-rw-r--r--storage/src/vespa/storageframework/generic/component/managedcomponent.h34
-rw-r--r--storage/src/vespa/storageframework/generic/metric/metricregistrator.h2
15 files changed, 125 insertions, 240 deletions
diff --git a/storage/src/vespa/storage/bucketdb/bucketmanager.cpp b/storage/src/vespa/storage/bucketdb/bucketmanager.cpp
index 8e25c9a2ffb..9fafc87688f 100644
--- a/storage/src/vespa/storage/bucketdb/bucketmanager.cpp
+++ b/storage/src/vespa/storage/bucketdb/bucketmanager.cpp
@@ -50,13 +50,11 @@ BucketManager::BucketManager(const config::ConfigUri & configUri,
{
_component.registerStatusPage(*this);
_component.registerMetric(*_metrics);
- _component.registerMetricUpdateHook(*this, framework::SecondTime(300));
+ _component.registerMetricUpdateHook(*this, 300s);
// Initialize min used bits to default value used here.
- NodeStateUpdater::Lock::SP lock(
- _component.getStateUpdater().grabStateChangeLock());
- lib::NodeState ns(
- *_component.getStateUpdater().getReportedNodeState());
+ NodeStateUpdater::Lock::SP lock(_component.getStateUpdater().grabStateChangeLock());
+ lib::NodeState ns(*_component.getStateUpdater().getReportedNodeState());
ns.setMinUsedBits(58);
_component.getStateUpdater().setReportedNodeState(ns);
@@ -94,118 +92,118 @@ BucketManager::print(std::ostream& out, bool verbose,
namespace {
- template<bool log>
- class DistributorInfoGatherer
+template<bool log>
+class DistributorInfoGatherer
+{
+ using ResultArray = api::RequestBucketInfoReply::EntryVector;
+
+ DistributorStateCache _state;
+ std::unordered_map<uint16_t, ResultArray>& _result;
+ const document::BucketIdFactory& _factory;
+ std::shared_ptr<const lib::Distribution> _storageDistribution;
+
+public:
+ DistributorInfoGatherer(
+ const lib::ClusterState& systemState,
+ std::unordered_map<uint16_t, ResultArray>& result,
+ const document::BucketIdFactory& factory,
+ std::shared_ptr<const lib::Distribution> distribution)
+ : _state(*distribution, systemState),
+ _result(result),
+ _factory(factory),
+ _storageDistribution(std::move(distribution))
{
- using ResultArray = api::RequestBucketInfoReply::EntryVector;
-
- DistributorStateCache _state;
- std::unordered_map<uint16_t, ResultArray>& _result;
- const document::BucketIdFactory& _factory;
- std::shared_ptr<const lib::Distribution> _storageDistribution;
-
- public:
- DistributorInfoGatherer(
- const lib::ClusterState& systemState,
- std::unordered_map<uint16_t, ResultArray>& result,
- const document::BucketIdFactory& factory,
- std::shared_ptr<const lib::Distribution> distribution)
- : _state(*distribution, systemState),
- _result(result),
- _factory(factory),
- _storageDistribution(std::move(distribution))
- {
- }
+ }
- StorBucketDatabase::Decision operator()(uint64_t bucketId,
- const StorBucketDatabase::Entry& data)
- {
- document::BucketId b(document::BucketId::keyToBucketId(bucketId));
- try{
- uint16_t i = _state.getOwner(b);
- auto it = _result.find(i);
- if constexpr (log) {
- LOG(spam, "Bucket %s (reverse %" PRIu64 "), should be handled"
- " by distributor %u which we are %sgenerating "
- "state for.",
- b.toString().c_str(), bucketId, i,
- it == _result.end() ? "not " : "");
- }
- if (it != _result.end()) {
- api::RequestBucketInfoReply::Entry entry;
- entry._bucketId = b;
- entry._info = data.getBucketInfo();
- it->second.push_back(entry);
- }
- } catch (lib::TooFewBucketBitsInUseException& e) {
- LOGBP(warning, "Cannot assign bucket %s to a distributor "
- " as bucket only specifies %u bits.",
- b.toString().c_str(),
- b.getUsedBits());
- } catch (lib::NoDistributorsAvailableException& e) {
- LOGBP(warning, "No distributors available while processing "
- "request bucket info. Distribution hash: %s, "
- "cluster state: %s",
- _state.getDistribution().getNodeGraph()
- .getDistributionConfigHash().c_str(),
- _state.getClusterState().toString().c_str());
+ StorBucketDatabase::Decision operator()(uint64_t bucketId,
+ const StorBucketDatabase::Entry& data)
+ {
+ document::BucketId b(document::BucketId::keyToBucketId(bucketId));
+ try{
+ uint16_t i = _state.getOwner(b);
+ auto it = _result.find(i);
+ if constexpr (log) {
+ LOG(spam, "Bucket %s (reverse %" PRIu64 "), should be handled"
+ " by distributor %u which we are %sgenerating "
+ "state for.",
+ b.toString().c_str(), bucketId, i,
+ it == _result.end() ? "not " : "");
+ }
+ if (it != _result.end()) {
+ api::RequestBucketInfoReply::Entry entry;
+ entry._bucketId = b;
+ entry._info = data.getBucketInfo();
+ it->second.push_back(entry);
}
- return StorBucketDatabase::Decision::CONTINUE;
+ } catch (lib::TooFewBucketBitsInUseException& e) {
+ LOGBP(warning, "Cannot assign bucket %s to a distributor "
+ " as bucket only specifies %u bits.",
+ b.toString().c_str(),
+ b.getUsedBits());
+ } catch (lib::NoDistributorsAvailableException& e) {
+ LOGBP(warning, "No distributors available while processing "
+ "request bucket info. Distribution hash: %s, "
+ "cluster state: %s",
+ _state.getDistribution().getNodeGraph()
+ .getDistributionConfigHash().c_str(),
+ _state.getClusterState().toString().c_str());
}
+ return StorBucketDatabase::Decision::CONTINUE;
+ }
- };
+};
- struct MetricsUpdater {
- struct Count {
- uint64_t docs;
- uint64_t bytes;
- uint64_t buckets;
- uint64_t active;
- uint64_t ready;
+struct MetricsUpdater {
+ struct Count {
+ uint64_t docs;
+ uint64_t bytes;
+ uint64_t buckets;
+ uint64_t active;
+ uint64_t ready;
- constexpr Count() noexcept : docs(0), bytes(0), buckets(0), active(0), ready(0) {}
- };
+ constexpr Count() noexcept : docs(0), bytes(0), buckets(0), active(0), ready(0) {}
+ };
- Count count;
- uint32_t lowestUsedBit;
+ Count count;
+ uint32_t lowestUsedBit;
- constexpr MetricsUpdater() noexcept
- : count(), lowestUsedBit(58) {}
+ constexpr MetricsUpdater() noexcept
+ : count(), lowestUsedBit(58) {}
- void operator()(document::BucketId::Type bucketId,
- const StorBucketDatabase::Entry& data) noexcept
- {
- document::BucketId bucket(
- document::BucketId::keyToBucketId(bucketId));
+ void operator()(document::BucketId::Type bucketId,
+ const StorBucketDatabase::Entry& data) noexcept
+ {
+ document::BucketId bucket(
+ document::BucketId::keyToBucketId(bucketId));
- if (data.valid()) {
- ++count.buckets;
- if (data.getBucketInfo().isActive()) {
- ++count.active;
- }
- if (data.getBucketInfo().isReady()) {
- ++count.ready;
- }
- count.docs += data.getBucketInfo().getDocumentCount();
- count.bytes += data.getBucketInfo().getTotalDocumentSize();
-
- if (bucket.getUsedBits() < lowestUsedBit) {
- lowestUsedBit = bucket.getUsedBits();
- }
+ if (data.valid()) {
+ ++count.buckets;
+ if (data.getBucketInfo().isActive()) {
+ ++count.active;
}
- };
+ if (data.getBucketInfo().isReady()) {
+ ++count.ready;
+ }
+ count.docs += data.getBucketInfo().getDocumentCount();
+ count.bytes += data.getBucketInfo().getTotalDocumentSize();
- void add(const MetricsUpdater& rhs) noexcept {
- auto& d = count;
- auto& s = rhs.count;
- d.buckets += s.buckets;
- d.docs += s.docs;
- d.bytes += s.bytes;
- d.ready += s.ready;
- d.active += s.active;
+ if (bucket.getUsedBits() < lowestUsedBit) {
+ lowestUsedBit = bucket.getUsedBits();
+ }
}
};
+ void add(const MetricsUpdater& rhs) noexcept {
+ auto& d = count;
+ auto& s = rhs.count;
+ d.buckets += s.buckets;
+ d.docs += s.docs;
+ d.bytes += s.bytes;
+ d.ready += s.ready;
+ d.active += s.active;
+ }
+};
+
} // End of anonymous namespace
StorBucketDatabase::Entry
diff --git a/storage/src/vespa/storage/common/statusmetricconsumer.cpp b/storage/src/vespa/storage/common/statusmetricconsumer.cpp
index 561d7cbdd6f..9ffb044b0a5 100644
--- a/storage/src/vespa/storage/common/statusmetricconsumer.cpp
+++ b/storage/src/vespa/storage/common/statusmetricconsumer.cpp
@@ -28,7 +28,7 @@ StatusMetricConsumer::StatusMetricConsumer(
{
LOG(debug, "Started metrics consumer");
setlocale(LC_NUMERIC, "");
- _component.registerMetricUpdateHook(*this, framework::SecondTime(3600));
+ _component.registerMetricUpdateHook(*this, 3600s);
_component.registerStatusPage(*this);
}
diff --git a/storage/src/vespa/storage/distributor/top_level_distributor.cpp b/storage/src/vespa/storage/distributor/top_level_distributor.cpp
index e5cc35bd2d3..54dedbebbfe 100644
--- a/storage/src/vespa/storage/distributor/top_level_distributor.cpp
+++ b/storage/src/vespa/storage/distributor/top_level_distributor.cpp
@@ -84,7 +84,7 @@ TopLevelDistributor::TopLevelDistributor(DistributorComponentRegister& compReg,
{
_component.registerMetric(*_total_metrics);
_ideal_state_component.registerMetric(*_ideal_state_total_metrics);
- _component.registerMetricUpdateHook(_metricUpdateHook, framework::SecondTime(0));
+ _component.registerMetricUpdateHook(_metricUpdateHook, 0s);
assert(num_distributor_stripes == adjusted_num_stripes(num_distributor_stripes));
_n_stripe_bits = calc_num_stripe_bits(num_distributor_stripes);
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.cpp b/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.cpp
index 12924c3b4f7..92b9e832a23 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.cpp
@@ -76,7 +76,7 @@ FileStorHandlerImpl::FileStorHandlerImpl(uint32_t numThreads, uint32_t numStripe
}
// Add update hook, so we will get callbacks each 5 seconds to update metrics.
- _component.registerMetricUpdateHook(*this, framework::SecondTime(5));
+ _component.registerMetricUpdateHook(*this, 5s);
}
FileStorHandlerImpl::~FileStorHandlerImpl()
diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.cpp b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
index fff40250d41..0680c10ab29 100644
--- a/storage/src/vespa/storage/storageserver/communicationmanager.cpp
+++ b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
@@ -230,7 +230,7 @@ CommunicationManager::CommunicationManager(StorageComponentRegister& compReg, co
_docApiConverter(configUri, std::make_shared<PlaceHolderBucketResolver>()),
_thread()
{
- _component.registerMetricUpdateHook(*this, framework::SecondTime(5));
+ _component.registerMetricUpdateHook(*this, 5s);
_component.registerMetric(_metrics);
}
diff --git a/storage/src/vespa/storage/storageserver/storagenode.cpp b/storage/src/vespa/storage/storageserver/storagenode.cpp
index cc433ea4ee5..3987827a264 100644
--- a/storage/src/vespa/storage/storageserver/storagenode.cpp
+++ b/storage/src/vespa/storage/storageserver/storagenode.cpp
@@ -137,8 +137,6 @@ StorageNode::initialize()
// and store them away, while having the config lock.
subscribeToConfigs();
- updateUpgradeFlag(*_clusterConfig);
-
// First update some basics that doesn't depend on anything else to be
// available
_rootFolder = _serverConfig->rootFolder;
@@ -156,7 +154,7 @@ StorageNode::initialize()
_metricManager = std::make_unique<metrics::MetricManager>();
_context.getComponentRegister().setMetricManager(*_metricManager);
}
- _component->registerMetricUpdateHook(*this, framework::SecondTime(300));
+ _component->registerMetricUpdateHook(*this, 300s);
// Initializing state manager early, as others use it init time to
// update node state according min used bits etc.
@@ -246,22 +244,6 @@ StorageNode::setNewDocumentRepo(const std::shared_ptr<const document::DocumentTy
}
void
-StorageNode::updateUpgradeFlag(const UpgradingConfig& config)
-{
- framework::UpgradeFlags flag(framework::NO_UPGRADE_SPECIAL_HANDLING_ACTIVE);
- if (config.upgradingMajorTo) {
- flag = framework::UPGRADING_TO_MAJOR_VERSION;
- } else if (config.upgradingMinorTo) {
- flag = framework::UPGRADING_TO_MINOR_VERSION;
- } else if (config.upgradingMajorFrom) {
- flag = framework::UPGRADING_FROM_MAJOR_VERSION;
- } else if (config.upgradingMinorFrom) {
- flag = framework::UPGRADING_FROM_MINOR_VERSION;
- }
- _context.getComponentRegister().setUpgradeFlag(flag);
-}
-
-void
StorageNode::handleLiveConfigUpdate(const InitialGuard & initGuard)
{
// Make sure we don't conflict with initialize or shutdown threads.
@@ -329,7 +311,6 @@ StorageNode::handleLiveConfigUpdate(const InitialGuard & initGuard)
}
}
if (_newClusterConfig) {
- updateUpgradeFlag(*_newClusterConfig);
if (*_clusterConfig != *_newClusterConfig) {
LOG(warning, "Live config failure: Cannot alter cluster config of node live.");
}
diff --git a/storage/src/vespa/storage/storageserver/storagenode.h b/storage/src/vespa/storage/storageserver/storagenode.h
index 0b7dc0233e4..0e420f206e2 100644
--- a/storage/src/vespa/storage/storageserver/storagenode.h
+++ b/storage/src/vespa/storage/storageserver/storagenode.h
@@ -136,7 +136,6 @@ private:
virtual void configure(std::unique_ptr<document::config::DocumenttypesConfig> config,
bool hasChanged, int64_t generation);
void configure(std::unique_ptr<BucketspacesConfig>) override;
- void updateUpgradeFlag(const UpgradingConfig&);
protected:
// Lock taken while doing configuration of the server.
diff --git a/storage/src/vespa/storage/visiting/visitormanager.cpp b/storage/src/vespa/storage/visiting/visitormanager.cpp
index 9c9a39ff28c..a03b9a9a8a3 100644
--- a/storage/src/vespa/storage/visiting/visitormanager.cpp
+++ b/storage/src/vespa/storage/visiting/visitormanager.cpp
@@ -56,7 +56,7 @@ VisitorManager::VisitorManager(const config::ConfigUri & configUri,
if (!defer_manager_thread_start) {
create_and_start_manager_thread();
}
- _component.registerMetricUpdateHook(*this, framework::SecondTime(5));
+ _component.registerMetricUpdateHook(*this, 5s);
_visitorFactories["dumpvisitor"] = std::make_shared<DumpVisitorSingleFactory>();
_visitorFactories["dumpvisitorsingle"] = std::make_shared<DumpVisitorSingleFactory>();
_visitorFactories["testvisitor"] = std::make_shared<TestVisitorFactory>();
diff --git a/storage/src/vespa/storage/visiting/visitorthread.cpp b/storage/src/vespa/storage/visiting/visitorthread.cpp
index ba2a7584ff4..55ef83ba658 100644
--- a/storage/src/vespa/storage/visiting/visitorthread.cpp
+++ b/storage/src/vespa/storage/visiting/visitorthread.cpp
@@ -11,7 +11,6 @@
#include <vespa/storage/config/config-stor-server.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/exceptions.h>
-#include <locale>
#include <vespa/log/log.h>
LOG_SETUP(".visitor.thread");
@@ -95,7 +94,7 @@ VisitorThread::VisitorThread(uint32_t threadIndex,
_visitorFactories(visitorFactories)
{
_thread = _component.startThread(*this, 30s, 1s, 1, vespalib::CpuUsage::Category::READ);
- _component.registerMetricUpdateHook(*this, framework::SecondTime(5));
+ _component.registerMetricUpdateHook(*this, 5s);
}
VisitorThread::~VisitorThread()
diff --git a/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp b/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp
index 0da02b15a11..1c33fa453bd 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp
+++ b/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp
@@ -16,7 +16,6 @@ ComponentRegisterImpl::ComponentRegisterImpl()
_metricManager(nullptr),
_clock(nullptr),
_threadPool(nullptr),
- _upgradeFlag(NO_UPGRADE_SPECIAL_HANDLING_ACTIVE),
_shutdownListener(nullptr)
{ }
@@ -36,7 +35,6 @@ ComponentRegisterImpl::registerComponent(ManagedComponent& mc)
if (_metricManager) {
mc.setMetricRegistrator(*this);
}
- mc.setUpgradeFlag(_upgradeFlag);
}
void
@@ -62,7 +60,7 @@ ComponentRegisterImpl::setMetricManager(metrics::MetricManager& mm)
metrics::MetricLockGuard lock(mm.getMetricLock());
mm.registerMetric(lock, _topMetricSet);
}
- for (auto* component : _components) {
+ for (auto* component : components) {
component->setMetricRegistrator(*this);
}
}
@@ -89,16 +87,6 @@ ComponentRegisterImpl::setThreadPool(ThreadPool& tp)
}
}
-void
-ComponentRegisterImpl::setUpgradeFlag(UpgradeFlags flag)
-{
- std::lock_guard lock(_componentLock);
- _upgradeFlag = flag;
- for (auto* component : _components) {
- component->setUpgradeFlag(_upgradeFlag);
- }
-}
-
const StatusReporter*
ComponentRegisterImpl::getStatusReporter(vespalib::stringref id)
{
@@ -150,11 +138,11 @@ namespace {
void
ComponentRegisterImpl::registerUpdateHook(vespalib::stringref name,
MetricUpdateHook& hook,
- SecondTime period)
+ vespalib::duration period)
{
std::lock_guard lock(_componentLock);
auto hookPtr = std::make_unique<MetricHookWrapper>(name, hook);
- _metricManager->addMetricUpdateHook(*hookPtr, period.getTime());
+ _metricManager->addMetricUpdateHook(*hookPtr, vespalib::to_s(period));
_hooks.emplace_back(std::move(hookPtr));
}
diff --git a/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h b/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h
index 8cd4f87c404..e569288ac64 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h
+++ b/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h
@@ -35,7 +35,7 @@ namespace metrics {
namespace storage::framework::defaultimplementation {
struct ShutdownListener {
- virtual ~ShutdownListener() {}
+ virtual ~ShutdownListener() = default;
virtual void requestShutdown(vespalib::stringref reason) = 0;
};
@@ -51,7 +51,6 @@ class ComponentRegisterImpl : public virtual ComponentRegister,
metrics::MetricManager* _metricManager;
Clock* _clock;
ThreadPool* _threadPool;
- UpgradeFlags _upgradeFlag;
ShutdownListener* _shutdownListener;
public:
@@ -60,7 +59,7 @@ public:
ComponentRegisterImpl();
~ComponentRegisterImpl() override;
- bool hasMetricManager() const { return (_metricManager != 0); }
+ [[nodiscard]] bool hasMetricManager() const { return (_metricManager != nullptr); }
metrics::MetricManager& getMetricManager() { return *_metricManager; }
void registerComponent(ManagedComponent&) override;
@@ -69,13 +68,12 @@ public:
void setMetricManager(metrics::MetricManager&);
void setClock(Clock&);
void setThreadPool(ThreadPool&);
- void setUpgradeFlag(UpgradeFlags flag);
const StatusReporter* getStatusReporter(vespalib::stringref id) override;
std::vector<const StatusReporter*> getStatusReporters() override;
void registerMetric(metrics::Metric&) override;
- void registerUpdateHook(vespalib::stringref name, MetricUpdateHook& hook, SecondTime period) override;
+ void registerUpdateHook(vespalib::stringref name, MetricUpdateHook& hook, vespalib::duration period) override;
void registerShutdownListener(ShutdownListener&);
};
diff --git a/storage/src/vespa/storageframework/generic/component/component.cpp b/storage/src/vespa/storageframework/generic/component/component.cpp
index f45e1a0b839..17e521a99ac 100644
--- a/storage/src/vespa/storageframework/generic/component/component.cpp
+++ b/storage/src/vespa/storageframework/generic/component/component.cpp
@@ -11,13 +11,11 @@ namespace storage::framework {
void
Component::open()
{
- if (_listener != 0) _listener->onOpen();
}
void
Component::close()
{
- if (_listener != 0) _listener->onClose();
}
Component::Component(ComponentRegister& cr, vespalib::stringref name)
@@ -27,8 +25,7 @@ Component::Component(ComponentRegister& cr, vespalib::stringref name)
_metric(nullptr),
_threadPool(nullptr),
_metricReg(nullptr),
- _clock(nullptr),
- _listener(nullptr)
+ _clock(nullptr)
{
cr.registerComponent(*this);
}
@@ -36,13 +33,6 @@ Component::Component(ComponentRegister& cr, vespalib::stringref name)
Component::~Component() = default;
void
-Component::registerComponentStateListener(ComponentStateListener& l)
-{
- assert(_listener == nullptr);
- _listener = &l;
-}
-
-void
Component::registerStatusPage(const StatusReporter& sr)
{
assert(_status == nullptr);
@@ -60,7 +50,7 @@ Component::registerMetric(metrics::Metric& m)
}
void
-Component::registerMetricUpdateHook(MetricUpdateHook& hook, SecondTime period)
+Component::registerMetricUpdateHook(MetricUpdateHook& hook, vespalib::duration period)
{
assert(_metricUpdateHook.first == 0);
_metricUpdateHook = std::make_pair(&hook, period);
@@ -90,7 +80,7 @@ Component::getThreadPool() const
// Helper functions for components wanting to start a single thread.
Thread::UP
Component::startThread(Runnable& runnable, vespalib::duration waitTime, vespalib::duration maxProcessTime,
- int ticksBeforeWait, std::optional<vespalib::CpuUsage::Category> cpu_category)
+ int ticksBeforeWait, std::optional<vespalib::CpuUsage::Category> cpu_category) const
{
return getThreadPool().startThread(runnable, getName(), waitTime,
maxProcessTime, ticksBeforeWait, cpu_category);
diff --git a/storage/src/vespa/storageframework/generic/component/component.h b/storage/src/vespa/storageframework/generic/component/component.h
index 09af1d276f3..df1aea09653 100644
--- a/storage/src/vespa/storageframework/generic/component/component.h
+++ b/storage/src/vespa/storageframework/generic/component/component.h
@@ -79,13 +79,6 @@ namespace storage::framework {
struct ComponentRegister;
-struct ComponentStateListener {
- virtual ~ComponentStateListener() = default;
-
- virtual void onOpen() {}
- virtual void onClose() {}
-};
-
class Component : private ManagedComponent
{
ComponentRegister* _componentRegister;
@@ -94,25 +87,15 @@ class Component : private ManagedComponent
metrics::Metric* _metric;
ThreadPool* _threadPool;
MetricRegistrator* _metricReg;
- std::pair<MetricUpdateHook*, SecondTime> _metricUpdateHook;
+ std::pair<MetricUpdateHook*, vespalib::duration> _metricUpdateHook;
const Clock* _clock;
- ComponentStateListener* _listener;
- std::atomic<UpgradeFlags> _upgradeFlag;
-
- UpgradeFlags loadUpgradeFlag() const {
- return _upgradeFlag.load(std::memory_order_relaxed);
- }
// ManagedComponent implementation
metrics::Metric* getMetric() override { return _metric; }
- std::pair<MetricUpdateHook*, SecondTime> getMetricUpdateHook() override { return _metricUpdateHook; }
const StatusReporter* getStatusReporter() override { return _status; }
void setMetricRegistrator(MetricRegistrator& mr) override;
void setClock(Clock& c) override { _clock = &c; }
void setThreadPool(ThreadPool& tp) override { _threadPool = &tp; }
- void setUpgradeFlag(UpgradeFlags flag) override {
- _upgradeFlag.store(flag, std::memory_order_relaxed);
- }
void open() override;
void close() override;
@@ -120,19 +103,9 @@ public:
using UP = std::unique_ptr<Component>;
Component(ComponentRegister&, vespalib::stringref name);
- virtual ~Component();
+ ~Component() override;
/**
- * Register a component state listener, getting callbacks when components
- * are started and stopped. An application might want to create all
- * components before starting to do it's work. And it might stop doing work
- * before starting to remove components. Using this listener, components
- * may get callbacks in order to do some initialization after all components
- * are set up, and to do some cleanups before other components are being
- * removed.
- */
- void registerComponentStateListener(ComponentStateListener&);
- /**
* Register a status page, which might be visible to others through a
* component showing status of components. Only one status page can be
* registered per component. Use URI parameters in order to distinguish
@@ -152,10 +125,10 @@ public:
* update hook will only be called if there actually is a metric mananger
* component registered in the application.
*/
- void registerMetricUpdateHook(MetricUpdateHook&, SecondTime period);
+ void registerMetricUpdateHook(MetricUpdateHook&, vespalib::duration period);
/** Get the name of the component. Must be a unique name. */
- const vespalib::string& getName() const override { return _name; }
+ [[nodiscard]] const vespalib::string& getName() const override { return _name; }
/**
* Get the thread pool for this application. Note that this call will fail
@@ -163,7 +136,7 @@ public:
* encouraged to register a threadpool before adding components to avoid
* needing components to wait before accessing threadpool.
*/
- ThreadPool& getThreadPool() const;
+ [[nodiscard]] ThreadPool& getThreadPool() const;
/**
* Get the clock used in this application. This function will fail before
@@ -171,7 +144,7 @@ public:
* encourated to register a clock implementation before adding components to
* avoid needing components to delay using it.
*/
- const Clock& getClock() const { return *_clock; }
+ [[nodiscard]] const Clock& getClock() const { return *_clock; }
/**
* Helper functions for components wanting to start a single thread.
@@ -183,18 +156,7 @@ public:
vespalib::duration maxProcessTime = vespalib::duration::zero(),
vespalib::duration waitTime = vespalib::duration::zero(),
int ticksBeforeWait = 1,
- std::optional<vespalib::CpuUsage::Category> cpu_category = std::nullopt);
-
- // Check upgrade flag settings. Note that this flag may change at any time.
- // Thus the results of these functions should not be cached.
- bool isUpgradingToMajorVersion() const
- { return (loadUpgradeFlag() == UPGRADING_TO_MAJOR_VERSION); }
- bool isUpgradingToMinorVersion() const
- { return (loadUpgradeFlag() == UPGRADING_TO_MINOR_VERSION); }
- bool isUpgradingFromMajorVersion() const
- { return (loadUpgradeFlag() == UPGRADING_FROM_MAJOR_VERSION); }
- bool isUpgradingFromMinorVersion() const
- { return (loadUpgradeFlag() == UPGRADING_FROM_MINOR_VERSION); }
+ std::optional<vespalib::CpuUsage::Category> cpu_category = std::nullopt) const;
void requestShutdown(vespalib::stringref reason);
diff --git a/storage/src/vespa/storageframework/generic/component/managedcomponent.h b/storage/src/vespa/storageframework/generic/component/managedcomponent.h
index 4cd142420cd..aba6d6bd4eb 100644
--- a/storage/src/vespa/storageframework/generic/component/managedcomponent.h
+++ b/storage/src/vespa/storageframework/generic/component/managedcomponent.h
@@ -27,46 +27,16 @@ struct MetricUpdateHook;
struct ThreadPool;
struct Clock;
-/**
- * The upgrade flags can be used to add forward/backward compatability. In most
- * cases, we can hopefully ignore this as next version is compatible. In some
- * cases the new version might need to avoid doing requests the old version
- * can't handle. In rare cases, the older version might have gotten some forward
- * compatability code added which it might need to activate during an upgrade.
- *
- * Note that these flags must be set in an application when an upgrade requiring
- * this is being performed. Upgrade docs should specify this if needed.
- */
-enum UpgradeFlags {
- // Indicates we're either not upgrading, or we're upgrading compatible
- // versions so we doesn't need any special handling.
- NO_UPGRADE_SPECIAL_HANDLING_ACTIVE,
- // The cluster is being upgraded to this major version. We might need to
- // send old type of messages to make older nodes understand what we send
- UPGRADING_TO_MAJOR_VERSION,
- // The cluster is being upgraded to this minor version. We might need to
- // send old type of messages to make older nodes understand what we send
- UPGRADING_TO_MINOR_VERSION,
- // The cluster is being upgraded to the next major version. We might
- // need to refrain from using functionality removed in the new version.
- UPGRADING_FROM_MAJOR_VERSION,
- // The cluster is being upgraded to the next minor version. We might
- // need to refrain from using functionality removed in the new version.
- UPGRADING_FROM_MINOR_VERSION
-};
-
struct ManagedComponent {
- virtual ~ManagedComponent() {}
+ virtual ~ManagedComponent() = default;
- virtual const vespalib::string& getName() const = 0;
+ [[nodiscard]] virtual const vespalib::string& getName() const = 0;
virtual metrics::Metric* getMetric() = 0;
- virtual std::pair<MetricUpdateHook*, SecondTime> getMetricUpdateHook() = 0;
virtual const StatusReporter* getStatusReporter() = 0;
virtual void setMetricRegistrator(MetricRegistrator&) = 0;
virtual void setClock(Clock&) = 0;
virtual void setThreadPool(ThreadPool&) = 0;
- virtual void setUpgradeFlag(UpgradeFlags flag) = 0;
virtual void open() = 0;
virtual void close() = 0;
diff --git a/storage/src/vespa/storageframework/generic/metric/metricregistrator.h b/storage/src/vespa/storageframework/generic/metric/metricregistrator.h
index 1129bf29e45..11ce53b3d5b 100644
--- a/storage/src/vespa/storageframework/generic/metric/metricregistrator.h
+++ b/storage/src/vespa/storageframework/generic/metric/metricregistrator.h
@@ -24,7 +24,7 @@ struct MetricRegistrator {
virtual ~MetricRegistrator() = default;
virtual void registerMetric(metrics::Metric&) = 0;
- virtual void registerUpdateHook(vespalib::stringref name, MetricUpdateHook& hook, SecondTime period) = 0;
+ virtual void registerUpdateHook(vespalib::stringref name, MetricUpdateHook& hook, vespalib::duration period) = 0;
};
}