diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-11-21 10:48:54 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-11-21 10:48:54 +0000 |
commit | 7f91170b182d44fd36b1ccf1653243a5057ed824 (patch) | |
tree | 9e054fe069ba0b0c7352c33f216f3f4b708845bc /metrics/src | |
parent | 63329e6242f302cb361b7548573bafe858360fa7 (diff) |
Implement assigValues in .cpp file
Diffstat (limited to 'metrics/src')
-rw-r--r-- | metrics/src/tests/loadmetrictest.cpp | 12 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/metric.cpp | 9 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/metric.h | 15 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/metricset.cpp | 3 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/metricset.h | 12 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/metricsnapshot.cpp | 2 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/metricsnapshot.h | 2 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/summetric.h | 2 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/summetric.hpp | 1 |
9 files changed, 27 insertions, 31 deletions
diff --git a/metrics/src/tests/loadmetrictest.cpp b/metrics/src/tests/loadmetrictest.cpp index ff4658d6bb2..d14595b3044 100644 --- a/metrics/src/tests/loadmetrictest.cpp +++ b/metrics/src/tests/loadmetrictest.cpp @@ -62,14 +62,11 @@ namespace { { } - MetricSet* clone(std::vector<Metric::LP>& ownerList, - CopyType copyType, - MetricSet* owner, - bool includeUnused = false) const + MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet* owner, bool includeUnused = false) const override { if (copyType != CLONE) { - return MetricSet::clone(ownerList, copyType, owner, - includeUnused); + return MetricSet::clone(ownerList, copyType, owner, includeUnused); } MyMetricSet * myset = new MyMetricSet(owner); myset->assignValues(*this); @@ -89,8 +86,7 @@ LoadMetricTest::testClone(Metric::CopyType copyType) metric[loadTypes["foo"]].metric.addValue(5); std::vector<Metric::LP> ownerList; - MetricSet::UP copy(dynamic_cast<MetricSet*>( - top.clone(ownerList, copyType, 0, true))); + MetricSet::UP copy(dynamic_cast<MetricSet*>(top.clone(ownerList, copyType, 0, true))); CPPUNIT_ASSERT(copy.get()); std::string expected = diff --git a/metrics/src/vespa/metrics/metric.cpp b/metrics/src/vespa/metrics/metric.cpp index dbb58882670..29fe973a193 100644 --- a/metrics/src/vespa/metrics/metric.cpp +++ b/metrics/src/vespa/metrics/metric.cpp @@ -234,4 +234,13 @@ Metric::printDebug(std::ostream& out, const std::string& indent) const << ", owner=" << ((const void*) _owner); } +Metric* +Metric::assignValues(const Metric& m) { + std::vector<Metric::LP> ownerList; + const_cast<Metric&>(m).addToSnapshot(*this, ownerList); + // As this should only be called among active metrics, all metrics + // should exist and owner list should thus always end up empty. + assert(ownerList.empty()); + return this; +} } // metrics diff --git a/metrics/src/vespa/metrics/metric.h b/metrics/src/vespa/metrics/metric.h index 850d712ebf5..959c9bd2411 100644 --- a/metrics/src/vespa/metrics/metric.h +++ b/metrics/src/vespa/metrics/metric.h @@ -161,14 +161,7 @@ public: * addToSnapshot, which should not alter source if reset is false. This can * not be used to copy between active metrics and inactive copies. */ - virtual Metric* assignValues(const Metric& m) { - std::vector<Metric::LP> ownerList; - const_cast<Metric&>(m).addToSnapshot(*this, ownerList); - // As this should only be called among active metrics, all metrics - // should exist and owner list should thus always end up empty. - assert(ownerList.empty()); - return this; - } + virtual Metric* assignValues(const Metric& m); /** Reset all metric values. */ virtual void reset() = 0; @@ -207,8 +200,7 @@ public: * @param ownerList In case snapshot doesn't contain given metric, it can * create them and add them to ownerlist. */ - virtual void addToSnapshot(Metric& m, - std::vector<Metric::LP>& ownerList) const = 0; + virtual void addToSnapshot(Metric& m, std::vector<Metric::LP>& ownerList) const = 0; /** * For sum metrics to work with metric sets, metric sets need operator+=. @@ -224,8 +216,7 @@ public: */ virtual void addToPart(Metric& m) const = 0; - virtual bool visit(MetricVisitor& visitor, - bool tagAsAutoGenerated = false) const = 0; + virtual bool visit(MetricVisitor& visitor, bool tagAsAutoGenerated = false) const = 0; /** Used by sum metric to alter name of cloned metric for sum. */ void setName(const String& name) { _name = name; } diff --git a/metrics/src/vespa/metrics/metricset.cpp b/metrics/src/vespa/metrics/metricset.cpp index 96bd87c7102..d22eb9d6af9 100644 --- a/metrics/src/vespa/metrics/metricset.cpp +++ b/metrics/src/vespa/metrics/metricset.cpp @@ -232,8 +232,7 @@ MetricSet::addTo(Metric& other, std::vector<Metric::LP>* ownerList) const if (target == map2.end() || source->first < target->first) { // Source missing in snapshot to add to. Lets create and add. if (!mustAdd && source->second->used()) { - Metric::LP copy(source->second->clone( - *ownerList, INACTIVE, &o)); + Metric::LP copy(source->second->clone(*ownerList, INACTIVE, &o)); ownerList->push_back(copy); newMetrics[source->first] = copy.get(); } diff --git a/metrics/src/vespa/metrics/metricset.h b/metrics/src/vespa/metrics/metricset.h index 47a29deda34..67c7981e8d0 100644 --- a/metrics/src/vespa/metrics/metricset.h +++ b/metrics/src/vespa/metrics/metricset.h @@ -52,19 +52,17 @@ public: void registerMetric(Metric& m); void unregisterMetric(Metric& m); - virtual MetricSet* clone(std::vector<Metric::LP>& ownerList, - CopyType type, MetricSet* owner, - bool includeUnused = false) const + MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType type, + MetricSet* owner, bool includeUnused = false) const override { return new MetricSet(*this, ownerList, type, owner, includeUnused); } void reset(); - virtual bool visit(MetricVisitor&, bool tagAsAutoGenerated = false) const; + bool visit(MetricVisitor&, bool tagAsAutoGenerated = false) const override; - virtual bool logEvent(const String& fullName) const; + bool logEvent(const String& fullName) const override; - virtual void print(std::ostream&, bool verbose, - const std::string& indent, uint64_t secondsPassed) const; + void print(std::ostream&, bool verbose, const std::string& indent, uint64_t secondsPassed) const override; // These should never be called on metrics set. virtual int64_t getLongValue(const stringref & id) const diff --git a/metrics/src/vespa/metrics/metricsnapshot.cpp b/metrics/src/vespa/metrics/metricsnapshot.cpp index fee30760f91..1f4457d3c21 100644 --- a/metrics/src/vespa/metrics/metricsnapshot.cpp +++ b/metrics/src/vespa/metrics/metricsnapshot.cpp @@ -35,6 +35,8 @@ MetricSnapshot::MetricSnapshot( trim(_metrics); } +MetricSnapshot::~MetricSnapshot() { } + void MetricSnapshot::reset(time_t currentTime) { diff --git a/metrics/src/vespa/metrics/metricsnapshot.h b/metrics/src/vespa/metrics/metricsnapshot.h index c10ec204a84..b6770d8d7e9 100644 --- a/metrics/src/vespa/metrics/metricsnapshot.h +++ b/metrics/src/vespa/metrics/metricsnapshot.h @@ -39,7 +39,7 @@ public: /** Create a snapshot of another metric source. */ MetricSnapshot(const Metric::String& name, uint32_t period, const MetricSet& source, bool copyUnset); - virtual ~MetricSnapshot() {} + virtual ~MetricSnapshot(); void addToSnapshot(MetricSnapshot& other, bool reset_, time_t currentTime) { _snapshot->addToSnapshot(other.getMetrics(), other._metrics); diff --git a/metrics/src/vespa/metrics/summetric.h b/metrics/src/vespa/metrics/summetric.h index cb213cc36c1..61a1d31e4f6 100644 --- a/metrics/src/vespa/metrics/summetric.h +++ b/metrics/src/vespa/metrics/summetric.h @@ -46,7 +46,7 @@ public: SumMetric(const SumMetric<AddendMetric>& other, std::vector<Metric::LP>& ownerList, MetricSet* owner = 0); ~SumMetric(); - virtual Metric* clone( std::vector<Metric::LP>&, CopyType, MetricSet* owner, bool includeUnused = false) const; + Metric* clone( std::vector<Metric::LP>&, CopyType, MetricSet* owner, bool includeUnused = false) const override; /** * If you want to support sums of collections of metrics that may diff --git a/metrics/src/vespa/metrics/summetric.hpp b/metrics/src/vespa/metrics/summetric.hpp index b881bb43f9a..6486afadc99 100644 --- a/metrics/src/vespa/metrics/summetric.hpp +++ b/metrics/src/vespa/metrics/summetric.hpp @@ -103,6 +103,7 @@ SumMetric<AddendMetric>::clone(std::vector<Metric::LP>& ownerList, { (void) includeUnused; if (_metricsToSum.empty() && _startValue.get() == 0) { + abort(); throw vespalib::IllegalStateException( "Attempted to clone sum metric without any children or start value. " "This is currently illegal, to avoid needing to be able to " |