diff options
author | Geir Storli <geirst@yahooinc.com> | 2023-01-31 15:35:31 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahooinc.com> | 2023-01-31 15:46:00 +0000 |
commit | d8665736bf00d9d635f3f950d3aa16ac222486b6 (patch) | |
tree | 66c1b7f9b7ad36cfb057f5c0c87bb2247b3e58f5 /searchcore | |
parent | ce4afff327e8effdd2ea1fef79292cb093c25709 (diff) |
Prepare for splitting DocumentDB reconfig into two phases.
Diffstat (limited to 'searchcore')
5 files changed, 98 insertions, 0 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt index c1f7b24b05c..34e2ee283f1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt @@ -19,6 +19,7 @@ vespa_add_library(searchcore_server STATIC document_db_explorer.cpp document_db_flush_config.cpp document_db_maintenance_config.cpp + document_db_reconfig.cpp document_meta_store_read_guards.cpp document_scan_iterator.cpp document_subdb_collection_explorer.cpp @@ -26,6 +27,7 @@ vespa_add_library(searchcore_server STATIC document_subdb_explorer.cpp document_subdb_initializer.cpp document_subdb_initializer_result.cpp + document_subdb_reconfig.cpp documentbucketmover.cpp documentdb.cpp documentdb_metrics_updater.cpp diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.cpp b/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.cpp new file mode 100644 index 00000000000..bd7b14483ad --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.cpp @@ -0,0 +1,16 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "document_db_reconfig.h" +#include "document_subdb_reconfig.h" + +namespace proton { + +DocumentDBReconfig::DocumentDBReconfig(std::unique_ptr<const DocumentSubDBReconfig> ready_reconfig_in, + std::unique_ptr<const DocumentSubDBReconfig> not_ready_reconfig_in) + : _ready_reconfig(std::move(ready_reconfig_in)), + _not_ready_reconfig(std::move(not_ready_reconfig_in)) +{ +} + +} + diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.h b/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.h new file mode 100644 index 00000000000..c1f768511c8 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.h @@ -0,0 +1,35 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include <memory> + +namespace proton { + +class DocumentSubDBReconfig; + +/** + * Class representing the result of the prepare step of a DocumentDB reconfig. + * + * The reconfig is performed in two steps: + * Prepare: + * Based on the config that is changed, new components are instantiated in each subdb. + * This can be costly and is handled by helper threads from the shared executor pool. + * + * Apply: + * The new components are swapped with the old ones in the DocumentDB master write thread. + */ +class DocumentDBReconfig { +private: + std::unique_ptr<const DocumentSubDBReconfig> _ready_reconfig; + std::unique_ptr<const DocumentSubDBReconfig> _not_ready_reconfig; + +public: + DocumentDBReconfig(std::unique_ptr<const DocumentSubDBReconfig> ready_reconfig_in, + std::unique_ptr<const DocumentSubDBReconfig> not_ready_reconfig_in); + + const DocumentSubDBReconfig& ready_reconfig() const { return *_ready_reconfig; } + const DocumentSubDBReconfig& not_ready_reconfig() const { return *_not_ready_reconfig; } +}; + +} + diff --git a/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.cpp b/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.cpp new file mode 100644 index 00000000000..3692fa07c06 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.cpp @@ -0,0 +1,14 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "document_subdb_reconfig.h" + +namespace proton { + +DocumentSubDBReconfig::DocumentSubDBReconfig(std::shared_ptr<Matchers> matchers_in) + : _old_matchers(matchers_in), + _new_matchers(matchers_in) +{ +} + +} + diff --git a/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.h b/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.h new file mode 100644 index 00000000000..ed9faeee6fc --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.h @@ -0,0 +1,31 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include <memory> + +namespace proton { + +class Matchers; + +/** + * Class representing the result of the prepare step of a IDocumentSubDB reconfig. + */ +class DocumentSubDBReconfig { +private: + std::shared_ptr<Matchers> _old_matchers; + std::shared_ptr<Matchers> _new_matchers; + +public: + DocumentSubDBReconfig(std::shared_ptr<Matchers> matchers_in); + + void set_matchers(std::shared_ptr<Matchers> value) { + _new_matchers = std::move(value); + } + bool has_matchers_changed() const noexcept { + return _old_matchers != _new_matchers; + } + std::shared_ptr<Matchers> matchers() const { return _new_matchers; } +}; + +} + |