Added full implementation of MXS-121 to all monitors.

This commit is contained in:
Markus Makela
2015-05-09 17:37:34 +03:00
parent 0c15812340
commit 9845923f81
6 changed files with 334 additions and 84 deletions

View File

@ -107,23 +107,31 @@ static void *
startMonitor(void *arg,void* opt)
{
MONITOR* mon = (MONITOR*)arg;
MYSQL_MONITOR *handle = mon->handle;
CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
if (handle != NULL)
MYSQL_MONITOR *handle = mon->handle;
CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
if (handle != NULL)
{
handle->shutdown = 0;
}
else
{
if ((handle = (MYSQL_MONITOR *)malloc(sizeof(MYSQL_MONITOR))) == NULL)
return NULL;
handle->shutdown = 0;
handle->id = MONITOR_DEFAULT_ID;
spinlock_init(&handle->lock);
}
while(params)
{
if(!strcmp(params->name,"script"))
{
handle->shutdown = 0;
if(handle->script)
free(handle->script);
handle->script = strdup(params->value);
}
else
{
if ((handle = (MYSQL_MONITOR *)malloc(sizeof(MYSQL_MONITOR))) == NULL)
return NULL;
handle->shutdown = 0;
handle->id = MONITOR_DEFAULT_ID;
spinlock_init(&handle->lock);
}
handle->tid = (THREAD)thread_start(monitorMain, mon);
return handle;
}
handle->tid = (THREAD)thread_start(monitorMain, mon);
return handle;
}
/**
@ -372,5 +380,24 @@ size_t nrounds = 0;
ptr = ptr->next;
}
ptr = mon->databases;
while(ptr)
{
/** Execute monitor script if a server state has changed */
if(mon_status_changed(ptr) && mon_get_event_type(ptr) != UNDEFINED_MONITOR_EVENT)
{
skygw_log_write(LOGFILE_TRACE,"Server changed state: %s[%s:%u]: %s",
ptr->server->unique_name,
ptr->server->name,ptr->server->port,
mon_get_event_name(ptr));
if(handle->script)
{
monitor_launch_script(mon,ptr,handle->script);
}
}
ptr = ptr->next;
}
}
}