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:
@ -19,7 +19,7 @@ namespace wsrep
|
|||||||
: id_(static_cast<type>(id))
|
: id_(static_cast<type>(id))
|
||||||
{ }
|
{ }
|
||||||
type get() const { return id_; }
|
type get() const { return id_; }
|
||||||
static type invalid() { return -1; }
|
static type undefined() { return -1; }
|
||||||
private:
|
private:
|
||||||
type id_;
|
type id_;
|
||||||
};
|
};
|
||||||
|
@ -488,6 +488,10 @@ namespace wsrep
|
|||||||
return transaction_;
|
return transaction_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wsrep::ws_meta& toi_meta() const
|
||||||
|
{
|
||||||
|
return toi_meta_;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Set debug logging level.
|
* Set debug logging level.
|
||||||
*
|
*
|
||||||
@ -589,7 +593,8 @@ namespace wsrep
|
|||||||
wsrep::client_error current_error_;
|
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)
|
switch (state)
|
||||||
{
|
{
|
||||||
@ -601,6 +606,29 @@ namespace wsrep
|
|||||||
}
|
}
|
||||||
return "unknown";
|
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
|
class client_state_switch
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -29,6 +29,12 @@ namespace wsrep
|
|||||||
{
|
{
|
||||||
return (seqno_.is_undefined() && id_.is_undefined());
|
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:
|
private:
|
||||||
wsrep::id id_;
|
wsrep::id id_;
|
||||||
wsrep::seqno seqno_;
|
wsrep::seqno seqno_;
|
||||||
|
@ -92,6 +92,7 @@ namespace wsrep
|
|||||||
, flags_(flags)
|
, flags_(flags)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
const wsrep::gtid& gtid() const { return gtid_; }
|
||||||
const wsrep::id& group_id() const
|
const wsrep::id& group_id() const
|
||||||
{
|
{
|
||||||
return gtid_.id();
|
return gtid_.id();
|
||||||
|
@ -58,6 +58,10 @@ namespace wsrep
|
|||||||
{
|
{
|
||||||
return (seqno_ == other.seqno_);
|
return (seqno_ == other.seqno_);
|
||||||
}
|
}
|
||||||
|
bool operator!=(seqno other) const
|
||||||
|
{
|
||||||
|
return !(seqno_ == other.seqno_);
|
||||||
|
}
|
||||||
seqno operator+(seqno other) const
|
seqno operator+(seqno other) const
|
||||||
{
|
{
|
||||||
return (seqno(seqno_ + other.seqno_));
|
return (seqno(seqno_ + other.seqno_));
|
||||||
|
@ -59,14 +59,14 @@ namespace wsrep
|
|||||||
|
|
||||||
void rolled_back(wsrep::transaction_id id)
|
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;
|
rollback_replicated_for_ = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rolled_back() const
|
bool rolled_back() const
|
||||||
{
|
{
|
||||||
return (rollback_replicated_for_ !=
|
return (rollback_replicated_for_ !=
|
||||||
wsrep::transaction_id::invalid());
|
wsrep::transaction_id::undefined());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t unit_counter() const { return unit_counter_; }
|
size_t unit_counter() const { return unit_counter_; }
|
||||||
@ -80,7 +80,7 @@ namespace wsrep
|
|||||||
void cleanup()
|
void cleanup()
|
||||||
{
|
{
|
||||||
fragments_.clear();
|
fragments_.clear();
|
||||||
rollback_replicated_for_ = wsrep::transaction_id::invalid();
|
rollback_replicated_for_ = wsrep::transaction_id::undefined();
|
||||||
bytes_certified_ = 0;
|
bytes_certified_ = 0;
|
||||||
unit_counter_ = 0;
|
unit_counter_ = 0;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ namespace wsrep
|
|||||||
{ return id_; }
|
{ return id_; }
|
||||||
|
|
||||||
bool active() const
|
bool active() const
|
||||||
{ return (id_ != wsrep::transaction_id::invalid()); }
|
{ return (id_ != wsrep::transaction_id::undefined()); }
|
||||||
|
|
||||||
|
|
||||||
void state(wsrep::unique_lock<wsrep::mutex>&, enum state);
|
void state(wsrep::unique_lock<wsrep::mutex>&, enum state);
|
||||||
|
@ -24,7 +24,7 @@ namespace wsrep
|
|||||||
: id_(static_cast<type>(id))
|
: id_(static_cast<type>(id))
|
||||||
{ }
|
{ }
|
||||||
type get() const { return 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
|
bool operator<(const transaction_id& other) const
|
||||||
{
|
{
|
||||||
return (id_ < other.id_);
|
return (id_ < other.id_);
|
||||||
|
@ -26,7 +26,7 @@ wsrep::transaction::transaction(
|
|||||||
: server_service_(client_state.server_state().server_service())
|
: server_service_(client_state.server_state().server_service())
|
||||||
, client_service_(client_state.client_service())
|
, client_service_(client_state.client_service())
|
||||||
, client_state_(client_state)
|
, client_state_(client_state)
|
||||||
, id_(transaction_id::invalid())
|
, id_(transaction_id::undefined())
|
||||||
, state_(s_executing)
|
, state_(s_executing)
|
||||||
, state_hist_()
|
, state_hist_()
|
||||||
, bf_abort_state_(s_executing)
|
, bf_abort_state_(s_executing)
|
||||||
@ -952,7 +952,7 @@ void wsrep::transaction::cleanup()
|
|||||||
assert(is_streaming() == false);
|
assert(is_streaming() == false);
|
||||||
assert(state() == s_committed || state() == s_aborted);
|
assert(state() == s_committed || state() == s_aborted);
|
||||||
debug_log_state("cleanup_enter");
|
debug_log_state("cleanup_enter");
|
||||||
id_ = wsrep::transaction_id::invalid();
|
id_ = wsrep::transaction_id::undefined();
|
||||||
ws_handle_ = wsrep::ws_handle();
|
ws_handle_ = wsrep::ws_handle();
|
||||||
// Keep the state history for troubleshooting. Reset at start_transaction().
|
// Keep the state history for troubleshooting. Reset at start_transaction().
|
||||||
// state_hist_.clear();
|
// state_hist_.clear();
|
||||||
|
Reference in New Issue
Block a user