mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Galera4
This commit is contained in:
committed by
Sergey Vojtovich
parent
382115b992
commit
36a2a185fe
@ -21,6 +21,27 @@
|
||||
|
||||
unsigned int wsrep_check_ip (const char* const addr, bool *is_ipv6);
|
||||
size_t wsrep_guess_ip (char* buf, size_t buf_len);
|
||||
namespace wsp {
|
||||
class node_status
|
||||
{
|
||||
public:
|
||||
node_status() : status(wsrep::server_state::s_disconnected) {}
|
||||
void set(enum wsrep::server_state::state new_status,
|
||||
const wsrep::view* view= 0)
|
||||
{
|
||||
if (status != new_status || 0 != view)
|
||||
{
|
||||
wsrep_notify_status(new_status, view);
|
||||
status= new_status;
|
||||
}
|
||||
}
|
||||
enum wsrep::server_state::state get() const { return status; }
|
||||
private:
|
||||
enum wsrep::server_state::state status;
|
||||
};
|
||||
} /* namespace wsp */
|
||||
|
||||
extern wsp::node_status local_status;
|
||||
|
||||
/* returns the length of the host part of the address string */
|
||||
size_t wsrep_host_len(const char* addr, size_t addr_len);
|
||||
@ -173,52 +194,37 @@ private:
|
||||
class Config_state
|
||||
{
|
||||
public:
|
||||
Config_state() : view_(), status_(WSREP_MEMBER_UNDEFINED)
|
||||
Config_state() : view_(), status_(wsrep::server_state::s_disconnected)
|
||||
{}
|
||||
|
||||
void set(wsrep_member_status_t status, const wsrep_view_info_t* view)
|
||||
void set(const wsrep::view& view)
|
||||
{
|
||||
wsrep_notify_status(status, view);
|
||||
wsrep_notify_status(status_, &view);
|
||||
|
||||
lock();
|
||||
|
||||
status_= status;
|
||||
view_= *view;
|
||||
member_info_.clear();
|
||||
|
||||
wsrep_member_info_t memb;
|
||||
for(int i= 0; i < view->memb_num; i ++)
|
||||
{
|
||||
memb= view->members[i];
|
||||
member_info_.append_val(memb);
|
||||
}
|
||||
|
||||
view_= view;
|
||||
unlock();
|
||||
}
|
||||
|
||||
void set(wsrep_member_status_t status)
|
||||
void set(enum wsrep::server_state::state status)
|
||||
{
|
||||
wsrep_notify_status(status, 0);
|
||||
wsrep_notify_status(status);
|
||||
|
||||
lock();
|
||||
status_= status;
|
||||
unlock();
|
||||
}
|
||||
|
||||
wsrep_view_info_t get_view_info() const
|
||||
const wsrep::view& get_view_info() const
|
||||
{
|
||||
return view_;
|
||||
}
|
||||
|
||||
wsrep_member_status_t get_status() const
|
||||
enum wsrep::server_state::state get_status() const
|
||||
{
|
||||
return status_;
|
||||
}
|
||||
|
||||
Dynamic_array<wsrep_member_info_t> * get_member_info()
|
||||
{
|
||||
return &member_info_;
|
||||
}
|
||||
|
||||
int lock()
|
||||
{
|
||||
return mysql_mutex_lock(&LOCK_wsrep_config_state);
|
||||
@ -230,9 +236,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
wsrep_view_info_t view_;
|
||||
wsrep_member_status_t status_;
|
||||
Dynamic_array<wsrep_member_info_t> member_info_;
|
||||
wsrep::view view_;
|
||||
enum wsrep::server_state::state status_;
|
||||
};
|
||||
|
||||
} /* namespace wsp */
|
||||
@ -308,12 +313,23 @@ public:
|
||||
string() : string_(0) {}
|
||||
explicit string(size_t s) : string_(static_cast<char*>(malloc(s))) {}
|
||||
char* operator()() { return string_; }
|
||||
void set(char* str) { if (string_) free (string_); string_ = str; }
|
||||
void set(char* str) { if (string_) free (string_); string_= str; }
|
||||
~string() { set (0); }
|
||||
private:
|
||||
char* string_;
|
||||
};
|
||||
|
||||
/* scope level lock */
|
||||
class auto_lock
|
||||
{
|
||||
public:
|
||||
auto_lock(mysql_mutex_t* m) : m_(m) { mysql_mutex_lock(m_); }
|
||||
~auto_lock() { mysql_mutex_unlock(m_); }
|
||||
private:
|
||||
mysql_mutex_t& operator =(mysql_mutex_t&);
|
||||
mysql_mutex_t* const m_;
|
||||
};
|
||||
|
||||
#ifdef REMOVED
|
||||
class lock
|
||||
{
|
||||
@ -323,7 +339,7 @@ public:
|
||||
|
||||
lock (pthread_mutex_t* mtx) : mtx_(mtx)
|
||||
{
|
||||
int err = pthread_mutex_lock (mtx_);
|
||||
int err= pthread_mutex_lock (mtx_);
|
||||
|
||||
if (err)
|
||||
{
|
||||
@ -334,7 +350,7 @@ public:
|
||||
|
||||
virtual ~lock ()
|
||||
{
|
||||
int err = pthread_mutex_unlock (mtx_);
|
||||
int err= pthread_mutex_unlock (mtx_);
|
||||
|
||||
if (err)
|
||||
{
|
||||
|
Reference in New Issue
Block a user