Allow the query classifier to be specified in maxscale.cnf

This commit is contained in:
Johan Wikman
2016-02-01 20:44:36 +02:00
parent e668abec5b
commit 2bbe1b068a
4 changed files with 26 additions and 2 deletions

View File

@ -47,6 +47,7 @@ bool qc_init(const char* plugin_name)
if (!plugin_name || (*plugin_name == 0)) if (!plugin_name || (*plugin_name == 0))
{ {
MXS_NOTICE("No query classifier specified, using default '%s'.", default_qc_name);
plugin_name = default_qc_name; plugin_name = default_qc_name;
} }

View File

@ -1002,6 +1002,22 @@ handle_global_item(const char *name, const char *value)
MXS_ERROR("Invalid timeout value for 'auth_write_timeout': %s", value); MXS_ERROR("Invalid timeout value for 'auth_write_timeout': %s", value);
} }
} }
else if (strcmp(name, "query_classifier") == 0)
{
int len = strlen(value);
int max_len = sizeof(gateway.qc_name) - 1;
if (len <= max_len)
{
strcpy(gateway.qc_name, value);
}
else
{
MXS_ERROR("The length of '%s' is %d, while the maximum length is %d.",
value, len, max_len);
return 0;
}
}
else else
{ {
for (i = 0; lognames[i].name; i++) for (i = 0; lognames[i].name; i++)
@ -1110,6 +1126,9 @@ global_defaults()
{ {
strncpy(gateway.sysname, uname_data.sysname, _SYSNAME_STR_LENGTH); strncpy(gateway.sysname, uname_data.sysname, _SYSNAME_STR_LENGTH);
} }
/* query_classifier */
memset(gateway.qc_name, 0, sizeof(gateway.qc_name));
} }
/** /**

View File

@ -1782,7 +1782,10 @@ int main(int argc, char **argv)
goto return_main; goto return_main;
} }
if (!qc_init(NULL)) GATEWAY_CONF* cnf = config_get_global_options();
ss_dassert(cnf);
if (!qc_init(cnf->qc_name))
{ {
char* logerr = "Failed to initialise query classifier library."; char* logerr = "Failed to initialise query classifier library.";
print_log_n_stderr(true, true, logerr, logerr, eno); print_log_n_stderr(true, true, logerr, logerr, eno);

View File

@ -124,7 +124,8 @@ typedef struct
int log_to_shm; /**< Write log-file to shared memory */ int log_to_shm; /**< Write log-file to shared memory */
unsigned int auth_conn_timeout; /**< Connection timeout for the user authentication */ unsigned int auth_conn_timeout; /**< Connection timeout for the user authentication */
unsigned int auth_read_timeout; /**< Read timeout for the user authentication */ unsigned int auth_read_timeout; /**< Read timeout for the user authentication */
unsigned int auth_write_timeout; /**< Write timeout for the user authentication */ unsigned int auth_write_timeout; /**< Write timeout for the user authentication */
char qc_name[PATH_MAX]; /**< The name of the query classifier to load */
} GATEWAY_CONF; } GATEWAY_CONF;