mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
Initial replicating side implementation of streaming replication
This commit is contained in:
@ -229,6 +229,13 @@ namespace wsrep
|
||||
return transaction_.start_transaction(wsh, meta);
|
||||
}
|
||||
|
||||
void enable_streaming(
|
||||
enum wsrep::transaction_context::streaming_context::fragment_unit fragment_unit,
|
||||
size_t fragment_size)
|
||||
{
|
||||
transaction_.streaming_context_.enable(
|
||||
fragment_unit, fragment_size);
|
||||
}
|
||||
int append_key(const wsrep::key& key)
|
||||
{
|
||||
assert(state_ == s_exec);
|
||||
@ -240,6 +247,13 @@ namespace wsrep
|
||||
assert(state_ == s_exec);
|
||||
return transaction_.append_data(data);
|
||||
}
|
||||
|
||||
|
||||
int after_row()
|
||||
{
|
||||
assert(state_ == s_exec);
|
||||
return transaction_.after_row();
|
||||
}
|
||||
int before_prepare()
|
||||
{
|
||||
assert(state_ == s_exec);
|
||||
|
@ -129,6 +129,7 @@ namespace wsrep
|
||||
int flags_;
|
||||
};
|
||||
|
||||
|
||||
// Abstract interface for provider implementations
|
||||
class provider
|
||||
{
|
||||
@ -284,6 +285,22 @@ namespace wsrep
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline bool starts_transaction(int flags)
|
||||
{
|
||||
return (flags & wsrep::provider::flag::start_transaction);
|
||||
}
|
||||
|
||||
static inline bool commits_transaction(int flags)
|
||||
{
|
||||
return (flags & wsrep::provider::flag::commit);
|
||||
}
|
||||
|
||||
static inline bool rolls_back_transaction(int flags)
|
||||
{
|
||||
return (flags & wsrep::provider::flag::rollback);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // WSREP_PROVIDER_HPP
|
||||
|
@ -150,8 +150,79 @@ namespace wsrep
|
||||
bool pa_unsafe_;
|
||||
bool certified_;
|
||||
|
||||
std::vector<wsrep::seqno> fragments_;
|
||||
wsrep::transaction_id rollback_replicated_for_;
|
||||
public:
|
||||
class streaming_context
|
||||
{
|
||||
public:
|
||||
enum fragment_unit
|
||||
{
|
||||
row,
|
||||
bytes,
|
||||
statement
|
||||
};
|
||||
|
||||
streaming_context()
|
||||
: fragments_()
|
||||
, rollback_replicated_for_()
|
||||
, fragment_unit_()
|
||||
, fragment_size_()
|
||||
, bytes_certified_()
|
||||
, unit_counter_()
|
||||
{ }
|
||||
|
||||
void enable(enum fragment_unit fragment_unit, size_t fragment_size)
|
||||
{
|
||||
assert(fragment_size > 0);
|
||||
fragment_unit_ = fragment_unit;
|
||||
fragment_size_ = fragment_size;
|
||||
}
|
||||
|
||||
enum fragment_unit fragment_unit() const { return fragment_unit_; }
|
||||
|
||||
size_t fragment_size() const { return fragment_size_; }
|
||||
|
||||
void disable()
|
||||
{
|
||||
fragment_size_ = 0;
|
||||
}
|
||||
|
||||
void certified(wsrep::seqno seqno)
|
||||
{
|
||||
fragments_.push_back(seqno);
|
||||
}
|
||||
|
||||
size_t fragments_certified() const
|
||||
{
|
||||
return fragments_.size();
|
||||
}
|
||||
|
||||
size_t bytes_certified() const
|
||||
{
|
||||
return bytes_certified_;
|
||||
}
|
||||
|
||||
void rolled_back(wsrep::transaction_id id)
|
||||
{
|
||||
assert(rollback_replicated_for_ == wsrep::transaction_id::invalid());
|
||||
rollback_replicated_for_ = id;
|
||||
}
|
||||
|
||||
bool rolled_back() const
|
||||
{
|
||||
return (rollback_replicated_for_ !=
|
||||
wsrep::transaction_id::invalid());
|
||||
}
|
||||
|
||||
size_t unit_counter() const { return unit_counter_; }
|
||||
void increment_unit_counter() { ++unit_counter_; }
|
||||
private:
|
||||
std::vector<wsrep::seqno> fragments_;
|
||||
wsrep::transaction_id rollback_replicated_for_;
|
||||
enum fragment_unit fragment_unit_;
|
||||
size_t fragment_size_;
|
||||
size_t bytes_certified_;
|
||||
size_t unit_counter_;
|
||||
} streaming_context_;
|
||||
};
|
||||
|
||||
static inline std::string to_string(enum wsrep::transaction_context::state state)
|
||||
|
Reference in New Issue
Block a user