summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-10-15 21:21:41 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-10-15 21:46:00 +0000
commit04dd145c9ac0b571c585d1728fa27391e8f1cea4 (patch)
treed746848c7ab8fe5bf59f06b081eaa7f1288293be /storage
parent4dd068249cf25874b95ec86eaebd870be371da34 (diff)
- Remove unused members.
- Use the same ServiceLayerComponent. - GC unused code.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/persistence/persistencetestutils.cpp2
-rw-r--r--storage/src/tests/persistence/persistencetestutils.h2
-rw-r--r--storage/src/vespa/storage/common/servicelayercomponent.h5
-rw-r--r--storage/src/vespa/storage/persistence/diskthread.h42
-rw-r--r--storage/src/vespa/storage/persistence/persistencethread.cpp11
-rw-r--r--storage/src/vespa/storage/persistence/persistencethread.h2
-rw-r--r--storage/src/vespa/storage/persistence/persistenceutil.cpp17
-rw-r--r--storage/src/vespa/storage/persistence/persistenceutil.h19
8 files changed, 27 insertions, 73 deletions
diff --git a/storage/src/tests/persistence/persistencetestutils.cpp b/storage/src/tests/persistence/persistencetestutils.cpp
index 67d148fb317..6eb7fb7fd04 100644
--- a/storage/src/tests/persistence/persistencetestutils.cpp
+++ b/storage/src/tests/persistence/persistencetestutils.cpp
@@ -55,7 +55,7 @@ PersistenceTestEnvironment::PersistenceTestEnvironment(const std::string & rootO
_node.setupDummyPersistence();
_metrics.initDiskMetrics(1, _node.getLoadTypes()->getMetricLoadTypes(), 1, 1);
_handler = std::make_unique<FileStorHandler>(_messageKeeper, _metrics, _node.getComponentRegister());
- _diskEnv = std::make_unique<PersistenceUtil>(_config.getConfigId(), _node.getComponentRegister(), *_handler,
+ _diskEnv = std::make_unique<PersistenceUtil>(_config.getConfigId(), _component, *_handler,
*_metrics.disks[0]->threads[0], _node.getPersistenceProvider());
}
diff --git a/storage/src/tests/persistence/persistencetestutils.h b/storage/src/tests/persistence/persistencetestutils.h
index a0ab516754a..65a7441847e 100644
--- a/storage/src/tests/persistence/persistencetestutils.h
+++ b/storage/src/tests/persistence/persistencetestutils.h
@@ -31,7 +31,7 @@ struct PersistenceTestEnvironment {
vdstestlib::DirConfig _config;
MessageKeeper _messageKeeper;
TestServiceLayerApp _node;
- StorageComponent _component;
+ ServiceLayerComponent _component;
FileStorMetrics _metrics;
std::unique_ptr<FileStorHandler> _handler;
std::unique_ptr<PersistenceUtil> _diskEnv;
diff --git a/storage/src/vespa/storage/common/servicelayercomponent.h b/storage/src/vespa/storage/common/servicelayercomponent.h
index 2308480411e..a75dacde1d8 100644
--- a/storage/src/vespa/storage/common/servicelayercomponent.h
+++ b/storage/src/vespa/storage/common/servicelayercomponent.h
@@ -36,7 +36,7 @@ class StorBucketDatabase;
struct ServiceLayerManagedComponent
{
- virtual ~ServiceLayerManagedComponent() {}
+ virtual ~ServiceLayerManagedComponent() = default;
virtual void setDiskCount(uint16_t count) = 0;
virtual void setBucketSpaceRepo(ContentBucketSpaceRepo&) = 0;
@@ -45,8 +45,7 @@ struct ServiceLayerManagedComponent
struct ServiceLayerComponentRegister : public virtual StorageComponentRegister
{
- virtual void registerServiceLayerComponent(
- ServiceLayerManagedComponent&) = 0;
+ virtual void registerServiceLayerComponent(ServiceLayerManagedComponent&) = 0;
};
class ServiceLayerComponent : public StorageComponent,
diff --git a/storage/src/vespa/storage/persistence/diskthread.h b/storage/src/vespa/storage/persistence/diskthread.h
index 926b766aca0..114257c38d4 100644
--- a/storage/src/vespa/storage/persistence/diskthread.h
+++ b/storage/src/vespa/storage/persistence/diskthread.h
@@ -12,11 +12,7 @@
*/
#pragma once
-#include <vespa/vespalib/util/printable.h>
-#include <vespa/vespalib/util/document_runnable.h>
-#include <vespa/config-stor-filestor.h>
#include <vespa/storageframework/generic/thread/runnable.h>
-#include <ostream>
namespace storage {
@@ -25,10 +21,6 @@ namespace framework {
class Thread;
}
-class Directory;
-class SlotFileOptions;
-struct FileStorThreadMetrics;
-
class DiskThread : public framework::Runnable
{
public:
@@ -37,39 +29,7 @@ public:
DiskThread(const DiskThread &) = delete;
DiskThread & operator = (const DiskThread &) = delete;
DiskThread() = default;
- virtual ~DiskThread() {}
-
- /**
- * Query filestorthread for its operation count.
- *
- * Count is increased for each operation (and rolls around). If you query
- * filestorthread, and count has not changed over a period of time that is
- * longer than a single operation should use, and shorter than
- * filestorthread can manage 2^32 operations, you can detect if the thread
- * is stuck.
- *
- * (No locking is used for this. We assume instance don't manage to get
- * partially updated to look exactly like the last retrieved entry)
- */
- struct OperationCount : public vespalib::Printable {
- uint32_t count;
- bool pending;
-
- OperationCount() : count(0), pending(false) {}
-
- void inc() { ++count; pending = true; }
- void done() { pending = false; }
-
- bool operator==(const OperationCount& c) const
- { return (count == c.count && pending == c.pending); }
-
- void print(std::ostream& out, bool, const std::string&) const override
- {
- out << "OperationCount(" << count << (pending ? ", pending" : "")
- << ")";
- }
- };
-
+ virtual ~DiskThread() = default;
/** Waits for current operation to be finished. */
virtual void flush() = 0;
diff --git a/storage/src/vespa/storage/persistence/persistencethread.cpp b/storage/src/vespa/storage/persistence/persistencethread.cpp
index fdafa92ed70..98270561a33 100644
--- a/storage/src/vespa/storage/persistence/persistencethread.cpp
+++ b/storage/src/vespa/storage/persistence/persistencethread.cpp
@@ -92,6 +92,11 @@ private:
vespalib::ISequencedTaskExecutor::ExecutorId _executorId;
};
+vespalib::string
+createThreadName(size_t stripeId) {
+ return vespalib::make_string("Thread %zu", stripeId);
+}
+
}
PersistenceThread::PersistenceThread(vespalib::ISequencedTaskExecutor & sequencedExecutor,
@@ -101,16 +106,14 @@ PersistenceThread::PersistenceThread(vespalib::ISequencedTaskExecutor & sequence
FileStorHandler& filestorHandler,
FileStorThreadMetrics& metrics)
: _stripeId(filestorHandler.getNextStripeId()),
- _env(configUri, compReg, filestorHandler, metrics, provider),
+ _component(std::make_unique<ServiceLayerComponent>(compReg, createThreadName(_stripeId))),
+ _env(configUri, *_component, filestorHandler, metrics, provider),
_sequencedExecutor(sequencedExecutor),
_spi(provider),
_processAllHandler(_env, provider),
_mergeHandler(_spi, _env),
_bucketOwnershipNotifier()
{
- std::ostringstream threadName;
- threadName << "Thread " << _stripeId;
- _component = std::make_unique<ServiceLayerComponent>(compReg, threadName.str());
_bucketOwnershipNotifier = std::make_unique<BucketOwnershipNotifier>(*_component, filestorHandler);
_thread = _component->startThread(*this, 60s, 1s);
}
diff --git a/storage/src/vespa/storage/persistence/persistencethread.h b/storage/src/vespa/storage/persistence/persistencethread.h
index 6643345353c..55e1fdc9ae6 100644
--- a/storage/src/vespa/storage/persistence/persistencethread.h
+++ b/storage/src/vespa/storage/persistence/persistencethread.h
@@ -48,12 +48,12 @@ public:
private:
uint32_t _stripeId;
+ ServiceLayerComponent::UP _component;
PersistenceUtil _env;
vespalib::ISequencedTaskExecutor & _sequencedExecutor;
spi::PersistenceProvider& _spi;
ProcessAllHandler _processAllHandler;
MergeHandler _mergeHandler;
- ServiceLayerComponent::UP _component;
framework::Thread::UP _thread;
std::unique_ptr<BucketOwnershipNotifier> _bucketOwnershipNotifier;
diff --git a/storage/src/vespa/storage/persistence/persistenceutil.cpp b/storage/src/vespa/storage/persistence/persistenceutil.cpp
index 24d91253358..083b15abe13 100644
--- a/storage/src/vespa/storage/persistence/persistenceutil.cpp
+++ b/storage/src/vespa/storage/persistence/persistenceutil.cpp
@@ -9,12 +9,6 @@ LOG_SETUP(".persistence.util");
namespace storage {
namespace {
- std::string generateName(void* p) {
- std::ostringstream ost;
- ost << "PersistenceUtil(" << p << ")";
- return ost.str();
- }
-
bool isBatchable(api::MessageType::Id id)
{
return (id == api::MessageType::PUT_ID ||
@@ -163,18 +157,17 @@ MessageTracker::generateReply(api::StorageCommand& cmd)
PersistenceUtil::PersistenceUtil(
const config::ConfigUri & configUri,
- ServiceLayerComponentRegister& compReg,
+ ServiceLayerComponent& component,
FileStorHandler& fileStorHandler,
FileStorThreadMetrics& metrics,
spi::PersistenceProvider& provider)
: _config(*config::ConfigGetter<vespa::config::content::StorFilestorConfig>::getConfig(configUri.getConfigId(), configUri.getContext())),
- _compReg(compReg),
- _component(compReg, generateName(this)),
+ _component(component),
_fileStorHandler(fileStorHandler),
- _nodeIndex(_component.getIndex()),
+ _nodeIndex(component.getIndex()),
_metrics(metrics),
- _bucketFactory(_component.getBucketIdFactory()),
- _repo(_component.getTypeRepo()->documentTypeRepo),
+ _bucketFactory(component.getBucketIdFactory()),
+ _repo(component.getTypeRepo()->documentTypeRepo),
_spi(provider)
{
}
diff --git a/storage/src/vespa/storage/persistence/persistenceutil.h b/storage/src/vespa/storage/persistence/persistenceutil.h
index fe475d96077..f2da4256ea0 100644
--- a/storage/src/vespa/storage/persistence/persistenceutil.h
+++ b/storage/src/vespa/storage/persistence/persistenceutil.h
@@ -88,26 +88,25 @@ private:
spi::Context _context;
PersistenceUtil &_env;
MessageSender &_replySender;
- FileStorThreadMetrics::Op *_metric;
+ FileStorThreadMetrics::Op *_metric; // needs a better and thread safe solution
api::StorageReply::SP _reply;
api::ReturnCode _result;
framework::MilliSecTimer _timer;
};
struct PersistenceUtil {
- vespa::config::content::StorFilestorConfig _config;
- ServiceLayerComponentRegister &_compReg;
- ServiceLayerComponent _component;
- FileStorHandler &_fileStorHandler;
- uint16_t _nodeIndex;
- FileStorThreadMetrics &_metrics;
- const document::BucketIdFactory &_bucketFactory;
+ vespa::config::content::StorFilestorConfig _config;
+ ServiceLayerComponent &_component;
+ FileStorHandler &_fileStorHandler;
+ uint16_t _nodeIndex;
+ FileStorThreadMetrics &_metrics; // Needs a better solution for speed and thread safety
+ const document::BucketIdFactory &_bucketFactory;
const std::shared_ptr<const document::DocumentTypeRepo> _repo;
- spi::PersistenceProvider& _spi;
+ spi::PersistenceProvider &_spi;
PersistenceUtil(
const config::ConfigUri&,
- ServiceLayerComponentRegister&,
+ ServiceLayerComponent&,
FileStorHandler& fileStorHandler,
FileStorThreadMetrics& metrics,
spi::PersistenceProvider& provider);