Skip to content

Commit

Permalink
db::extentions: Add "extensions internal" keyspace set
Browse files Browse the repository at this point in the history
Refs scylladb#13334

To be populated early by extensions. Such a keyspace should be
1.) Started before user keyspaces
2.) Flushed/closed after user keyspaces
3.) For all other regards be considered "user".
  • Loading branch information
Calle Wilund committed Mar 27, 2023
1 parent cd0b167 commit 7c8c020
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions db/extensions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,20 @@ void db::extensions::add_commitlog_file_extension(sstring n, commitlog_file_exte
void db::extensions::add_extension_to_schema(schema_ptr s, const sstring& name, shared_ptr<schema_extension> ext) {
const_cast<schema *>(s.get())->extensions()[name] = std::move(ext);
}

void db::extensions::add_extension_internal_keyspace(std::string ks) {
_extension_internal_keyspaces.emplace(std::move(ks));
}

// TODO: remove once this is backmerged to ent once, and relevant code is updated.
extern bool is_load_prio_keyspace(std::string_view name);

bool db::extensions::is_extension_internal_keyspace(const std::string& ks) const {
if (_extension_internal_keyspaces.count(ks)) {
return true;
}
if (::is_load_prio_keyspace(ks)) {
return true;
}
return false;
}
19 changes: 19 additions & 0 deletions db/extensions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <map>
#include <variant>
#include <vector>
#include <unordered_set>

#include <seastar/core/sstring.hh>

Expand Down Expand Up @@ -97,9 +98,27 @@ public:
* config apply.
*/
void add_extension_to_schema(schema_ptr, const sstring&, shared_ptr<schema_extension>);

/**
* Adds a keyspace to "extension internal" set.
*
* Such a keyspace must be loaded before/destroyed after any "normal" user keyspace.
* Thus a psuedo-system/internal keyspce.
* This has little to no use in open source version, and is temporarily bridged with
* the static version of same functionality in distributed loader. It is however (or will
* be), essential to enterprise code. Do not remove.
*/
void add_extension_internal_keyspace(std::string);

/**
* Checks if a keyspace is a registered load priority one.
*/
bool is_extension_internal_keyspace(const std::string&) const;

private:
std::map<sstring, schema_ext_create_func> _schema_extensions;
std::map<sstring, sstable_file_io_extension> _sstable_file_io_extensions;
std::map<sstring, commitlog_file_extension_ptr> _commitlog_file_extensions;
std::unordered_set<std::string> _extension_internal_keyspaces;
};
}

0 comments on commit 7c8c020

Please sign in to comment.