summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-11-26 11:06:01 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-11-26 11:27:06 +0000
commit8236c60ded3e9ae63363750851fd89359d286a01 (patch)
treeaa7b014749b21d94b3a3cf24c88be06e5dc60d7f /searchcore
parentc07824476253a07219cac5821e768ece213e8d5a (diff)
Remove the need for Syncable
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp3
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.h3
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp34
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton_configurer.h23
-rw-r--r--searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h2
8 files changed, 46 insertions, 27 deletions
diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
index e3e6ac6321e..b80cd08ae8e 100644
--- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
@@ -234,8 +234,7 @@ MySearchableContext::MySearchableContext(IThreadingService &writeService,
IBucketDBHandlerInitializer & bucketDBHandlerInitializer)
: _fastUpdCtx(writeService, bucketDB, bucketDBHandlerInitializer),
_queryLimiter(), _clock(),
- _ctx(_fastUpdCtx._ctx, _queryLimiter,
- _clock, dynamic_cast<vespalib::SyncableThreadExecutor &>(writeService.shared()))
+ _ctx(_fastUpdCtx._ctx, _queryLimiter, _clock, writeService.shared())
{}
MySearchableContext::~MySearchableContext() = default;
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
index 4eaa722e0ba..632f4482654 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
@@ -119,7 +119,7 @@ public:
/**
* Returns the underlying executor. Only used for state explorers.
*/
- const vespalib::SyncableThreadExecutor& get_executor() const { return _executor; }
+ const vespalib::ThreadExecutor& get_executor() const { return _executor; }
/**
* Starts the scheduling thread of this manager.
diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h
index 7cc0c97048b..3d3be775a4a 100644
--- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h
+++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h
@@ -69,7 +69,7 @@ public:
/**
* Returns the underlying executor. Only used for state explorers.
*/
- const vespalib::SyncableThreadExecutor& get_executor() const { return _executor; }
+ const vespalib::ThreadExecutor& get_executor() const { return _executor; }
/**
* Closes the request handler interface. This will prevent any more data
diff --git a/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h b/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h
index 0d6bb07b173..704b54dc566 100644
--- a/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h
+++ b/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h
@@ -6,8 +6,6 @@
#include <vespa/vespalib/stllike/string.h>
#include <memory>
-namespace vespalib { class ThreadStackExecutorBase; }
-
namespace proton {
class DocumentDBConfigOwner;
@@ -19,7 +17,7 @@ class DocumentDBConfigOwner;
class IProtonConfigurerOwner
{
public:
- using InitializeThreads = std::shared_ptr<vespalib::SyncableThreadExecutor>;
+ using InitializeThreads = std::shared_ptr<vespalib::ThreadExecutor>;
virtual ~IProtonConfigurerOwner() { }
virtual std::shared_ptr<DocumentDBConfigOwner> addDocumentDB(const DocTypeName &docTypeName,
document::BucketSpace bucketSpace,
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h
index 6fd31352051..fffc16089fa 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.h
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.h
@@ -58,8 +58,7 @@ private:
using MonitorReply = search::engine::MonitorReply;
using MonitorClient = search::engine::MonitorClient;
using DocumentDBMap = std::map<DocTypeName, DocumentDB::SP>;
- using ProtonConfigSP = BootstrapConfig::ProtonConfigSP;
- using InitializeThreads = std::shared_ptr<vespalib::SyncableThreadExecutor>;
+ using InitializeThreads = std::shared_ptr<vespalib::ThreadExecutor>;
using BucketSpace = document::BucketSpace;
class ProtonFileHeaderContext : public search::common::FileHeaderContext
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp
index 7c998ceca7c..25918d32049 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp
@@ -42,7 +42,7 @@ getBucketSpace(const BootstrapConfig &bootstrapConfig, const DocTypeName &name)
}
-ProtonConfigurer::ProtonConfigurer(vespalib::SyncableThreadExecutor &executor,
+ProtonConfigurer::ProtonConfigurer(vespalib::ThreadExecutor &executor,
IProtonConfigurerOwner &owner,
const std::unique_ptr<IProtonDiskLayout> &diskLayout)
: IProtonConfigurer(),
@@ -54,13 +54,30 @@ ProtonConfigurer::ProtonConfigurer(vespalib::SyncableThreadExecutor &executor,
_mutex(),
_allowReconfig(false),
_componentConfig(),
- _diskLayout(diskLayout)
+ _diskLayout(diskLayout),
+ _pendingReconfigureTasks(0)
{
}
-ProtonConfigurer::~ProtonConfigurer()
-{
-}
+class ProtonConfigurer::ReconfigureTask : public vespalib::Executor::Task {
+public:
+ ReconfigureTask(ProtonConfigurer & configurer)
+ : _configurer(configurer)
+ {
+ _configurer._pendingReconfigureTasks++;
+ }
+ ~ReconfigureTask() {
+ _configurer._pendingReconfigureTasks--;
+ }
+
+ void run() override {
+ _configurer.performReconfigure();
+ }
+private:
+ ProtonConfigurer & _configurer;
+};
+
+ProtonConfigurer::~ProtonConfigurer() = default;
void
ProtonConfigurer::setAllowReconfig(bool allowReconfig)
@@ -76,7 +93,10 @@ ProtonConfigurer::setAllowReconfig(bool allowReconfig)
}
}
if (!allowReconfig) {
- _executor.sync(); // drain queued performReconfigure tasks
+ // drain queued performReconfigure tasks
+ while ( _pendingReconfigureTasks > 0) {
+ std::this_thread::sleep_for(1ms);
+ }
}
}
@@ -102,7 +122,7 @@ ProtonConfigurer::reconfigure(std::shared_ptr<ProtonConfigSnapshot> configSnapsh
std::lock_guard<std::mutex> guard(_mutex);
_pendingConfigSnapshot = configSnapshot;
if (_allowReconfig) {
- _executor.execute(makeLambdaTask([&]() { performReconfigure(); }));
+ _executor.execute(std::make_unique<ReconfigureTask>(*this));
}
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h
index 3ebfbc378d7..b59af6c347a 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h
+++ b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h
@@ -9,6 +9,7 @@
#include <vespa/vespalib/net/simple_component_config_producer.h>
#include <map>
#include <mutex>
+#include <atomic>
namespace proton {
@@ -25,17 +26,19 @@ class IProtonDiskLayout;
class ProtonConfigurer : public IProtonConfigurer
{
using DocumentDBs = std::map<DocTypeName, std::pair<std::weak_ptr<IDocumentDBConfigOwner>, std::weak_ptr<DocumentDBDirectoryHolder>>>;
- using InitializeThreads = std::shared_ptr<vespalib::SyncableThreadExecutor>;
+ using InitializeThreads = std::shared_ptr<vespalib::ThreadExecutor>;
+ class ReconfigureTask;
- SyncableExecutorThreadService _executor;
- IProtonConfigurerOwner &_owner;
- DocumentDBs _documentDBs;
- std::shared_ptr<ProtonConfigSnapshot> _pendingConfigSnapshot;
- std::shared_ptr<ProtonConfigSnapshot> _activeConfigSnapshot;
- mutable std::mutex _mutex;
- bool _allowReconfig;
- vespalib::SimpleComponentConfigProducer _componentConfig;
+ ExecutorThreadService _executor;
+ IProtonConfigurerOwner &_owner;
+ DocumentDBs _documentDBs;
+ std::shared_ptr<ProtonConfigSnapshot> _pendingConfigSnapshot;
+ std::shared_ptr<ProtonConfigSnapshot> _activeConfigSnapshot;
+ mutable std::mutex _mutex;
+ bool _allowReconfig;
+ vespalib::SimpleComponentConfigProducer _componentConfig;
const std::unique_ptr<IProtonDiskLayout> &_diskLayout;
+ std::atomic<uint64_t> _pendingReconfigureTasks;
void performReconfigure();
bool skipConfig(const ProtonConfigSnapshot *configSnapshot, bool initialConfig);
@@ -48,7 +51,7 @@ class ProtonConfigurer : public IProtonConfigurer
void pruneInitialDocumentDBDirs(const ProtonConfigSnapshot &configSnapshot);
public:
- ProtonConfigurer(vespalib::SyncableThreadExecutor &executor,
+ ProtonConfigurer(vespalib::ThreadExecutor &executor,
IProtonConfigurerOwner &owner,
const std::unique_ptr<IProtonDiskLayout> &diskLayout);
diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h
index 7f6d9328491..c49649de1e3 100644
--- a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h
+++ b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h
@@ -72,7 +72,7 @@ public:
/**
* Returns the underlying executor. Only used for state explorers.
*/
- const vespalib::SyncableThreadExecutor& get_executor() const { return _executor; }
+ const vespalib::ThreadExecutor& get_executor() const { return _executor; }
/**
* Starts the underlying threads. This will throw a vespalib::Exception if