MXS-2000 Add query_classifier_cache_size to maxscale resource
This commit is contained in:
parent
cf4521503f
commit
2539183be2
@ -150,6 +150,7 @@ extern const char CN_PORT[];
|
||||
extern const char CN_PROTOCOL[];
|
||||
extern const char CN_QUERY_CLASSIFIER[];
|
||||
extern const char CN_QUERY_CLASSIFIER_ARGS[];
|
||||
extern const char CN_QUERY_CLASSIFIER_CACHE_SIZE[];
|
||||
extern const char CN_QUERY_RETRIES[];
|
||||
extern const char CN_QUERY_RETRY_TIMEOUT[];
|
||||
extern const char CN_RELATIONSHIPS[];
|
||||
@ -259,7 +260,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_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 */
|
||||
|
@ -2123,17 +2123,17 @@ handle_global_item(const char *name, const char *value)
|
||||
}
|
||||
else if (strcmp(name, CN_QUERY_CLASSIFIER_CACHE_SIZE) == 0)
|
||||
{
|
||||
static QC_CACHE_PROPERTIES cache_properties = { INT64_MAX };
|
||||
decltype(gateway.qc_cache_properties.max_size) max_size = get_suffixed_size(value);
|
||||
|
||||
cache_properties.max_size = get_suffixed_size(value);
|
||||
|
||||
if (cache_properties.max_size < 0)
|
||||
if (max_size >= 0)
|
||||
{
|
||||
// Someone got carried away; we'll just silently adjust the value.
|
||||
cache_properties.max_size = INT64_MAX;
|
||||
gateway.qc_cache_properties.max_size = max_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Invalid value for %s: %s", CN_QUERY_CLASSIFIER_CACHE_SIZE, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
gateway.qc_cache_properties = &cache_properties;
|
||||
}
|
||||
else if (strcmp(name, "sql_mode") == 0)
|
||||
{
|
||||
@ -4200,6 +4200,9 @@ json_t* config_maxscale_to_json(const char* host)
|
||||
json_object_set_new(param, CN_QUERY_CLASSIFIER_ARGS, json_string(cnf->qc_args));
|
||||
}
|
||||
|
||||
json_object_set_new(param, CN_QUERY_CLASSIFIER_CACHE_SIZE,
|
||||
json_integer(cnf->qc_cache_properties.max_size));
|
||||
|
||||
json_t* attr = json_object();
|
||||
time_t started = maxscale_started();
|
||||
time_t activated = started + MXS_CLOCK_TO_SEC(cnf->promoted_at);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "internal/config_runtime.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <set>
|
||||
@ -772,6 +773,25 @@ bool runtime_alter_maxscale(const char* name, const char* value)
|
||||
config_runtime_error("Invalid boolean value for '%s': %s", CN_PASSIVE, value);
|
||||
}
|
||||
}
|
||||
else if (key == CN_QUERY_CLASSIFIER_CACHE_SIZE)
|
||||
{
|
||||
char* end;
|
||||
long max_size = strtol(value, &end, 10);
|
||||
|
||||
if ((max_size >= 0) && (*end == 0))
|
||||
{
|
||||
MXS_NOTICE("Updated '%s' from %" PRIi64 " to %ld",
|
||||
CN_QUERY_CLASSIFIER_CACHE_SIZE, cnf.qc_cache_properties.max_size, max_size);
|
||||
|
||||
cnf.qc_cache_properties.max_size = max_size;
|
||||
qc_set_cache_properties(&cnf.qc_cache_properties);
|
||||
rval = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
config_runtime_error("Invalid size value for '%s': %s", CN_QUERY_CLASSIFIER_CACHE_SIZE, value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
config_runtime_error("Unknown global parameter: %s=%s", name, value);
|
||||
@ -2463,7 +2483,8 @@ bool validate_maxscale_json(json_t* json)
|
||||
runtime_is_count_or_null(param, CN_AUTH_READ_TIMEOUT) &&
|
||||
runtime_is_count_or_null(param, CN_AUTH_WRITE_TIMEOUT) &&
|
||||
runtime_is_bool_or_null(param, CN_ADMIN_AUTH) &&
|
||||
runtime_is_bool_or_null(param, CN_ADMIN_LOG_AUTH_FAILURES);
|
||||
runtime_is_bool_or_null(param, CN_ADMIN_LOG_AUTH_FAILURES) &&
|
||||
runtime_is_count_or_null(param, CN_QUERY_CLASSIFIER_CACHE_SIZE);
|
||||
}
|
||||
|
||||
return rval;
|
||||
|
@ -1984,7 +1984,7 @@ int main(int argc, char **argv)
|
||||
goto return_main;
|
||||
}
|
||||
|
||||
if (!qc_setup(cnf->qc_cache_properties, 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user