Moved common functions to monitor_common.c

This commit is contained in:
Markus Makela
2015-05-09 14:29:26 +03:00
parent 8af302d785
commit 0c15812340
7 changed files with 63 additions and 127 deletions

View File

@ -77,8 +77,6 @@ static void *startMonitor(void *,void*);
static void stopMonitor(void *);
static void diagnostics(DCB *, void *);
static void defaultId(void *, unsigned long);
static bool mon_status_changed(MONITOR_SERVERS* mon_srv);
static bool mon_print_fail_status(MONITOR_SERVERS* mon_srv);
static MONITOR_SERVERS *getServerByNodeId(MONITOR_SERVERS *, long);
static MONITOR_SERVERS *getSlaveOfNodeId(MONITOR_SERVERS *, long);
static MONITOR_SERVERS *get_replication_tree(MONITOR *, int);
@ -807,55 +805,6 @@ MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
memcpy(&handle->detectStaleMaster, &enable, sizeof(int));
}
/**
* Check if current monitored server status has changed
*
* @param mon_srv The monitored server
* @return true if status has changed or false
*/
static bool mon_status_changed(
MONITOR_SERVERS* mon_srv)
{
bool succp;
/** This is the first time the server was set with a status*/
if (mon_srv->mon_prev_status == -1)
return false;
if (mon_srv->mon_prev_status != mon_srv->server->status)
{
succp = true;
}
else
{
succp = false;
}
return succp;
}
/**
* Check if current monitored server has a loggable failure status
*
* @param mon_srv The monitored server
* @return true if failed status can be logged or false
*/
static bool mon_print_fail_status(
MONITOR_SERVERS* mon_srv)
{
bool succp;
int errcount = mon_srv->mon_err_count;
if (SERVER_IS_DOWN(mon_srv->server) && errcount == 0)
{
succp = true;
}
else
{
succp = false;
}
return succp;
}
/**
* Fetch a MySQL node by node_id
*