Allow monitors and services to start without servers
MaxScale can now start without any defined monitors. This allows the core services to be configured beforehand. With the changes to dynamic modifications to servers, automatic scaling of slaves is possible.
This commit is contained in:
@ -2824,12 +2824,6 @@ int configure_new_service(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj)
|
||||
s = strtok_r(NULL, ",", &lasts);
|
||||
}
|
||||
}
|
||||
else if (servers == NULL && !is_internal_service(router))
|
||||
{
|
||||
MXS_ERROR("The service '%s' is missing a definition of the servers "
|
||||
"that provide the service.", obj->object);
|
||||
error_count++;
|
||||
}
|
||||
|
||||
if (roptions)
|
||||
{
|
||||
@ -2882,12 +2876,6 @@ int create_new_monitor(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj, HASHTABLE*
|
||||
}
|
||||
|
||||
char *servers = config_get_value(obj->parameters, "servers");
|
||||
if (servers == NULL)
|
||||
{
|
||||
MXS_ERROR("Monitor '%s' is missing the 'servers' parameter that "
|
||||
"lists the servers that it monitors.", obj->object);
|
||||
error_count++;
|
||||
}
|
||||
|
||||
if (error_count == 0)
|
||||
{
|
||||
@ -2934,6 +2922,8 @@ int create_new_monitor(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj, HASHTABLE*
|
||||
}
|
||||
}
|
||||
|
||||
if (servers)
|
||||
{
|
||||
/* get the servers to monitor */
|
||||
char *s, *lasts;
|
||||
s = strtok_r(servers, ",", &lasts);
|
||||
@ -2965,6 +2955,7 @@ int create_new_monitor(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj, HASHTABLE*
|
||||
|
||||
s = strtok_r(NULL, ",", &lasts);
|
||||
}
|
||||
}
|
||||
|
||||
char *user = config_get_value(obj->parameters, "user");
|
||||
char *passwd = config_get_password(obj->parameters);
|
||||
|
@ -58,7 +58,7 @@ const monitor_def_t monitor_event_definitions[MAX_MONITOR_EVENT] =
|
||||
static MONITOR *allMonitors = NULL;
|
||||
static SPINLOCK monLock = SPINLOCK_INIT;
|
||||
|
||||
static void monitor_servers_free(MONITOR_SERVERS *servers);
|
||||
static void monitor_server_free_all(MONITOR_SERVERS *servers);
|
||||
|
||||
/**
|
||||
* Allocate a new monitor, load the associated module for the monitor
|
||||
@ -142,7 +142,7 @@ monitor_free(MONITOR *mon)
|
||||
}
|
||||
spinlock_release(&monLock);
|
||||
free_config_parameter(mon->parameters);
|
||||
monitor_servers_free(mon->databases);
|
||||
monitor_server_free_all(mon->databases);
|
||||
MXS_FREE(mon->name);
|
||||
MXS_FREE(mon);
|
||||
}
|
||||
@ -304,7 +304,7 @@ static void monitor_server_free(MONITOR_SERVERS *tofree)
|
||||
* Free monitor server list
|
||||
* @param servers Servers to free
|
||||
*/
|
||||
static void monitor_servers_free(MONITOR_SERVERS *servers)
|
||||
static void monitor_server_free_all(MONITOR_SERVERS *servers)
|
||||
{
|
||||
while (servers)
|
||||
{
|
||||
@ -357,7 +357,7 @@ void monitorRemoveServer(MONITOR *mon, SERVER *server)
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
monitor_servers_free(ptr);
|
||||
monitor_server_free(ptr);
|
||||
}
|
||||
|
||||
if (old_state == MONITOR_STATE_RUNNING)
|
||||
@ -608,13 +608,8 @@ monitorGetList()
|
||||
*/
|
||||
bool check_monitor_permissions(MONITOR* monitor, const char* query)
|
||||
{
|
||||
if (monitor->databases == NULL)
|
||||
{
|
||||
MXS_ERROR("[%s] Monitor is missing the servers parameter.", monitor->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config_get_global_options()->skip_permission_checks)
|
||||
if (monitor->databases == NULL || // No servers to check
|
||||
config_get_global_options()->skip_permission_checks)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -821,13 +821,12 @@ void serviceRemoveBackend(SERVICE *service, const SERVER *server)
|
||||
{
|
||||
spinlock_acquire(&service->spin);
|
||||
|
||||
service->n_dbref--;
|
||||
|
||||
for (SERVER_REF *ref = service->dbref; ref; ref = ref->next)
|
||||
{
|
||||
if (ref->server == server)
|
||||
{
|
||||
ref->active = false;
|
||||
service->n_dbref--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2649,17 +2649,12 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
|
||||
bool check_service_permissions(SERVICE* service)
|
||||
{
|
||||
if (is_internal_service(service->routerModule) ||
|
||||
config_get_global_options()->skip_permission_checks)
|
||||
config_get_global_options()->skip_permission_checks ||
|
||||
service->dbref == NULL) // No servers to check
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (service->dbref == NULL)
|
||||
{
|
||||
MXS_ERROR("[%s] Service is missing the servers parameter.", service->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
char *user, *password;
|
||||
|
||||
if (serviceGetUser(service, &user, &password) == 0)
|
||||
|
@ -215,7 +215,7 @@ bool init_server_info(MYSQL_MONITOR *handle, MONITOR_SERVERS *database)
|
||||
while (database)
|
||||
{
|
||||
/** Delete any existing structures and replace them with empty ones */
|
||||
hashtable_delete(handle->server_info, database->server);
|
||||
hashtable_delete(handle->server_info, database->server->unique_name);
|
||||
|
||||
if (!hashtable_add(handle->server_info, database->server->unique_name, &info))
|
||||
{
|
||||
|
Reference in New Issue
Block a user