1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-02 05:22:26 +03:00

Renamed invalid to undefined. More utility functions.

This commit is contained in:
Teemu Ollakka
2018-06-21 16:50:44 +03:00
parent 81ac78913a
commit 8f0e112c47
9 changed files with 48 additions and 9 deletions

View File

@ -19,7 +19,7 @@ namespace wsrep
: id_(static_cast<type>(id))
{ }
type get() const { return id_; }
static type invalid() { return -1; }
static type undefined() { return -1; }
private:
type id_;
};

View File

@ -488,6 +488,10 @@ namespace wsrep
return transaction_;
}
const wsrep::ws_meta& toi_meta() const
{
return toi_meta_;
}
/**
* Set debug logging level.
*
@ -589,7 +593,8 @@ namespace wsrep
wsrep::client_error current_error_;
};
static inline const char* to_string(enum wsrep::client_state::state state)
static inline const char* to_c_string(
enum wsrep::client_state::state state)
{
switch (state)
{
@ -601,6 +606,29 @@ namespace wsrep
}
return "unknown";
}
static inline std::string to_string(enum wsrep::client_state::state state)
{
return to_c_string(state);
}
static inline const char* to_c_string(enum wsrep::client_state::mode mode)
{
switch (mode)
{
case wsrep::client_state::m_local: return "local";
case wsrep::client_state::m_replicating: return "replicating";
case wsrep::client_state::m_high_priority: return "high priority";
case wsrep::client_state::m_toi: return "toi";
}
return "unknown";
}
static inline std::string to_string(enum wsrep::client_state::mode mode)
{
return to_c_string(mode);
}
class client_state_switch
{
public:

View File

@ -29,6 +29,12 @@ namespace wsrep
{
return (seqno_.is_undefined() && id_.is_undefined());
}
static wsrep::gtid undefined()
{
static const wsrep::gtid ret(wsrep::id::undefined(),
wsrep::seqno::undefined());
return ret;
}
private:
wsrep::id id_;
wsrep::seqno seqno_;

View File

@ -92,6 +92,7 @@ namespace wsrep
, flags_(flags)
{ }
const wsrep::gtid& gtid() const { return gtid_; }
const wsrep::id& group_id() const
{
return gtid_.id();

View File

@ -58,6 +58,10 @@ namespace wsrep
{
return (seqno_ == other.seqno_);
}
bool operator!=(seqno other) const
{
return !(seqno_ == other.seqno_);
}
seqno operator+(seqno other) const
{
return (seqno(seqno_ + other.seqno_));

View File

@ -59,14 +59,14 @@ namespace wsrep
void rolled_back(wsrep::transaction_id id)
{
assert(rollback_replicated_for_ == wsrep::transaction_id::invalid());
assert(rollback_replicated_for_ == wsrep::transaction_id::undefined());
rollback_replicated_for_ = id;
}
bool rolled_back() const
{
return (rollback_replicated_for_ !=
wsrep::transaction_id::invalid());
wsrep::transaction_id::undefined());
}
size_t unit_counter() const { return unit_counter_; }
@ -80,7 +80,7 @@ namespace wsrep
void cleanup()
{
fragments_.clear();
rollback_replicated_for_ = wsrep::transaction_id::invalid();
rollback_replicated_for_ = wsrep::transaction_id::undefined();
bytes_certified_ = 0;
unit_counter_ = 0;
}

View File

@ -52,7 +52,7 @@ namespace wsrep
{ return id_; }
bool active() const
{ return (id_ != wsrep::transaction_id::invalid()); }
{ return (id_ != wsrep::transaction_id::undefined()); }
void state(wsrep::unique_lock<wsrep::mutex>&, enum state);

View File

@ -24,7 +24,7 @@ namespace wsrep
: id_(static_cast<type>(id))
{ }
type get() const { return id_; }
static unsigned long long invalid() { return type(-1); }
static unsigned long long undefined() { return type(-1); }
bool operator<(const transaction_id& other) const
{
return (id_ < other.id_);

View File

@ -26,7 +26,7 @@ wsrep::transaction::transaction(
: server_service_(client_state.server_state().server_service())
, client_service_(client_state.client_service())
, client_state_(client_state)
, id_(transaction_id::invalid())
, id_(transaction_id::undefined())
, state_(s_executing)
, state_hist_()
, bf_abort_state_(s_executing)
@ -952,7 +952,7 @@ void wsrep::transaction::cleanup()
assert(is_streaming() == false);
assert(state() == s_committed || state() == s_aborted);
debug_log_state("cleanup_enter");
id_ = wsrep::transaction_id::invalid();
id_ = wsrep::transaction_id::undefined();
ws_handle_ = wsrep::ws_handle();
// Keep the state history for troubleshooting. Reset at start_transaction().
// state_hist_.clear();