mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
Collect and append SR commit keys.
This commit is contained in:
44
include/wsrep/sr_key_set.hpp
Normal file
44
include/wsrep/sr_key_set.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
//
|
||||
|
||||
#ifndef WSREP_SR_KEY_SET_HPP
|
||||
#define WSREP_SR_KEY_SET_HPP
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
namespace wsrep
|
||||
{
|
||||
class sr_key_set
|
||||
{
|
||||
public:
|
||||
typedef std::set<std::string> leaf_type;
|
||||
typedef std::map<std::string, leaf_type > branch_type;
|
||||
sr_key_set()
|
||||
: root_()
|
||||
{ }
|
||||
|
||||
void insert(const wsrep::key& key)
|
||||
{
|
||||
assert(key.size() == 3);
|
||||
if (key.size() < 3)
|
||||
{
|
||||
throw wsrep::runtime_error("Invalid key size");
|
||||
}
|
||||
|
||||
root_[std::string(
|
||||
static_cast<const char*>(key.key_parts()[0].data()),
|
||||
key.key_parts()[0].size())].insert(
|
||||
std::string(static_cast<const char*>(key.key_parts()[1].data()),
|
||||
key.key_parts()[1].size()));
|
||||
}
|
||||
|
||||
const branch_type& root() const { return root_; }
|
||||
void clear() { root_.clear(); }
|
||||
private:
|
||||
branch_type root_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // WSREP_KEY_SET_HPP
|
@ -11,6 +11,7 @@
|
||||
#include "transaction_id.hpp"
|
||||
#include "streaming_context.hpp"
|
||||
#include "lock.hpp"
|
||||
#include "sr_key_set.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
@ -149,6 +150,7 @@ namespace wsrep
|
||||
void flags(int flags) { flags_ = flags; }
|
||||
int certify_fragment(wsrep::unique_lock<wsrep::mutex>&);
|
||||
int certify_commit(wsrep::unique_lock<wsrep::mutex>&);
|
||||
int append_sr_keys_for_commit();
|
||||
void streaming_rollback();
|
||||
void clear_fragments();
|
||||
void cleanup();
|
||||
@ -169,6 +171,7 @@ namespace wsrep
|
||||
bool pa_unsafe_;
|
||||
bool certified_;
|
||||
wsrep::streaming_context streaming_context_;
|
||||
wsrep::sr_key_set sr_keys_;
|
||||
};
|
||||
|
||||
static inline const char* to_c_string(enum wsrep::transaction::state state)
|
||||
|
Reference in New Issue
Block a user