MXS-1624 Add configuration parameter
With the global configuration parameter 'query_classifier_cache' the query classification cache can be turned on. At the moment it does not matter what value it has; its presence simply enables the caching. Eventually you will be able to specify how much memory the cache is allowed to consume.
This commit is contained in:
parent
e7913cc022
commit
f2b8487577
@ -257,6 +257,7 @@ typedef struct
|
||||
* promoted from a passive to an active */
|
||||
char qc_name[PATH_MAX]; /**< The name of the query classifier to load */
|
||||
char* qc_args; /**< Arguments for the query classifier */
|
||||
QC_CACHE_PROPERTIES* qc_cache_properties; /**< The query classifier cache properties. */
|
||||
qc_sql_mode_t qc_sql_mode; /**< The query classifier sql mode */
|
||||
char admin_host[MAX_ADMIN_HOST_LEN]; /**< Admin interface host */
|
||||
uint16_t admin_port; /**< Admin interface port */
|
||||
|
@ -120,6 +120,7 @@ const char CN_PORT[] = "port";
|
||||
const char CN_PROTOCOL[] = "protocol";
|
||||
const char CN_QUERY_CLASSIFIER[] = "query_classifier";
|
||||
const char CN_QUERY_CLASSIFIER_ARGS[] = "query_classifier_args";
|
||||
const char CN_QUERY_CLASSIFIER_CACHE[] = "query_classifier_cache";
|
||||
const char CN_QUERY_RETRIES[] = "query_retries";
|
||||
const char CN_QUERY_RETRY_TIMEOUT[] = "query_retry_timeout";
|
||||
const char CN_RELATIONSHIPS[] = "relationships";
|
||||
@ -1723,6 +1724,12 @@ handle_global_item(const char *name, const char *value)
|
||||
{
|
||||
gateway.qc_args = MXS_STRDUP_A(value);
|
||||
}
|
||||
else if (strcmp(name, CN_QUERY_CLASSIFIER_CACHE) == 0)
|
||||
{
|
||||
static QC_CACHE_PROPERTIES cache_properties;
|
||||
|
||||
gateway.qc_cache_properties = &cache_properties;
|
||||
}
|
||||
else if (strcmp(name, "sql_mode") == 0)
|
||||
{
|
||||
if (strcasecmp(value, "default") == 0)
|
||||
|
@ -1975,7 +1975,7 @@ int main(int argc, char **argv)
|
||||
goto return_main;
|
||||
}
|
||||
|
||||
if (!qc_setup(NULL, cnf->qc_sql_mode, cnf->qc_name, cnf->qc_args))
|
||||
if (!qc_setup(cnf->qc_cache_properties, cnf->qc_sql_mode, cnf->qc_name, cnf->qc_args))
|
||||
{
|
||||
const char* logerr = "Failed to initialise query classifier library.";
|
||||
print_log_n_stderr(true, true, logerr, logerr, eno);
|
||||
|
@ -278,7 +278,19 @@ bool qc_setup(const QC_CACHE_PROPERTIES* cache_properties,
|
||||
if (rv == QC_RESULT_OK)
|
||||
{
|
||||
this_unit.qc_sql_mode = sql_mode;
|
||||
this_unit.use_cached_result = (cache_properties ? true : false);
|
||||
|
||||
bool use_cached_result = (cache_properties != nullptr);
|
||||
|
||||
if (use_cached_result)
|
||||
{
|
||||
MXS_NOTICE("Query classification results are cached and reused.");
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_NOTICE("Query classification results are not cached.");
|
||||
}
|
||||
|
||||
this_unit.use_cached_result = use_cached_result;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user