MXS-2271 Rename MXS_MONITORED_SERVER to MonitorServer
This commit is contained in:
parent
6042a53cb3
commit
6b14479b6c
@ -154,7 +154,7 @@ namespace maxscale
|
||||
/**
|
||||
* The linked list of servers that are being monitored by the monitor module.
|
||||
*/
|
||||
class MXS_MONITORED_SERVER
|
||||
class MonitorServer
|
||||
{
|
||||
public:
|
||||
class ConnectionSettings
|
||||
@ -181,9 +181,9 @@ public:
|
||||
static const int BEING_DRAINED_OFF = 3;
|
||||
static const int BEING_DRAINED_ON = 4;
|
||||
|
||||
MXS_MONITORED_SERVER(SERVER* server);
|
||||
MonitorServer(SERVER* server);
|
||||
|
||||
~MXS_MONITORED_SERVER();
|
||||
~MonitorServer();
|
||||
|
||||
/**
|
||||
* Set pending status bits in the monitor server
|
||||
@ -273,7 +273,7 @@ public:
|
||||
* valid or NULL.
|
||||
* @return Connection status.
|
||||
*/
|
||||
static mxs_connect_result_t ping_or_connect_to_db(const MXS_MONITORED_SERVER::ConnectionSettings& sett,
|
||||
static mxs_connect_result_t ping_or_connect_to_db(const MonitorServer::ConnectionSettings& sett,
|
||||
SERVER& server, MYSQL** ppConn);
|
||||
|
||||
static bool connection_is_ok(mxs_connect_result_t connect_result);
|
||||
@ -373,8 +373,8 @@ public:
|
||||
uint64_t m_ticks {0}; /**< Number of performed monitoring intervals */
|
||||
uint8_t m_journal_hash[SHA_DIGEST_LENGTH]; /**< SHA1 hash of the latest written journal */
|
||||
|
||||
MXS_CONFIG_PARAMETER parameters; /**< Configuration parameters */
|
||||
std::vector<MXS_MONITORED_SERVER*> m_servers; /**< Monitored servers */
|
||||
MXS_CONFIG_PARAMETER parameters; /**< Configuration parameters */
|
||||
std::vector<MonitorServer*> m_servers; /**< Monitored servers */
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -433,7 +433,7 @@ protected:
|
||||
* @param error_out Set to true if an error occurs
|
||||
* @return Output array
|
||||
*/
|
||||
std::vector<MXS_MONITORED_SERVER*> get_monitored_serverlist(const std::string& key, bool* error_out);
|
||||
std::vector<MonitorServer*> get_monitored_serverlist(const std::string& key, bool* error_out);
|
||||
|
||||
/**
|
||||
* Find the monitored server representing the server.
|
||||
@ -441,21 +441,21 @@ protected:
|
||||
* @param search_server Server to search for
|
||||
* @return Found monitored server or NULL if not found
|
||||
*/
|
||||
MXS_MONITORED_SERVER* get_monitored_server(SERVER* search_server);
|
||||
MonitorServer* get_monitored_server(SERVER* search_server);
|
||||
|
||||
/**
|
||||
* @brief Load a journal of server states
|
||||
*
|
||||
* @param master Set to point to the current master
|
||||
*/
|
||||
void load_server_journal(MXS_MONITORED_SERVER** master);
|
||||
void load_server_journal(MonitorServer** master);
|
||||
|
||||
/**
|
||||
* @brief Store a journal of server states
|
||||
*
|
||||
* @param master The current master server or NULL if no master exists
|
||||
*/
|
||||
void store_server_journal(MXS_MONITORED_SERVER* master);
|
||||
void store_server_journal(MonitorServer* master);
|
||||
|
||||
void check_maintenance_requests();
|
||||
|
||||
@ -468,9 +468,9 @@ protected:
|
||||
|
||||
void remove_server_journal();
|
||||
|
||||
MXS_MONITORED_SERVER* find_parent_node(MXS_MONITORED_SERVER* target);
|
||||
MonitorServer* find_parent_node(MonitorServer* target);
|
||||
|
||||
std::string child_nodes(MXS_MONITORED_SERVER* parent);
|
||||
std::string child_nodes(MonitorServer* parent);
|
||||
|
||||
/**
|
||||
* Contains monitor base class settings. Since monitors are stopped before a setting change,
|
||||
@ -493,7 +493,7 @@ protected:
|
||||
* disabling. */
|
||||
int64_t disk_space_check_interval = -1;
|
||||
|
||||
MXS_MONITORED_SERVER::ConnectionSettings conn_settings;
|
||||
MonitorServer::ConnectionSettings conn_settings;
|
||||
};
|
||||
|
||||
Settings m_settings;
|
||||
@ -531,7 +531,7 @@ private:
|
||||
* @param ptr The server which has changed state
|
||||
* @return Return value of the executed script or -1 on error
|
||||
*/
|
||||
int launch_script(MXS_MONITORED_SERVER* ptr);
|
||||
int launch_script(MonitorServer* ptr);
|
||||
|
||||
/**
|
||||
* Launch a command
|
||||
@ -543,7 +543,7 @@ private:
|
||||
*
|
||||
* @return Return value of the executed script or -1 on error.
|
||||
*/
|
||||
int launch_command(MXS_MONITORED_SERVER* ptr, EXTERNCMD* cmd);
|
||||
int launch_command(MonitorServer* ptr, EXTERNCMD* cmd);
|
||||
|
||||
/**
|
||||
* @brief The monitor should populate associated services.
|
||||
@ -663,7 +663,7 @@ protected:
|
||||
*
|
||||
* @return True, if the disk space should be checked, false otherwise.
|
||||
*/
|
||||
bool should_update_disk_space_status(const MXS_MONITORED_SERVER* pMonitored_server) const;
|
||||
bool should_update_disk_space_status(const MonitorServer* pMonitored_server) const;
|
||||
|
||||
/**
|
||||
* @brief Update the disk space status of a server.
|
||||
@ -672,7 +672,7 @@ protected:
|
||||
* @c pMonitored_server->pending_status if the disk space is exhausted
|
||||
* or cleared if it is not.
|
||||
*/
|
||||
void update_disk_space_status(MXS_MONITORED_SERVER* pMonitored_server);
|
||||
void update_disk_space_status(MonitorServer* pMonitored_server);
|
||||
|
||||
/**
|
||||
* @brief Configure the monitor.
|
||||
@ -745,7 +745,7 @@ protected:
|
||||
*/
|
||||
virtual bool immediate_tick_required() const;
|
||||
|
||||
MXS_MONITORED_SERVER* m_master; /**< Master server */
|
||||
MonitorServer* m_master; /**< Master server */
|
||||
|
||||
private:
|
||||
std::atomic<bool> m_thread_running; /**< Thread state. Only visible inside MonitorInstance. */
|
||||
@ -779,7 +779,7 @@ protected:
|
||||
* The implementation should probe the server in question and update
|
||||
* the server status bits.
|
||||
*/
|
||||
virtual void update_server_status(MXS_MONITORED_SERVER* pMonitored_server) = 0;
|
||||
virtual void update_server_status(MonitorServer* pMonitored_server) = 0;
|
||||
|
||||
/**
|
||||
* @brief Called right at the beginning of @c tick().
|
||||
|
@ -71,7 +71,7 @@ using std::string;
|
||||
using std::set;
|
||||
using Guard = std::lock_guard<std::mutex>;
|
||||
using maxscale::Monitor;
|
||||
using maxscale::MXS_MONITORED_SERVER;
|
||||
using maxscale::MonitorServer;
|
||||
|
||||
const char CN_BACKEND_CONNECT_ATTEMPTS[] = "backend_connect_attempts";
|
||||
const char CN_BACKEND_CONNECT_TIMEOUT[] = "backend_connect_timeout";
|
||||
@ -236,7 +236,7 @@ bool rename_tmp_file(Monitor* monitor, const char* src)
|
||||
* PATH_MAX bytes long
|
||||
* @param size Size of @c data
|
||||
*/
|
||||
void store_data(Monitor* monitor, MXS_MONITORED_SERVER* master, uint8_t* data, uint32_t size)
|
||||
void store_data(Monitor* monitor, MonitorServer* master, uint8_t* data, uint32_t size)
|
||||
{
|
||||
uint8_t* ptr = data;
|
||||
|
||||
@ -248,7 +248,7 @@ void store_data(Monitor* monitor, MXS_MONITORED_SERVER* master, uint8_t* data, u
|
||||
*ptr++ = MMB_SCHEMA_VERSION;
|
||||
|
||||
/** Store the states of all servers */
|
||||
for (MXS_MONITORED_SERVER* db : monitor->m_servers)
|
||||
for (MonitorServer* db : monitor->m_servers)
|
||||
{
|
||||
*ptr++ = (char)SVT_SERVER; // Value type
|
||||
memcpy(ptr, db->server->name(), strlen(db->server->name()));// Name of the server
|
||||
@ -301,7 +301,7 @@ static bool has_null_terminator(const char* data, const char* end)
|
||||
*/
|
||||
const char* process_server(Monitor* monitor, const char* data, const char* end)
|
||||
{
|
||||
for (MXS_MONITORED_SERVER* db : monitor->m_servers)
|
||||
for (MonitorServer* db : monitor->m_servers)
|
||||
{
|
||||
if (strcmp(db->server->name(), data) == 0)
|
||||
{
|
||||
@ -325,12 +325,12 @@ const char* process_server(Monitor* monitor, const char* data, const char* end)
|
||||
/**
|
||||
* Process a master
|
||||
*/
|
||||
const char* process_master(Monitor* monitor, MXS_MONITORED_SERVER** master,
|
||||
const char* process_master(Monitor* monitor, MonitorServer** master,
|
||||
const char* data, const char* end)
|
||||
{
|
||||
if (master)
|
||||
{
|
||||
for (MXS_MONITORED_SERVER* db : monitor->m_servers)
|
||||
for (MonitorServer* db : monitor->m_servers)
|
||||
{
|
||||
if (strcmp(db->server->name(), data) == 0)
|
||||
{
|
||||
@ -359,7 +359,7 @@ bool check_crc32(const uint8_t* data, uint32_t size, const uint8_t* crc_ptr)
|
||||
/**
|
||||
* Process the stored journal data
|
||||
*/
|
||||
bool process_data_file(Monitor* monitor, MXS_MONITORED_SERVER** master,
|
||||
bool process_data_file(Monitor* monitor, MonitorServer** master,
|
||||
const char* data, const char* crc_ptr)
|
||||
{
|
||||
const char* ptr = data;
|
||||
@ -441,7 +441,7 @@ json_t* monitor_json_data(const Monitor* monitor, const char* host)
|
||||
if (!monitor->m_servers.empty())
|
||||
{
|
||||
json_t* mon_rel = mxs_json_relationship(host, MXS_JSON_API_SERVERS);
|
||||
for (MXS_MONITORED_SERVER* db : monitor->m_servers)
|
||||
for (MonitorServer* db : monitor->m_servers)
|
||||
{
|
||||
mxs_json_add_relation(mon_rel, db->server->name(), CN_SERVERS);
|
||||
}
|
||||
@ -724,7 +724,7 @@ Monitor* MonitorManager::server_is_monitored(const SERVER* server)
|
||||
Guard guard(monitor->m_lock);
|
||||
if (monitor->m_active)
|
||||
{
|
||||
for (MXS_MONITORED_SERVER* db : monitor->m_servers)
|
||||
for (MonitorServer* db : monitor->m_servers)
|
||||
{
|
||||
if (db->server == server)
|
||||
{
|
||||
@ -846,7 +846,7 @@ json_t* MonitorManager::monitor_relations_to_server(const SERVER* server, const
|
||||
Guard guard(mon->m_lock);
|
||||
if (mon->m_active)
|
||||
{
|
||||
for (MXS_MONITORED_SERVER* db : mon->m_servers)
|
||||
for (MonitorServer* db : mon->m_servers)
|
||||
{
|
||||
if (db->server == server)
|
||||
{
|
||||
@ -981,7 +981,7 @@ Monitor::~Monitor()
|
||||
void Monitor::add_server(SERVER* server)
|
||||
{
|
||||
mxb_assert(state() != MONITOR_STATE_RUNNING);
|
||||
auto new_server = new MXS_MONITORED_SERVER(server);
|
||||
auto new_server = new MonitorServer(server);
|
||||
m_servers.push_back(new_server);
|
||||
server_added(server);
|
||||
}
|
||||
@ -1014,7 +1014,7 @@ void Monitor::remove_server(SERVER* server)
|
||||
{
|
||||
mxb_assert(state() != MONITOR_STATE_RUNNING);
|
||||
|
||||
MXS_MONITORED_SERVER* ptr = nullptr;
|
||||
MonitorServer* ptr = nullptr;
|
||||
|
||||
using Guard = std::unique_lock<std::mutex>;
|
||||
Guard guard(m_lock);
|
||||
@ -1054,7 +1054,7 @@ void Monitor::show(DCB* dcb)
|
||||
|
||||
const char* sep = "";
|
||||
|
||||
for (MXS_MONITORED_SERVER* db : monitor->m_servers)
|
||||
for (MonitorServer* db : monitor->m_servers)
|
||||
{
|
||||
dcb_printf(dcb, "%s[%s]:%d", sep, db->server->address, db->server->port);
|
||||
sep = ", ";
|
||||
@ -1084,7 +1084,7 @@ bool Monitor::test_permissions(const string& query)
|
||||
char* dpasswd = decrypt_password(m_settings.conn_settings.password.c_str());
|
||||
bool rval = false;
|
||||
|
||||
for (MXS_MONITORED_SERVER* mondb : monitor->m_servers)
|
||||
for (MonitorServer* mondb : monitor->m_servers)
|
||||
{
|
||||
if (!connection_is_ok(mondb->ping_or_connect(m_settings.conn_settings)))
|
||||
{
|
||||
@ -1149,18 +1149,18 @@ bool Monitor::test_permissions(const string& query)
|
||||
return rval;
|
||||
}
|
||||
|
||||
void MXS_MONITORED_SERVER::stash_current_status()
|
||||
void MonitorServer::stash_current_status()
|
||||
{
|
||||
mon_prev_status = server->status;
|
||||
pending_status = server->status;
|
||||
}
|
||||
|
||||
void MXS_MONITORED_SERVER::set_pending_status(uint64_t bits)
|
||||
void MonitorServer::set_pending_status(uint64_t bits)
|
||||
{
|
||||
pending_status |= bits;
|
||||
}
|
||||
|
||||
void MXS_MONITORED_SERVER::clear_pending_status(uint64_t bits)
|
||||
void MonitorServer::clear_pending_status(uint64_t bits)
|
||||
{
|
||||
pending_status &= ~bits;
|
||||
}
|
||||
@ -1173,7 +1173,7 @@ void MXS_MONITORED_SERVER::clear_pending_status(uint64_t bits)
|
||||
*
|
||||
* @note This function must only be called from mon_process_state_changes
|
||||
*/
|
||||
mxs_monitor_event_t MXS_MONITORED_SERVER::get_event_type() const
|
||||
mxs_monitor_event_t MonitorServer::get_event_type() const
|
||||
{
|
||||
typedef enum
|
||||
{
|
||||
@ -1312,7 +1312,7 @@ const char* Monitor::get_event_name(mxs_monitor_event_t event)
|
||||
return "undefined_event";
|
||||
}
|
||||
|
||||
const char* MXS_MONITORED_SERVER::get_event_name()
|
||||
const char* MonitorServer::get_event_name()
|
||||
{
|
||||
return Monitor::get_event_name((mxs_monitor_event_t) server->last_event);
|
||||
}
|
||||
@ -1376,7 +1376,7 @@ void Monitor::append_node_names(char* dest, int len, int status, credentials_app
|
||||
*
|
||||
* @return true if status has changed
|
||||
*/
|
||||
bool MXS_MONITORED_SERVER::status_changed()
|
||||
bool MonitorServer::status_changed()
|
||||
{
|
||||
bool rval = false;
|
||||
|
||||
@ -1408,18 +1408,18 @@ bool MXS_MONITORED_SERVER::status_changed()
|
||||
*
|
||||
* @return true if failed status can be logged or false
|
||||
*/
|
||||
bool MXS_MONITORED_SERVER::should_print_fail_status()
|
||||
bool MonitorServer::should_print_fail_status()
|
||||
{
|
||||
return server->is_down() && mon_err_count == 0;
|
||||
}
|
||||
|
||||
MXS_MONITORED_SERVER* Monitor::find_parent_node(MXS_MONITORED_SERVER* target)
|
||||
MonitorServer* Monitor::find_parent_node(MonitorServer* target)
|
||||
{
|
||||
MXS_MONITORED_SERVER* rval = NULL;
|
||||
MonitorServer* rval = NULL;
|
||||
|
||||
if (target->server->master_id > 0)
|
||||
{
|
||||
for (MXS_MONITORED_SERVER* node : m_servers)
|
||||
for (MonitorServer* node : m_servers)
|
||||
{
|
||||
if (node->server->node_id == target->server->master_id)
|
||||
{
|
||||
@ -1432,14 +1432,14 @@ MXS_MONITORED_SERVER* Monitor::find_parent_node(MXS_MONITORED_SERVER* target)
|
||||
return rval;
|
||||
}
|
||||
|
||||
std::string Monitor::child_nodes(MXS_MONITORED_SERVER* parent)
|
||||
std::string Monitor::child_nodes(MonitorServer* parent)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
if (parent->server->node_id > 0)
|
||||
{
|
||||
bool have_content = false;
|
||||
for (MXS_MONITORED_SERVER* node : m_servers)
|
||||
for (MonitorServer* node : m_servers)
|
||||
{
|
||||
if (node->server->master_id == parent->server->node_id)
|
||||
{
|
||||
@ -1457,7 +1457,7 @@ std::string Monitor::child_nodes(MXS_MONITORED_SERVER* parent)
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
int Monitor::launch_command(MXS_MONITORED_SERVER* ptr, EXTERNCMD* cmd)
|
||||
int Monitor::launch_command(MonitorServer* ptr, EXTERNCMD* cmd)
|
||||
{
|
||||
if (externcmd_matches(cmd, "$INITIATOR"))
|
||||
{
|
||||
@ -1469,7 +1469,7 @@ int Monitor::launch_command(MXS_MONITORED_SERVER* ptr, EXTERNCMD* cmd)
|
||||
if (externcmd_matches(cmd, "$PARENT"))
|
||||
{
|
||||
std::stringstream ss;
|
||||
MXS_MONITORED_SERVER* parent = find_parent_node(ptr);
|
||||
MonitorServer* parent = find_parent_node(ptr);
|
||||
|
||||
if (parent)
|
||||
{
|
||||
@ -1599,7 +1599,7 @@ int Monitor::launch_command(MXS_MONITORED_SERVER* ptr, EXTERNCMD* cmd)
|
||||
return rv;
|
||||
}
|
||||
|
||||
int Monitor::launch_script(MXS_MONITORED_SERVER* ptr)
|
||||
int Monitor::launch_script(MonitorServer* ptr)
|
||||
{
|
||||
const char* script = m_settings.script.c_str();
|
||||
char arg[strlen(script) + 1];
|
||||
@ -1622,7 +1622,7 @@ int Monitor::launch_script(MXS_MONITORED_SERVER* ptr)
|
||||
return rv;
|
||||
}
|
||||
|
||||
mxs_connect_result_t Monitor::ping_or_connect_to_db(const MXS_MONITORED_SERVER::ConnectionSettings& sett,
|
||||
mxs_connect_result_t Monitor::ping_or_connect_to_db(const MonitorServer::ConnectionSettings& sett,
|
||||
SERVER& server, MYSQL** ppConn)
|
||||
{
|
||||
mxb_assert(ppConn);
|
||||
@ -1683,7 +1683,7 @@ mxs_connect_result_t Monitor::ping_or_connect_to_db(const MXS_MONITORED_SERVER::
|
||||
return conn_result;
|
||||
}
|
||||
|
||||
mxs_connect_result_t MXS_MONITORED_SERVER::ping_or_connect(const ConnectionSettings& settings)
|
||||
mxs_connect_result_t MonitorServer::ping_or_connect(const ConnectionSettings& settings)
|
||||
{
|
||||
return Monitor::ping_or_connect_to_db(settings, *server, &con);
|
||||
}
|
||||
@ -1704,7 +1704,7 @@ bool Monitor::connection_is_ok(mxs_connect_result_t connect_result)
|
||||
*
|
||||
* @param rval Return value of mon_ping_or_connect_to_db
|
||||
*/
|
||||
void MXS_MONITORED_SERVER::log_connect_error(mxs_connect_result_t rval)
|
||||
void MonitorServer::log_connect_error(mxs_connect_result_t rval)
|
||||
{
|
||||
mxb_assert(!Monitor::connection_is_ok(rval));
|
||||
const char TIMED_OUT[] = "Monitor timed out when connecting to server %s[%s:%d] : '%s'";
|
||||
@ -1716,7 +1716,7 @@ void MXS_MONITORED_SERVER::log_connect_error(mxs_connect_result_t rval)
|
||||
mysql_error(con));
|
||||
}
|
||||
|
||||
void MXS_MONITORED_SERVER::log_state_change()
|
||||
void MonitorServer::log_state_change()
|
||||
{
|
||||
string prev = SERVER::status_to_string(mon_prev_status);
|
||||
string next = server->status_string();
|
||||
@ -1728,7 +1728,7 @@ void MXS_MONITORED_SERVER::log_state_change()
|
||||
|
||||
void Monitor::hangup_failed_servers()
|
||||
{
|
||||
for (MXS_MONITORED_SERVER* ptr : m_servers)
|
||||
for (MonitorServer* ptr : m_servers)
|
||||
{
|
||||
if (ptr->status_changed() && (!(ptr->server->is_usable()) || !(ptr->server->is_in_cluster())))
|
||||
{
|
||||
@ -1737,7 +1737,7 @@ void Monitor::hangup_failed_servers()
|
||||
}
|
||||
}
|
||||
|
||||
void MXS_MONITORED_SERVER::mon_report_query_error()
|
||||
void MonitorServer::mon_report_query_error()
|
||||
{
|
||||
MXS_ERROR("Failed to execute query on server '%s' ([%s]:%d): %s",
|
||||
server->name(),
|
||||
@ -1761,28 +1761,28 @@ void Monitor::check_maintenance_requests()
|
||||
{
|
||||
// The only server status bit the admin may change is the [Maintenance] bit.
|
||||
int admin_msg = atomic_exchange_int(&ptr->status_request,
|
||||
MXS_MONITORED_SERVER::NO_CHANGE);
|
||||
MonitorServer::NO_CHANGE);
|
||||
|
||||
switch (admin_msg)
|
||||
{
|
||||
case MXS_MONITORED_SERVER::MAINT_ON:
|
||||
case MonitorServer::MAINT_ON:
|
||||
// TODO: Change to writing MONITORED_SERVER->pending status instead once cleanup done.
|
||||
ptr->server->set_status(SERVER_MAINT);
|
||||
break;
|
||||
|
||||
case MXS_MONITORED_SERVER::MAINT_OFF:
|
||||
case MonitorServer::MAINT_OFF:
|
||||
ptr->server->clear_status(SERVER_MAINT);
|
||||
break;
|
||||
|
||||
case MXS_MONITORED_SERVER::BEING_DRAINED_ON:
|
||||
case MonitorServer::BEING_DRAINED_ON:
|
||||
ptr->server->set_status(SERVER_BEING_DRAINED);
|
||||
break;
|
||||
|
||||
case MXS_MONITORED_SERVER::BEING_DRAINED_OFF:
|
||||
case MonitorServer::BEING_DRAINED_OFF:
|
||||
ptr->server->clear_status(SERVER_BEING_DRAINED);
|
||||
break;
|
||||
|
||||
case MXS_MONITORED_SERVER::NO_CHANGE:
|
||||
case MonitorServer::NO_CHANGE:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1797,7 +1797,7 @@ void Monitor::detect_handle_state_changes()
|
||||
bool master_down = false;
|
||||
bool master_up = false;
|
||||
|
||||
for (MXS_MONITORED_SERVER* ptr : m_servers)
|
||||
for (MonitorServer* ptr : m_servers)
|
||||
{
|
||||
if (ptr->status_changed())
|
||||
{
|
||||
@ -1872,13 +1872,13 @@ FILE* Monitor::open_data_file(Monitor* monitor, char* path)
|
||||
return rval;
|
||||
}
|
||||
|
||||
void Monitor::store_server_journal(MXS_MONITORED_SERVER* master)
|
||||
void Monitor::store_server_journal(MonitorServer* master)
|
||||
{
|
||||
auto monitor = this; // TODO: cleanup later
|
||||
/** Calculate how much memory we need to allocate */
|
||||
uint32_t size = MMB_LEN_SCHEMA_VERSION + MMB_LEN_CRC32;
|
||||
|
||||
for (MXS_MONITORED_SERVER* db : m_servers)
|
||||
for (MonitorServer* db : m_servers)
|
||||
{
|
||||
/** Each server is stored as a type byte and a null-terminated string
|
||||
* followed by eight byte server status. */
|
||||
@ -1937,7 +1937,7 @@ void Monitor::store_server_journal(MXS_MONITORED_SERVER* master)
|
||||
MXS_FREE(data);
|
||||
}
|
||||
|
||||
void Monitor::load_server_journal(MXS_MONITORED_SERVER** master)
|
||||
void Monitor::load_server_journal(MonitorServer** master)
|
||||
{
|
||||
auto monitor = this; // TODO: cleanup later
|
||||
char path[PATH_MAX];
|
||||
@ -2073,7 +2073,7 @@ bool Monitor::journal_is_stale() const
|
||||
return is_stale;
|
||||
}
|
||||
|
||||
MXS_MONITORED_SERVER* Monitor::get_monitored_server(SERVER* search_server)
|
||||
MonitorServer* Monitor::get_monitored_server(SERVER* search_server)
|
||||
{
|
||||
mxb_assert(search_server);
|
||||
for (const auto iter : m_servers)
|
||||
@ -2086,9 +2086,9 @@ MXS_MONITORED_SERVER* Monitor::get_monitored_server(SERVER* search_server)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<MXS_MONITORED_SERVER*> Monitor::get_monitored_serverlist(const string& key, bool* error_out)
|
||||
std::vector<MonitorServer*> Monitor::get_monitored_serverlist(const string& key, bool* error_out)
|
||||
{
|
||||
std::vector<MXS_MONITORED_SERVER*> monitored_array;
|
||||
std::vector<MonitorServer*> monitored_array;
|
||||
// Check that value exists.
|
||||
if (!parameters.contains(key))
|
||||
{
|
||||
@ -2102,7 +2102,7 @@ std::vector<MXS_MONITORED_SERVER*> Monitor::get_monitored_serverlist(const strin
|
||||
// All servers in the array must be monitored by the given monitor.
|
||||
for (auto elem : servers)
|
||||
{
|
||||
MXS_MONITORED_SERVER* mon_serv = get_monitored_server(elem);
|
||||
MonitorServer* mon_serv = get_monitored_server(elem);
|
||||
if (mon_serv)
|
||||
{
|
||||
monitored_array.push_back(mon_serv);
|
||||
@ -2153,7 +2153,7 @@ const char WRN_REQUEST_OVERWRITTEN[] =
|
||||
|
||||
bool Monitor::set_server_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
{
|
||||
MXS_MONITORED_SERVER* msrv = get_monitored_server(srv);
|
||||
MonitorServer* msrv = get_monitored_server(srv);
|
||||
mxb_assert(msrv);
|
||||
|
||||
if (!msrv)
|
||||
@ -2185,18 +2185,18 @@ bool Monitor::set_server_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
int request;
|
||||
if (bit & SERVER_MAINT)
|
||||
{
|
||||
request = MXS_MONITORED_SERVER::MAINT_ON;
|
||||
request = MonitorServer::MAINT_ON;
|
||||
}
|
||||
else
|
||||
{
|
||||
mxb_assert(bit & SERVER_BEING_DRAINED);
|
||||
request = MXS_MONITORED_SERVER::BEING_DRAINED_ON;
|
||||
request = MonitorServer::BEING_DRAINED_ON;
|
||||
}
|
||||
|
||||
int previous_request = atomic_exchange_int(&msrv->status_request, request);
|
||||
written = true;
|
||||
// Warn if the previous request hasn't been read.
|
||||
if (previous_request != MXS_MONITORED_SERVER::NO_CHANGE)
|
||||
if (previous_request != MonitorServer::NO_CHANGE)
|
||||
{
|
||||
MXS_WARNING(WRN_REQUEST_OVERWRITTEN);
|
||||
}
|
||||
@ -2216,7 +2216,7 @@ bool Monitor::set_server_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
|
||||
bool Monitor::clear_server_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
{
|
||||
MXS_MONITORED_SERVER* msrv = get_monitored_server(srv);
|
||||
MonitorServer* msrv = get_monitored_server(srv);
|
||||
mxb_assert(msrv);
|
||||
|
||||
if (!msrv)
|
||||
@ -2243,18 +2243,18 @@ bool Monitor::clear_server_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
int request;
|
||||
if (bit & SERVER_MAINT)
|
||||
{
|
||||
request = MXS_MONITORED_SERVER::MAINT_OFF;
|
||||
request = MonitorServer::MAINT_OFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
mxb_assert(bit & SERVER_BEING_DRAINED);
|
||||
request = MXS_MONITORED_SERVER::BEING_DRAINED_OFF;
|
||||
request = MonitorServer::BEING_DRAINED_OFF;
|
||||
}
|
||||
|
||||
int previous_request = atomic_exchange_int(&msrv->status_request, request);
|
||||
written = true;
|
||||
// Warn if the previous request hasn't been read.
|
||||
if (previous_request != MXS_MONITORED_SERVER::NO_CHANGE)
|
||||
if (previous_request != MonitorServer::NO_CHANGE)
|
||||
{
|
||||
MXS_WARNING(WRN_REQUEST_OVERWRITTEN);
|
||||
}
|
||||
@ -2276,7 +2276,7 @@ void Monitor::populate_services()
|
||||
{
|
||||
mxb_assert(state() == MONITOR_STATE_STOPPED);
|
||||
|
||||
for (MXS_MONITORED_SERVER* pMs : m_servers)
|
||||
for (MonitorServer* pMs : m_servers)
|
||||
{
|
||||
service_add_server(this, pMs->server);
|
||||
}
|
||||
@ -2393,7 +2393,7 @@ int64_t MonitorWorker::get_time_ms()
|
||||
return t.tv_sec * 1000 + (t.tv_nsec / 1000000);
|
||||
}
|
||||
|
||||
bool MonitorWorker::should_update_disk_space_status(const MXS_MONITORED_SERVER* pMs) const
|
||||
bool MonitorWorker::should_update_disk_space_status(const MonitorServer* pMs) const
|
||||
{
|
||||
bool should_check = false;
|
||||
|
||||
@ -2414,7 +2414,7 @@ bool MonitorWorker::should_update_disk_space_status(const MXS_MONITORED_SERVER*
|
||||
namespace
|
||||
{
|
||||
|
||||
bool check_disk_space_exhausted(MXS_MONITORED_SERVER* pMs,
|
||||
bool check_disk_space_exhausted(MonitorServer* pMs,
|
||||
const std::string& path,
|
||||
const maxscale::disk::SizesAndName& san,
|
||||
int32_t max_percentage)
|
||||
@ -2439,7 +2439,7 @@ bool check_disk_space_exhausted(MXS_MONITORED_SERVER* pMs,
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorWorker::update_disk_space_status(MXS_MONITORED_SERVER* pMs)
|
||||
void MonitorWorker::update_disk_space_status(MonitorServer* pMs)
|
||||
{
|
||||
std::map<std::string, disk::SizesAndName> info;
|
||||
|
||||
@ -2554,7 +2554,7 @@ bool MonitorWorker::has_sufficient_permissions()
|
||||
|
||||
void MonitorWorker::flush_server_status()
|
||||
{
|
||||
for (MXS_MONITORED_SERVER* pMs : m_servers)
|
||||
for (MonitorServer* pMs : m_servers)
|
||||
{
|
||||
if (!pMs->server->is_in_maint())
|
||||
{
|
||||
@ -2575,7 +2575,7 @@ void MonitorWorkerSimple::tick()
|
||||
{
|
||||
pre_tick();
|
||||
|
||||
for (MXS_MONITORED_SERVER* pMs : m_servers)
|
||||
for (MonitorServer* pMs : m_servers)
|
||||
{
|
||||
if (!pMs->server->is_in_maint())
|
||||
{
|
||||
@ -2742,13 +2742,13 @@ bool MonitorWorker::immediate_tick_required() const
|
||||
}
|
||||
}
|
||||
|
||||
MXS_MONITORED_SERVER::MXS_MONITORED_SERVER(SERVER* server)
|
||||
MonitorServer::MonitorServer(SERVER* server)
|
||||
: server(server)
|
||||
, disk_space_checked(maxscale::MonitorWorker::get_time_ms()) // Pretend disk space was just checked.
|
||||
{
|
||||
}
|
||||
|
||||
MXS_MONITORED_SERVER::~MXS_MONITORED_SERVER()
|
||||
MonitorServer::~MonitorServer()
|
||||
{
|
||||
if (con)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <maxscale/modinfo.h>
|
||||
#include <maxscale/mysql_utils.hh>
|
||||
|
||||
using maxscale::MXS_MONITORED_SERVER;
|
||||
using maxscale::MonitorServer;
|
||||
|
||||
AuroraMonitor::AuroraMonitor(const std::string& name, const std::string& module)
|
||||
: MonitorWorkerSimple(name, module)
|
||||
@ -56,7 +56,7 @@ bool AuroraMonitor::has_sufficient_permissions()
|
||||
*
|
||||
* @param monitored_server Server whose status should be updated
|
||||
*/
|
||||
void AuroraMonitor::update_server_status(MXS_MONITORED_SERVER* monitored_server)
|
||||
void AuroraMonitor::update_server_status(MonitorServer* monitored_server)
|
||||
{
|
||||
monitored_server->clear_pending_status(SERVER_MASTER | SERVER_SLAVE);
|
||||
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
|
||||
protected:
|
||||
bool has_sufficient_permissions();
|
||||
void update_server_status(mxs::MXS_MONITORED_SERVER* monitored_server);
|
||||
void update_server_status(mxs::MonitorServer* monitored_server);
|
||||
|
||||
private:
|
||||
AuroraMonitor(const std::string& name, const std::string& module);
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <maxbase/assert.h>
|
||||
|
||||
using maxscale::Monitor;
|
||||
using maxscale::MXS_MONITORED_SERVER;
|
||||
using maxscale::MonitorServer;
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -206,7 +206,7 @@ bool Clustrix::is_being_softfailed(const char* zName, const SERVER& server, MYSQ
|
||||
}
|
||||
|
||||
bool Clustrix::ping_or_connect_to_hub(const char* zName,
|
||||
const MXS_MONITORED_SERVER::ConnectionSettings& settings,
|
||||
const MonitorServer::ConnectionSettings& settings,
|
||||
Softfailed softfailed,
|
||||
SERVER& server,
|
||||
MYSQL** ppCon)
|
||||
|
@ -65,7 +65,7 @@ bool is_part_of_the_quorum(const char* zName, const SERVER& server, MYSQL* pCon)
|
||||
*
|
||||
* @return True, if the node is part of the quorum, false otherwise.
|
||||
*/
|
||||
inline bool is_part_of_the_quorum(const char* zName, mxs::MXS_MONITORED_SERVER& ms)
|
||||
inline bool is_part_of_the_quorum(const char* zName, mxs::MonitorServer& ms)
|
||||
{
|
||||
mxb_assert(ms.server);
|
||||
mxb_assert(ms.con);
|
||||
@ -100,7 +100,7 @@ bool is_being_softfailed(const char* zName, const SERVER& server, MYSQL* pCon);
|
||||
* @note Upon return @c *ppCon will be non-NULL.
|
||||
*/
|
||||
bool ping_or_connect_to_hub(const char* zName,
|
||||
const mxs::MXS_MONITORED_SERVER::ConnectionSettings& settings,
|
||||
const mxs::MonitorServer::ConnectionSettings& settings,
|
||||
Softfailed softfailed,
|
||||
SERVER& server,
|
||||
MYSQL** ppCon);
|
||||
@ -117,9 +117,9 @@ bool ping_or_connect_to_hub(const char* zName,
|
||||
* @return True, if the server can be used as hub, false otherwise.
|
||||
*/
|
||||
inline bool ping_or_connect_to_hub(const char* zName,
|
||||
const mxs::MXS_MONITORED_SERVER::ConnectionSettings& settings,
|
||||
const mxs::MonitorServer::ConnectionSettings& settings,
|
||||
Softfailed softfailed,
|
||||
mxs::MXS_MONITORED_SERVER& ms)
|
||||
mxs::MonitorServer& ms)
|
||||
{
|
||||
return ping_or_connect_to_hub(zName, settings, softfailed, *ms.server, &ms.con);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
namespace http = mxb::http;
|
||||
using namespace std;
|
||||
using maxscale::MXS_MONITORED_SERVER;
|
||||
using maxscale::MonitorServer;
|
||||
|
||||
#define LOG_JSON_ERROR(ppJson, format, ...) \
|
||||
do { \
|
||||
@ -215,7 +215,7 @@ void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed)
|
||||
|
||||
for (auto it = m_servers.begin(); !pHub_con && (it != m_servers.end()); ++it)
|
||||
{
|
||||
MXS_MONITORED_SERVER& ms = **it;
|
||||
MonitorServer& ms = **it;
|
||||
|
||||
if (ips.find(ms.server->address) == ips.end())
|
||||
{
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "clustrix.hh"
|
||||
|
||||
bool ClustrixNode::can_be_used_as_hub(const char* zName,
|
||||
const mxs::MXS_MONITORED_SERVER::ConnectionSettings& settings)
|
||||
const mxs::MonitorServer::ConnectionSettings& settings)
|
||||
{
|
||||
mxb_assert(m_pServer);
|
||||
bool rv = Clustrix::ping_or_connect_to_hub(zName, settings, Clustrix::Softfailed::REJECT,
|
||||
|
@ -161,7 +161,7 @@ public:
|
||||
}
|
||||
|
||||
bool can_be_used_as_hub(const char* zName,
|
||||
const mxs::MXS_MONITORED_SERVER::ConnectionSettings& settings);
|
||||
const mxs::MonitorServer::ConnectionSettings& settings);
|
||||
|
||||
SERVER* server() const
|
||||
{
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <maxscale/modinfo.h>
|
||||
#include <maxscale/mysql_utils.hh>
|
||||
|
||||
using maxscale::MXS_MONITORED_SERVER;
|
||||
using maxscale::MonitorServer;
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -31,7 +31,7 @@ constexpr const char* alive_query = "SELECT mcsSystemReady() = 1 && mcsSystemRea
|
||||
constexpr const char* role_query = "SELECT mcsSystemPrimary()";
|
||||
|
||||
// Helper for extracting string results from queries
|
||||
static std::string do_query(MXS_MONITORED_SERVER* srv, const char* query)
|
||||
static std::string do_query(MonitorServer* srv, const char* query)
|
||||
{
|
||||
std::string rval;
|
||||
MYSQL_RES* result;
|
||||
@ -56,7 +56,7 @@ static std::string do_query(MXS_MONITORED_SERVER* srv, const char* query)
|
||||
}
|
||||
|
||||
// Returns a numeric version similar to mysql_get_server_version
|
||||
int get_cs_version(MXS_MONITORED_SERVER* srv)
|
||||
int get_cs_version(MonitorServer* srv)
|
||||
{
|
||||
// GCC 4.8 appears to have a broken std::regex_constants::ECMAScript that doesn't support brackets
|
||||
std::regex re("Columnstore \\([0-9]*\\)[.]\\([0-9]*\\)[.]\\([0-9]*\\)-[0-9]*",
|
||||
@ -95,7 +95,7 @@ bool CsMonitor::has_sufficient_permissions()
|
||||
return test_permissions(alive_query);
|
||||
}
|
||||
|
||||
void CsMonitor::update_server_status(MXS_MONITORED_SERVER* srv)
|
||||
void CsMonitor::update_server_status(MonitorServer* srv)
|
||||
{
|
||||
srv->clear_pending_status(SERVER_MASTER | SERVER_SLAVE | SERVER_RUNNING);
|
||||
int status = 0;
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
|
||||
protected:
|
||||
bool has_sufficient_permissions();
|
||||
void update_server_status(mxs::MXS_MONITORED_SERVER* monitored_server);
|
||||
void update_server_status(mxs::MonitorServer* monitored_server);
|
||||
|
||||
private:
|
||||
CsMonitor(const std::string& name, const std::string& module);
|
||||
|
@ -33,16 +33,16 @@
|
||||
#define DONOR_NODE_NAME_MAX_LEN 60
|
||||
#define DONOR_LIST_SET_VAR "SET GLOBAL wsrep_sst_donor = \""
|
||||
|
||||
using maxscale::MXS_MONITORED_SERVER;
|
||||
using maxscale::MonitorServer;
|
||||
|
||||
/** Log a warning when a bad 'wsrep_local_index' is found */
|
||||
static bool warn_erange_on_local_index = true;
|
||||
|
||||
static MXS_MONITORED_SERVER* set_cluster_master(MXS_MONITORED_SERVER*, MXS_MONITORED_SERVER*, int);
|
||||
static MonitorServer* set_cluster_master(MonitorServer*, MonitorServer*, int);
|
||||
static void disableMasterFailback(void*, int);
|
||||
static int compare_node_index(const void*, const void*);
|
||||
static int compare_node_priority(const void*, const void*);
|
||||
static bool using_xtrabackup(MXS_MONITORED_SERVER* database, const char* server_string);
|
||||
static bool using_xtrabackup(MonitorServer* database, const char* server_string);
|
||||
|
||||
GaleraMonitor::GaleraMonitor(const std::string& name, const std::string& module)
|
||||
: MonitorWorkerSimple(name, module)
|
||||
@ -130,7 +130,7 @@ bool GaleraMonitor::has_sufficient_permissions()
|
||||
return test_permissions("SHOW STATUS LIKE 'wsrep_local_state'");
|
||||
}
|
||||
|
||||
void GaleraMonitor::update_server_status(MXS_MONITORED_SERVER* monitored_server)
|
||||
void GaleraMonitor::update_server_status(MonitorServer* monitored_server)
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES* result;
|
||||
@ -254,7 +254,7 @@ void GaleraMonitor::post_tick()
|
||||
*/
|
||||
|
||||
/* get the candidate master, following MXS_MIN(node_id) rule */
|
||||
MXS_MONITORED_SERVER* candidate_master = get_candidate_master();
|
||||
MonitorServer* candidate_master = get_candidate_master();
|
||||
|
||||
m_master = set_cluster_master(m_master, candidate_master, m_disableMasterFailback);
|
||||
|
||||
@ -318,7 +318,7 @@ void GaleraMonitor::post_tick()
|
||||
}
|
||||
}
|
||||
|
||||
static bool using_xtrabackup(MXS_MONITORED_SERVER* database, const char* server_string)
|
||||
static bool using_xtrabackup(MonitorServer* database, const char* server_string)
|
||||
{
|
||||
bool rval = false;
|
||||
MYSQL_RES* result;
|
||||
@ -365,9 +365,9 @@ static bool using_xtrabackup(MXS_MONITORED_SERVER* database, const char* server_
|
||||
* @param servers The monitored servers list
|
||||
* @return The candidate master on success, NULL on failure
|
||||
*/
|
||||
MXS_MONITORED_SERVER* GaleraMonitor::get_candidate_master()
|
||||
MonitorServer* GaleraMonitor::get_candidate_master()
|
||||
{
|
||||
MXS_MONITORED_SERVER* candidate_master = NULL;
|
||||
MonitorServer* candidate_master = NULL;
|
||||
long min_id = -1;
|
||||
int minval = INT_MAX;
|
||||
int currval;
|
||||
@ -437,9 +437,9 @@ MXS_MONITORED_SERVER* GaleraMonitor::get_candidate_master()
|
||||
* @param candidate_master The candidate master server accordingly to the selection rule
|
||||
* @return The master node pointer (could be NULL)
|
||||
*/
|
||||
static MXS_MONITORED_SERVER* set_cluster_master(MXS_MONITORED_SERVER* current_master,
|
||||
MXS_MONITORED_SERVER* candidate_master,
|
||||
int master_stickiness)
|
||||
static MonitorServer* set_cluster_master(MonitorServer* current_master,
|
||||
MonitorServer* candidate_master,
|
||||
int master_stickiness)
|
||||
{
|
||||
/*
|
||||
* if current master is not set or master_stickiness is not enable
|
||||
@ -488,7 +488,7 @@ static MXS_MONITORED_SERVER* set_cluster_master(MXS_MONITORED_SERVER* current_ma
|
||||
*/
|
||||
void GaleraMonitor::update_sst_donor_nodes(int is_cluster)
|
||||
{
|
||||
MXS_MONITORED_SERVER* ptr;
|
||||
MonitorServer* ptr;
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES* result;
|
||||
bool ignore_priority = true;
|
||||
@ -499,7 +499,7 @@ void GaleraMonitor::update_sst_donor_nodes(int is_cluster)
|
||||
}
|
||||
|
||||
unsigned int found_slaves = 0;
|
||||
MXS_MONITORED_SERVER* node_list[is_cluster - 1];
|
||||
MonitorServer* node_list[is_cluster - 1];
|
||||
/* Donor list size = DONOR_LIST_SET_VAR + n_hosts * max_host_len + n_hosts + 1 */
|
||||
|
||||
char* donor_list = static_cast<char*>(MXS_CALLOC(1,
|
||||
@ -520,7 +520,7 @@ void GaleraMonitor::update_sst_donor_nodes(int is_cluster)
|
||||
{
|
||||
if ((ptr->pending_status & SERVER_JOINED) && (ptr->pending_status & SERVER_SLAVE))
|
||||
{
|
||||
node_list[found_slaves] = (MXS_MONITORED_SERVER*)ptr;
|
||||
node_list[found_slaves] = (MonitorServer*)ptr;
|
||||
found_slaves++;
|
||||
|
||||
/* Check the server parameter "priority"
|
||||
@ -541,13 +541,13 @@ void GaleraMonitor::update_sst_donor_nodes(int is_cluster)
|
||||
/* Sort the array */
|
||||
qsort(node_list,
|
||||
found_slaves,
|
||||
sizeof(MXS_MONITORED_SERVER*),
|
||||
sizeof(MonitorServer*),
|
||||
sort_order ? compare_node_priority : compare_node_index);
|
||||
|
||||
/* Select nodename from each server and append it to node_list */
|
||||
for (unsigned int k = 0; k < found_slaves; k++)
|
||||
{
|
||||
MXS_MONITORED_SERVER* ptr = node_list[k];
|
||||
MonitorServer* ptr = node_list[k];
|
||||
|
||||
/* Get the Galera node name */
|
||||
if (mxs_mysql_query(ptr->con, "SHOW VARIABLES LIKE 'wsrep_node_name'") == 0
|
||||
@ -586,7 +586,7 @@ void GaleraMonitor::update_sst_donor_nodes(int is_cluster)
|
||||
/* Set now rep_sst_donor in each slave node */
|
||||
for (unsigned int k = 0; k < found_slaves; k++)
|
||||
{
|
||||
MXS_MONITORED_SERVER* ptr = node_list[k];
|
||||
MonitorServer* ptr = node_list[k];
|
||||
if (mxs_mysql_query(ptr->con, donor_list) != 0)
|
||||
{
|
||||
ptr->mon_report_query_error();
|
||||
@ -611,8 +611,8 @@ void GaleraMonitor::update_sst_donor_nodes(int is_cluster)
|
||||
|
||||
static int compare_node_index(const void* a, const void* b)
|
||||
{
|
||||
const MXS_MONITORED_SERVER* s_a = *(MXS_MONITORED_SERVER* const*)a;
|
||||
const MXS_MONITORED_SERVER* s_b = *(MXS_MONITORED_SERVER* const*)b;
|
||||
const MonitorServer* s_a = *(MonitorServer* const*)a;
|
||||
const MonitorServer* s_b = *(MonitorServer* const*)b;
|
||||
|
||||
// Order is DESC: b - a
|
||||
return s_b->server->node_id - s_a->server->node_id;
|
||||
@ -639,8 +639,8 @@ static int compare_node_index(const void* a, const void* b)
|
||||
|
||||
static int compare_node_priority(const void* a, const void* b)
|
||||
{
|
||||
const MXS_MONITORED_SERVER* s_a = *(MXS_MONITORED_SERVER* const*)a;
|
||||
const MXS_MONITORED_SERVER* s_b = *(MXS_MONITORED_SERVER* const*)b;
|
||||
const MonitorServer* s_a = *(MonitorServer* const*)a;
|
||||
const MonitorServer* s_b = *(MonitorServer* const*)b;
|
||||
std::string pri_a = s_a->server->get_custom_parameter("priority");
|
||||
std::string pri_b = s_b->server->get_custom_parameter("priority");
|
||||
bool have_a = !pri_a.empty();
|
||||
|
@ -32,7 +32,7 @@ struct GaleraNode
|
||||
std::string cluster_uuid; /**< Cluster UUID */
|
||||
};
|
||||
|
||||
typedef std::unordered_map<mxs::MXS_MONITORED_SERVER*, GaleraNode> NodeMap;
|
||||
typedef std::unordered_map<mxs::MonitorServer*, GaleraNode> NodeMap;
|
||||
|
||||
class GaleraMonitor : public maxscale::MonitorWorkerSimple
|
||||
{
|
||||
@ -48,7 +48,7 @@ public:
|
||||
protected:
|
||||
bool configure(const MXS_CONFIG_PARAMETER* param);
|
||||
bool has_sufficient_permissions();
|
||||
void update_server_status(mxs::MXS_MONITORED_SERVER* monitored_server);
|
||||
void update_server_status(mxs::MonitorServer* monitored_server);
|
||||
void pre_tick();
|
||||
void post_tick();
|
||||
|
||||
@ -71,7 +71,7 @@ private:
|
||||
bool detect_cluster_size(const int n_nodes,
|
||||
const char* candidate_uuid,
|
||||
const int candidate_size);
|
||||
mxs::MXS_MONITORED_SERVER* get_candidate_master();
|
||||
mxs::MonitorServer* get_candidate_master();
|
||||
void set_galera_cluster();
|
||||
void update_sst_donor_nodes(int is_cluster);
|
||||
};
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <maxscale/protocol/mysql.hh>
|
||||
#include <mysqld_error.h>
|
||||
|
||||
using maxscale::MXS_MONITORED_SERVER;
|
||||
using maxscale::MonitorServer;
|
||||
|
||||
GRMon::GRMon(const std::string& name, const std::string& module)
|
||||
: MonitorWorkerSimple(name, module)
|
||||
@ -54,7 +54,7 @@ static inline bool is_false(const char* value)
|
||||
|| strcasecmp(value, "false") == 0;
|
||||
}
|
||||
|
||||
static bool is_master(MXS_MONITORED_SERVER* server)
|
||||
static bool is_master(MonitorServer* server)
|
||||
{
|
||||
bool rval = false;
|
||||
MYSQL_RES* result;
|
||||
@ -81,7 +81,7 @@ static bool is_master(MXS_MONITORED_SERVER* server)
|
||||
return rval;
|
||||
}
|
||||
|
||||
static bool is_slave(MXS_MONITORED_SERVER* server)
|
||||
static bool is_slave(MonitorServer* server)
|
||||
{
|
||||
bool rval = false;
|
||||
MYSQL_RES* result;
|
||||
@ -108,7 +108,7 @@ static bool is_slave(MXS_MONITORED_SERVER* server)
|
||||
return rval;
|
||||
}
|
||||
|
||||
void GRMon::update_server_status(MXS_MONITORED_SERVER* monitored_server)
|
||||
void GRMon::update_server_status(MonitorServer* monitored_server)
|
||||
{
|
||||
if (is_master(monitored_server))
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
|
||||
protected:
|
||||
bool has_sufficient_permissions();
|
||||
void update_server_status(mxs::MXS_MONITORED_SERVER* monitored_server);
|
||||
void update_server_status(mxs::MonitorServer* monitored_server);
|
||||
|
||||
private:
|
||||
GRMon(const std::string& name, const std::string& module);
|
||||
|
@ -33,7 +33,7 @@
|
||||
using std::string;
|
||||
using maxbase::string_printf;
|
||||
using maxscale::Monitor;
|
||||
using maxscale::MXS_MONITORED_SERVER;
|
||||
using maxscale::MonitorServer;
|
||||
|
||||
// Config parameter names
|
||||
const char* const CN_AUTO_FAILOVER = "auto_failover";
|
||||
@ -134,7 +134,7 @@ MariaDBServer* MariaDBMonitor::get_server(int64_t id)
|
||||
return (found != m_servers_by_id.end()) ? (*found).second : NULL;
|
||||
}
|
||||
|
||||
MariaDBServer* MariaDBMonitor::get_server(MXS_MONITORED_SERVER* mon_server)
|
||||
MariaDBServer* MariaDBMonitor::get_server(MonitorServer* mon_server)
|
||||
{
|
||||
return get_server(mon_server->server);
|
||||
}
|
||||
@ -336,7 +336,7 @@ json_t* MariaDBMonitor::to_json() const
|
||||
*/
|
||||
void MariaDBMonitor::update_server(MariaDBServer* server)
|
||||
{
|
||||
MXS_MONITORED_SERVER* mon_srv = server->m_server_base;
|
||||
MonitorServer* mon_srv = server->m_server_base;
|
||||
mxs_connect_result_t conn_status = mon_srv->ping_or_connect(m_settings.conn_settings);
|
||||
MYSQL* conn = mon_srv->con; // mon_ping_or_connect_to_db() may have reallocated the MYSQL struct.
|
||||
|
||||
@ -423,7 +423,7 @@ void MariaDBMonitor::pre_loop()
|
||||
|
||||
void MariaDBMonitor::tick()
|
||||
{
|
||||
/* Update MXS_MONITORED_SERVER->pending_status. This is where the monitor loop writes it's findings.
|
||||
/* Update MonitorServer->pending_status. This is where the monitor loop writes it's findings.
|
||||
* Also, backup current status so that it can be compared to any deduced state. */
|
||||
for (auto srv : m_servers)
|
||||
{
|
||||
@ -636,7 +636,7 @@ void MariaDBMonitor::update_external_master()
|
||||
|
||||
void MariaDBMonitor::log_master_changes()
|
||||
{
|
||||
MXS_MONITORED_SERVER* root_master = m_master ? m_master->m_server_base : NULL;
|
||||
MonitorServer* root_master = m_master ? m_master->m_server_base : NULL;
|
||||
if (root_master && root_master->status_changed()
|
||||
&& !(root_master->pending_status & SERVER_WAS_MASTER))
|
||||
{
|
||||
|
@ -251,7 +251,7 @@ private:
|
||||
|
||||
MariaDBServer* get_server(const std::string& host, int port);
|
||||
MariaDBServer* get_server(int64_t id);
|
||||
MariaDBServer* get_server(mxs::MXS_MONITORED_SERVER* mon_server);
|
||||
MariaDBServer* get_server(mxs::MonitorServer* mon_server);
|
||||
MariaDBServer* get_server(SERVER* server);
|
||||
|
||||
// Cluster discovery and status assignment methods, top levels
|
||||
|
@ -28,9 +28,9 @@ using maxbase::Duration;
|
||||
using maxbase::StopWatch;
|
||||
using maxsql::QueryResult;
|
||||
using Guard = std::lock_guard<std::mutex>;
|
||||
using maxscale::MXS_MONITORED_SERVER;
|
||||
using maxscale::MonitorServer;
|
||||
|
||||
MariaDBServer::MariaDBServer(MXS_MONITORED_SERVER* monitored_server, int config_index,
|
||||
MariaDBServer::MariaDBServer(MonitorServer* monitored_server, int config_index,
|
||||
bool assume_unique_hostnames, bool query_events)
|
||||
: m_server_base(monitored_server)
|
||||
, m_config_index(config_index)
|
||||
|
@ -73,7 +73,7 @@ struct NodeData
|
||||
class MariaDBServer
|
||||
{
|
||||
public:
|
||||
MariaDBServer(mxs::MXS_MONITORED_SERVER* monitored_server, int config_index,
|
||||
MariaDBServer(mxs::MonitorServer* monitored_server, int config_index,
|
||||
bool assume_unique_hostnames, bool query_events);
|
||||
|
||||
class EventInfo
|
||||
@ -119,7 +119,7 @@ public:
|
||||
|
||||
/* Monitored server base class/struct. MariaDBServer does not own the struct, it is not freed
|
||||
* (or connection closed) when a MariaDBServer is destroyed. */
|
||||
mxs::MXS_MONITORED_SERVER* m_server_base = NULL;
|
||||
mxs::MonitorServer* m_server_base = NULL;
|
||||
/* What position this server has in the monitor config? Used for tiebreaking between servers. */
|
||||
int m_config_index = 0;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
using std::string;
|
||||
using std::cout;
|
||||
using maxscale::MXS_MONITORED_SERVER;
|
||||
using maxscale::MonitorServer;
|
||||
|
||||
// Maximum sizes for array types
|
||||
const int MAX_CYCLE_SIZE = 10;
|
||||
@ -159,7 +159,7 @@ void MariaDBMonitor::Test::init_servers(int count)
|
||||
{
|
||||
// Server contents mostly undefined
|
||||
auto base_server = Server::create_test_server();
|
||||
MXS_MONITORED_SERVER* mon_server = new MXS_MONITORED_SERVER(base_server);
|
||||
MonitorServer* mon_server = new MonitorServer(base_server);
|
||||
MariaDBServer* mariadb_server = new MariaDBServer(mon_server, i - 1, m_use_hostnames, true);
|
||||
|
||||
if (m_use_hostnames)
|
||||
|
@ -42,7 +42,7 @@ bool NDBCMonitor::has_sufficient_permissions()
|
||||
return test_permissions("SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'");
|
||||
}
|
||||
|
||||
void NDBCMonitor::update_server_status(mxs::MXS_MONITORED_SERVER* monitored_server)
|
||||
void NDBCMonitor::update_server_status(mxs::MonitorServer* monitored_server)
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES* result;
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
|
||||
protected:
|
||||
bool has_sufficient_permissions();
|
||||
void update_server_status(mxs::MXS_MONITORED_SERVER* monitored_server);
|
||||
void update_server_status(mxs::MonitorServer* monitored_server);
|
||||
|
||||
private:
|
||||
NDBCMonitor(const std::string& name, const std::string& module);
|
||||
|
Loading…
x
Reference in New Issue
Block a user