aboutsummaryrefslogtreecommitdiffstats
path: root/storageframework
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-04-04 16:35:02 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-04-04 16:36:18 +0200
commit9204052b04f33c47f62acb8d01161726268990d5 (patch)
tree49e0e9819bd9a73c316694d791b93700a694db92 /storageframework
parent31fa22ae90c6481c6e70eb2381d63ecc9b6c6d42 (diff)
Use override
Diffstat (limited to 'storageframework')
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp5
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.h7
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.h29
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.h9
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.h24
-rw-r--r--storageframework/src/vespa/storageframework/generic/component/component.h20
-rw-r--r--storageframework/src/vespa/storageframework/generic/status/htmlstatusreporter.h8
-rw-r--r--storageframework/src/vespa/storageframework/generic/status/httpurlpath.h7
-rw-r--r--storageframework/src/vespa/storageframework/generic/status/xmlstatusreporter.h16
-rw-r--r--storageframework/src/vespa/storageframework/generic/thread/thread.h5
-rw-r--r--storageframework/src/vespa/storageframework/generic/thread/tickingthread.cpp61
11 files changed, 79 insertions, 112 deletions
diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp
index 022e0fa54fa..125e01db179 100644
--- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp
+++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp
@@ -74,6 +74,11 @@ MemoryState::MemoryState(Clock& clock, uint64_t maxMemory)
{
}
+MemoryState::MemoryState(const MemoryState &) = default;
+MemoryState & MemoryState::operator = (const MemoryState &) = default;
+
+MemoryState::~MemoryState() {}
+
void
MemoryState::addToEntry(const MemoryAllocationType& type, uint64_t memory,
uint8_t priority,
diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.h b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.h
index e84e864d435..4cbc4da1ac5 100644
--- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.h
+++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.h
@@ -8,7 +8,7 @@
#pragma once
-#include <vespa/storageframework/defaultimplementation/memory/memorymanager.h>
+#include "memorymanager.h"
#include <vespa/storageframework/storageframework.h>
#include <vespa/vespalib/util/sync.h>
@@ -102,6 +102,11 @@ private:
public:
MemoryState(Clock& clock, uint64_t maxMemory);
+ MemoryState(const MemoryState &);
+ MemoryState & operator = (const MemoryState &);
+ MemoryState(MemoryState &&) = default;
+ MemoryState & operator = (MemoryState &&) = default;
+ ~MemoryState();
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.h b/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.h
index 870d735b113..43669eac603 100644
--- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.h
+++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.h
@@ -11,10 +11,10 @@
#pragma once
-#include <map>
#include <vespa/storageframework/generic/memory/memorymanagerinterface.h>
#include <vespa/vespalib/util/printable.h>
#include <vespa/vespalib/util/sync.h>
+#include <map>
namespace storage {
namespace framework {
@@ -29,9 +29,8 @@ public:
SimpleMemoryTokenImpl & operator = (const SimpleMemoryTokenImpl &) = delete;
SimpleMemoryTokenImpl(uint64_t allocated) : _allocated(allocated) {}
- virtual uint64_t getSize() const { return _allocated; }
- virtual bool resize(uint64_t /* min */, uint64_t max)
- { _allocated = max; return true; }
+ uint64_t getSize() const override { return _allocated; }
+ bool resize(uint64_t /* min */, uint64_t max) override { _allocated = max; return true; }
};
class NoMemoryManager : public MemoryManagerInterface
@@ -42,29 +41,21 @@ class NoMemoryManager : public MemoryManagerInterface
public:
typedef std::unique_ptr<NoMemoryManager> UP;
- virtual void setMaximumMemoryUsage(uint64_t) {}
-
- virtual const MemoryAllocationType&
- registerAllocationType(const MemoryAllocationType& type);
-
- virtual const MemoryAllocationType&
- getAllocationType(const std::string& name) const;
+ void setMaximumMemoryUsage(uint64_t) override {}
+ const MemoryAllocationType & registerAllocationType(const MemoryAllocationType& type) override;
+ const MemoryAllocationType & getAllocationType(const std::string& name) const override;
- MemoryToken::UP allocate(
- const MemoryAllocationType&,
- uint64_t /* min */,
- uint64_t max,
- uint8_t /* priority */,
- ReduceMemoryUsageInterface* = 0)
+ MemoryToken::UP allocate(const MemoryAllocationType&, uint64_t /* min */, uint64_t max,
+ uint8_t /* priority */, ReduceMemoryUsageInterface* = 0) override
{
return SimpleMemoryTokenImpl::UP(new SimpleMemoryTokenImpl(max));
}
- virtual uint64_t getMemorySizeFreeForPriority(uint8_t priority) const {
+ uint64_t getMemorySizeFreeForPriority(uint8_t priority) const override {
(void) priority;
return std::numeric_limits<uint64_t>().max();
}
- virtual std::vector<const MemoryAllocationType*> getAllocationTypes() const;
+ std::vector<const MemoryAllocationType*> getAllocationTypes() const override;
};
} // defaultimplementation
diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.h b/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.h
index 0761603a324..c43d6ef7fa9 100644
--- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.h
+++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.h
@@ -9,7 +9,7 @@
#pragma once
-#include <vespa/storageframework/defaultimplementation/memory/simplememorylogic.h>
+#include "simplememorylogic.h"
#include <vespa/vespalib/util/sync.h>
namespace storage {
@@ -19,11 +19,8 @@ namespace defaultimplementation {
struct PriorityMemoryLogic : public SimpleMemoryLogic
{
PriorityMemoryLogic(Clock&, uint64_t maxMemory);
-
- virtual float getNonCacheThreshold(uint8_t priority) const;
-
- virtual void print(std::ostream& out, bool verbose,
- const std::string& indent) const;
+ float getNonCacheThreshold(uint8_t priority) const override;
+ void print(std::ostream& out, bool verbose, const std::string& indent) const override;
};
} // defaultimplementation
diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.h b/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.h
index aafae3d6a21..5a8df6441f1 100644
--- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.h
+++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.h
@@ -21,8 +21,8 @@
#pragma once
-#include <vespa/storageframework/defaultimplementation/memory/memorymanager.h>
-#include <vespa/storageframework/defaultimplementation/memory/memorystate.h>
+#include "memorymanager.h"
+#include "memorystate.h"
#include <vespa/vespalib/util/sync.h>
namespace storage {
@@ -64,26 +64,22 @@ public:
return *this;
}
- virtual void setMaximumMemoryUsage(uint64_t max);
+ void setMaximumMemoryUsage(uint64_t max) override;
void setCacheThreshold(float limit) { _cacheThreshold = limit; }
void setNonCacheThreshold(float limit) { _nonCacheThreshold = limit; }
MemoryState& getState() { return _state; } // Not threadsafe. Unit testing.
+ void getState(MemoryState& state, bool resetMax) override;
- virtual void getState(MemoryState& state, bool resetMax);
+ MemoryToken::UP allocate(const MemoryAllocationType&, uint8_t priority,
+ ReduceMemoryUsageInterface* = 0) override;
+ bool resize(MemoryToken& token, uint64_t min, uint64_t max, uint32_t allocationCounts) override;
- virtual MemoryToken::UP allocate(const MemoryAllocationType&,
- uint8_t priority,
- ReduceMemoryUsageInterface* = 0);
- virtual bool resize(MemoryToken& token, uint64_t min, uint64_t max,
- uint32_t allocationCounts);
-
- virtual void freeToken(MemoryTokenImpl& token);
- virtual void print(std::ostream& out, bool verbose,
- const std::string& indent) const;
+ void freeToken(MemoryTokenImpl& token) override;
+ void print(std::ostream& out, bool verbose, const std::string& indent) const override;
- virtual uint64_t getMemorySizeFreeForPriority(uint8_t priority) const;
+ virtual uint64_t getMemorySizeFreeForPriority(uint8_t priority) const override;
private:
void handleReduction(MemoryTokenImpl&, uint64_t size,
diff --git a/storageframework/src/vespa/storageframework/generic/component/component.h b/storageframework/src/vespa/storageframework/generic/component/component.h
index 5f55bb30397..5ce86292f7d 100644
--- a/storageframework/src/vespa/storageframework/generic/component/component.h
+++ b/storageframework/src/vespa/storageframework/generic/component/component.h
@@ -67,7 +67,7 @@
*/
#pragma once
-#include <vespa/storageframework/generic/component/managedcomponent.h>
+#include "managedcomponent.h"
#include <vespa/storageframework/generic/thread/runnable.h>
#include <vespa/storageframework/generic/thread/thread.h>
#include <vespa/storageframework/generic/clock/clock.h>
@@ -107,17 +107,17 @@ class Component : private ManagedComponent
// ManagedComponent implementation
metrics::Metric* getMetric() override { return _metric; }
std::pair<MetricUpdateHook*, SecondTime> getMetricUpdateHook() override { return _metricUpdateHook; }
- const StatusReporter* getStatusReporter() { return _status; }
- void setMetricRegistrator(MetricRegistrator& mr);
- void setMemoryManager(MemoryManagerInterface& mm) { _memoryManager = &mm; }
- void setClock(Clock& c) { _clock = &c; }
- void setThreadPool(ThreadPool& tp) { _threadPool = &tp; }
- void setUpgradeFlag(UpgradeFlags flag) {
+ const StatusReporter* getStatusReporter() override { return _status; }
+ void setMetricRegistrator(MetricRegistrator& mr) override;
+ void setMemoryManager(MemoryManagerInterface& mm) override { _memoryManager = &mm; }
+ void setClock(Clock& c) override { _clock = &c; }
+ void setThreadPool(ThreadPool& tp) override { _threadPool = &tp; }
+ void setUpgradeFlag(UpgradeFlags flag) override {
assert(_upgradeFlag.is_lock_free());
_upgradeFlag.store(flag, std::memory_order_relaxed);
}
- void open();
- void close();
+ void open() override;
+ void close() override;
public:
typedef std::unique_ptr<Component> UP;
@@ -164,7 +164,7 @@ public:
vespalib::MonitorGuard getMetricManagerLock();
/** Get the name of the component. Must be a unique name. */
- const vespalib::string& getName() const { return _name; }
+ const vespalib::string& getName() const override { return _name; }
/**
* Get the thread pool for this application. Note that this call will fail
diff --git a/storageframework/src/vespa/storageframework/generic/status/htmlstatusreporter.h b/storageframework/src/vespa/storageframework/generic/status/htmlstatusreporter.h
index c76ec879121..fb9248a97b9 100644
--- a/storageframework/src/vespa/storageframework/generic/status/htmlstatusreporter.h
+++ b/storageframework/src/vespa/storageframework/generic/status/htmlstatusreporter.h
@@ -16,7 +16,7 @@
#pragma once
-#include <vespa/storageframework/generic/status/statusreporter.h>
+#include "statusreporter.h"
namespace storage {
namespace framework {
@@ -46,8 +46,8 @@ struct HtmlStatusReporter : public StatusReporter {
virtual void reportHtmlFooter(std::ostream&, const HttpUrlPath&) const;
// Implementation of StatusReporter interface
- virtual vespalib::string getReportContentType(const HttpUrlPath&) const;
- virtual bool reportStatus(std::ostream&, const HttpUrlPath&) const;
+ vespalib::string getReportContentType(const HttpUrlPath&) const override;
+ bool reportStatus(std::ostream&, const HttpUrlPath&) const override;
};
/**
@@ -59,7 +59,7 @@ struct PartlyHtmlStatusReporter : public HtmlStatusReporter {
PartlyHtmlStatusReporter(const StatusReporter& main)
: HtmlStatusReporter(main.getId(), main.getName()) {}
- virtual void reportHtmlStatus(std::ostream&, const HttpUrlPath&) const {}
+ void reportHtmlStatus(std::ostream&, const HttpUrlPath&) const override {}
};
} // framework
diff --git a/storageframework/src/vespa/storageframework/generic/status/httpurlpath.h b/storageframework/src/vespa/storageframework/generic/status/httpurlpath.h
index f73fdc752ed..8c8c24c29dd 100644
--- a/storageframework/src/vespa/storageframework/generic/status/httpurlpath.h
+++ b/storageframework/src/vespa/storageframework/generic/status/httpurlpath.h
@@ -10,7 +10,6 @@
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/text/stringtokenizer.h>
#include <map>
-#include <string>
namespace storage {
namespace framework {
@@ -43,15 +42,13 @@ public:
template<typename T>
T get(const vespalib::string& id, const T& defaultValue = T()) const;
- virtual void print(std::ostream& out, bool verbose,
- const std::string& indent) const;
+ void print(std::ostream& out, bool verbose, const std::string& indent) const override;
};
template<typename T>
T HttpUrlPath::get(const vespalib::string& id, const T& defaultValue) const
{
- std::map<vespalib::string, vespalib::string>::const_iterator it
- = _attributes.find(id);
+ std::map<vespalib::string, vespalib::string>::const_iterator it = _attributes.find(id);
if (it == _attributes.end()) return defaultValue;
T val;
std::istringstream ist(it->second);
diff --git a/storageframework/src/vespa/storageframework/generic/status/xmlstatusreporter.h b/storageframework/src/vespa/storageframework/generic/status/xmlstatusreporter.h
index 0516989aaac..98002bf1113 100644
--- a/storageframework/src/vespa/storageframework/generic/status/xmlstatusreporter.h
+++ b/storageframework/src/vespa/storageframework/generic/status/xmlstatusreporter.h
@@ -17,12 +17,9 @@
#pragma once
-#include <vespa/storageframework/generic/status/statusreporter.h>
+#include "statusreporter.h"
#include <vespa/vespalib/util/xmlserializable.h>
-namespace vespalib {
-}
-
namespace storage {
namespace framework {
@@ -43,8 +40,8 @@ struct XmlStatusReporter : public StatusReporter {
const HttpUrlPath&) const;
// Implementation of status reporter interface
- virtual vespalib::string getReportContentType(const HttpUrlPath&) const;
- virtual bool reportStatus(std::ostream&, const HttpUrlPath&) const;
+ vespalib::string getReportContentType(const HttpUrlPath&) const override;
+ bool reportStatus(std::ostream&, const HttpUrlPath&) const override;
};
/**
@@ -71,12 +68,7 @@ public:
}
vespalib::XmlOutputStream& getStream() { return _xos; }
-
- virtual vespalib::string reportXmlStatus(vespalib::xml::XmlOutputStream&,
- const HttpUrlPath&) const
- {
- return "";
- }
+ vespalib::string reportXmlStatus(vespalib::xml::XmlOutputStream&, const HttpUrlPath&) const override { return ""; }
template<typename T>
PartlyXmlStatusReporter& operator<<(const T& v) {
diff --git a/storageframework/src/vespa/storageframework/generic/thread/thread.h b/storageframework/src/vespa/storageframework/generic/thread/thread.h
index e30e9b10404..a40a209e980 100644
--- a/storageframework/src/vespa/storageframework/generic/thread/thread.h
+++ b/storageframework/src/vespa/storageframework/generic/thread/thread.h
@@ -12,9 +12,8 @@
*/
#pragma once
-#include <memory>
+#include "runnable.h"
#include <vespa/vespalib/stllike/string.h>
-#include <vespa/storageframework/generic/thread/runnable.h>
namespace vespalib {
class Monitor;
@@ -35,7 +34,7 @@ public:
virtual const vespalib::string& getId() const { return _id; }
/** Check whether thread have been interrupted or not. */
- virtual bool interrupted() const = 0;
+ virtual bool interrupted() const override = 0;
/** Check whether thread have been joined or not. */
virtual bool joined() const = 0;
diff --git a/storageframework/src/vespa/storageframework/generic/thread/tickingthread.cpp b/storageframework/src/vespa/storageframework/generic/thread/tickingthread.cpp
index d425ff3a1d8..3b6d561b01f 100644
--- a/storageframework/src/vespa/storageframework/generic/thread/tickingthread.cpp
+++ b/storageframework/src/vespa/storageframework/generic/thread/tickingthread.cpp
@@ -1,12 +1,8 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/storageframework/generic/thread/tickingthread.h>
-#include <atomic>
-#include <vespa/log/log.h>
-#include <sstream>
-#include <vespa/storageframework/generic/thread/threadpool.h>
+#include "tickingthread.h"
+#include "threadpool.h"
#include <vespa/vespalib/util/exceptions.h>
-
-LOG_SETUP(".framework.thread.ticker");
+#include <vespa/vespalib/stllike/asciistream.h>
namespace storage {
namespace framework {
@@ -64,7 +60,7 @@ public:
char getState() const { return _state; }
private:
- virtual void run(ThreadHandle& handle) {
+ void run(ThreadHandle& handle) override {
ThreadWaitInfo info = ThreadWaitInfo::MORE_WORK_ENQUEUED;
CycleType cycle = PROCESS_CYCLE;
int ticksExecutedAfterWait = 0;
@@ -117,26 +113,21 @@ class TickingThreadPoolImpl : public TickingThreadPool {
struct FreezeGuard : public TickingLockGuard::Impl {
TickingThreadPoolImpl& _pool;
- FreezeGuard(TickingThreadPoolImpl& pool)
- : _pool(pool) { _pool.freeze(); }
-
- virtual ~FreezeGuard() { _pool.thaw(); }
-
- virtual void broadcast() {}
+ FreezeGuard(TickingThreadPoolImpl& pool) : _pool(pool) { _pool.freeze(); }
+ ~FreezeGuard() { _pool.thaw(); }
+ void broadcast() override {}
};
struct CriticalGuard : public TickingLockGuard::Impl {
vespalib::MonitorGuard _guard;
CriticalGuard(vespalib::Monitor& m) : _guard(m) {}
- virtual void broadcast() { _guard.broadcast(); }
+ void broadcast() override { _guard.broadcast(); }
};
public:
- TickingThreadPoolImpl(vespalib::stringref name,
- MilliSecTime waitTime,
- int ticksBeforeWait,
- MilliSecTime maxProcessTime)
+ TickingThreadPoolImpl(vespalib::stringref name, MilliSecTime waitTime,
+ int ticksBeforeWait, MilliSecTime maxProcessTime)
: _name(name),
_waitTime(waitTime.getTime()),
_ticksBeforeWait(ticksBeforeWait),
@@ -146,36 +137,31 @@ public:
stop();
}
- virtual void updateParametersAllThreads(
- MilliSecTime waitTime,
- MilliSecTime maxProcessTime,
- int ticksBeforeWait) {
+ void updateParametersAllThreads(MilliSecTime waitTime, MilliSecTime maxProcessTime,
+ int ticksBeforeWait) override {
_waitTime.store(waitTime.getTime());
_maxProcessTime.store(maxProcessTime.getTime());
_ticksBeforeWait.store(ticksBeforeWait);
// TODO: Add locking so threads not deleted while updating
- for (uint32_t i=0; i<_threads.size(); ++i) {
- _threads[i]->updateParameters(waitTime.getTime(),
- maxProcessTime.getTime(),
- ticksBeforeWait);
+ for (uint32_t i=0; i<_threads.size(); ++i) {
+ _threads[i]->updateParameters(waitTime.getTime(), maxProcessTime.getTime(), ticksBeforeWait);
}
}
- void addThread(TickingThread& ticker) {
+ void addThread(TickingThread& ticker) override {
ThreadIndex index = _tickers.size();
ticker.newThreadCreated(index);
- _tickers.push_back(TickingThreadRunner::SP(
- new TickingThreadRunner(_monitor, ticker, index)));
+ _tickers.push_back(TickingThreadRunner::SP(new TickingThreadRunner(_monitor, ticker, index)));
}
- void start(ThreadPool& pool) {
+ void start(ThreadPool& pool) override {
if (_tickers.empty()) {
throw vespalib::IllegalStateException(
"Makes no sense to start threadpool without threads",
VESPA_STRLOC);
}
for (uint32_t i=0; i<_tickers.size(); ++i) {
- std::ostringstream ost;
+ vespalib::asciistream ost;
ost << _name.c_str() << " thread " << i;
_threads.push_back(std::shared_ptr<Thread>(pool.startThread(
*_tickers[i],
@@ -186,17 +172,16 @@ public:
}
}
- virtual TickingLockGuard freezeAllTicks() {
- return TickingLockGuard(std::unique_ptr<TickingLockGuard::Impl>(
- new FreezeGuard(*this)));
+ TickingLockGuard freezeAllTicks() override {
+ return TickingLockGuard(std::unique_ptr<TickingLockGuard::Impl>(new FreezeGuard(*this)));
}
- virtual TickingLockGuard freezeCriticalTicks() {
+ TickingLockGuard freezeCriticalTicks() override {
return TickingLockGuard(std::unique_ptr<TickingLockGuard::Impl>(
new CriticalGuard(_monitor)));
}
- void stop() {
+ void stop() override {
for (uint32_t i=0; i<_threads.size(); ++i) {
_threads[i]->interrupt();
}
@@ -209,7 +194,7 @@ public:
}
}
- vespalib::string getStatus() {
+ vespalib::string getStatus() override {
vespalib::string result(_tickers.size(), ' ');
for (uint32_t i=0, n=_tickers.size(); i<n; ++i) {
result[i] = _tickers[i]->getState();