Monitor_common formatting changes

Cleaned up monitor_common.c and monitor_common.h
This commit is contained in:
Markus Makela
2015-11-16 13:37:32 +02:00
parent 6dea82631d
commit f9c99761d6
2 changed files with 267 additions and 220 deletions

View File

@ -43,7 +43,6 @@ void monitor_clear_pending_status(MONITOR_SERVERS *ptr, int bit)
ptr->pending_status &= ~bit;
}
monitor_event_t mon_get_event_type(MONITOR_SERVERS* node)
{
unsigned int prev = node->mon_prev_status;
@ -268,7 +267,9 @@ bool mon_status_changed(
/** 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)
{
@ -358,7 +359,9 @@ int mon_parse_event_string(bool* events, size_t count,char* string)
tok = strtok_r(string, ",| ", &saved);
if (tok == NULL)
{
return -1;
}
while (tok)
{
@ -378,52 +381,95 @@ int mon_parse_event_string(bool* events, size_t count,char* string)
monitor_event_t mon_name_to_event(char* tok)
{
if (!strcasecmp("master_down", tok))
{
return MASTER_DOWN_EVENT;
}
else if (!strcasecmp("master_up", tok))
{
return MASTER_UP_EVENT;
}
else if (!strcasecmp("slave_down", tok))
{
return SLAVE_DOWN_EVENT;
}
else if (!strcasecmp("slave_up", tok))
{
return SLAVE_UP_EVENT;
}
else if (!strcasecmp("server_down", tok))
{
return SERVER_DOWN_EVENT;
}
else if (!strcasecmp("server_up", tok))
{
return SERVER_UP_EVENT;
}
else if (!strcasecmp("synced_down", tok))
{
return SYNCED_DOWN_EVENT;
}
else if (!strcasecmp("synced_up", tok))
{
return SYNCED_UP_EVENT;
}
else if (!strcasecmp("donor_down", tok))
{
return DONOR_DOWN_EVENT;
}
else if (!strcasecmp("donor_up", tok))
{
return DONOR_UP_EVENT;
}
else if (!strcasecmp("ndb_down", tok))
{
return NDB_DOWN_EVENT;
}
else if (!strcasecmp("ndb_up", tok))
{
return NDB_UP_EVENT;
}
else if (!strcasecmp("lost_master", tok))
{
return LOST_MASTER_EVENT;
}
else if (!strcasecmp("lost_slave", tok))
{
return LOST_SLAVE_EVENT;
}
else if (!strcasecmp("lost_synced", tok))
{
return LOST_SYNCED_EVENT;
}
else if (!strcasecmp("lost_donor", tok))
{
return LOST_DONOR_EVENT;
}
else if (!strcasecmp("lost_ndb", tok))
{
return LOST_NDB_EVENT;
}
else if (!strcasecmp("new_master", tok))
{
return NEW_MASTER_EVENT;
}
else if (!strcasecmp("new_slave", tok))
{
return NEW_SLAVE_EVENT;
}
else if (!strcasecmp("new_synced", tok))
{
return NEW_SYNCED_EVENT;
}
else if (!strcasecmp("new_donor", tok))
{
return NEW_DONOR_EVENT;
}
else if (!strcasecmp("new_ndb", tok))
{
return NEW_NDB_EVENT;
else
return UNDEFINED_MONITOR_EVENT;
}
return UNDEFINED_MONITOR_EVENT;
}
/**

View File

@ -38,7 +38,8 @@
/** Monitor events that are caused by servers moving from
* one state to another.*/
typedef enum {
typedef enum
{
UNDEFINED_MONITOR_EVENT,
MASTER_DOWN_EVENT,
MASTER_UP_EVENT,