MXS-2304 Use get_size() instead of config_get_size()

This commit is contained in:
Esa Korhonen 2019-01-31 16:09:59 +02:00
parent b357717149
commit 882d360355
7 changed files with 24 additions and 27 deletions

View File

@ -274,6 +274,20 @@ public:
*/
bool get_bool(const std::string& key) const;
/**
* @brief Get a size in bytes
*
* The value can have either one of the IEC binary prefixes or SI prefixes as
* a suffix. For example, the value 1Ki will be converted to 1024 bytes whereas
* 1k will be converted to 1000 bytes. Supported SI suffix values are k, m, g and t
* in both lower and upper case. Supported IEC binary suffix values are
* Ki, Mi, Gi and Ti both in upper and lower case.
*
* @param key Parameter name
* @return Number of bytes or 0 if no parameter was found
*/
uint64_t get_size(const std::string& key) const;
char* name; /**< The name of the parameter */
char* value; /**< The value of the parameter */
MXS_CONFIG_PARAMETER* next; /**< Next pointer in the linked list */
@ -388,22 +402,6 @@ bool config_param_is_valid(const MXS_MODULE_PARAM* params,
const char* value,
const CONFIG_CONTEXT* context);
/**
* @brief Get a size in bytes
*
* The value can have either one of the IEC binary prefixes or SI prefixes as
* a suffix. For example, the value 1Ki will be converted to 1024 bytes whereas
* 1k will be converted to 1000 bytes. Supported SI suffix values are k, m, g and t
* in both lower and upper case. Supported IEC binary suffix values are
* Ki, Mi, Gi and Ti both in upper and lower case.
*
* @param params List of configuration parameters
* @param key Parameter name
*
* @return Number of bytes or 0 if no parameter was found
*/
uint64_t config_get_size(const MXS_CONFIG_PARAMETER* params, const char* key);
/**
* @brief Get a string value
*

View File

@ -1760,11 +1760,11 @@ bool MXS_CONFIG_PARAMETER::get_bool(const std::string& key) const
return param_value.empty() ? false : config_truth_value(param_value.c_str());
}
uint64_t config_get_size(const MXS_CONFIG_PARAMETER* params, const char* key)
uint64_t MXS_CONFIG_PARAMETER::get_size(const std::string& key) const
{
const char* value = config_get_value_string(params, key);
uint64_t intval;
MXB_AT_DEBUG(bool rval = ) get_suffixed_size(value, &intval);
string param_value = get_string(key);
uint64_t intval = 0;
MXB_AT_DEBUG(bool rval = ) get_suffixed_size(param_value.c_str(), &intval);
mxb_assert(rval);
return intval;
}

View File

@ -348,11 +348,11 @@ bool CacheFilter::process_params(MXS_CONFIG_PARAMETER* ppParams, CACHE_CONFIG& c
config.debug = ppParams->get_integer("debug");
config.hard_ttl = ppParams->get_integer("hard_ttl");
config.soft_ttl = ppParams->get_integer("soft_ttl");
config.max_size = config_get_size(ppParams, "max_size");
config.max_size = ppParams->get_size("max_size");
config.max_count = ppParams->get_integer("max_count");
config.storage = MXS_STRDUP(config_get_string(ppParams, "storage"));
config.max_resultset_rows = ppParams->get_integer("max_resultset_rows");
config.max_resultset_size = config_get_size(ppParams, "max_resultset_size");
config.max_resultset_size = ppParams->get_size("max_resultset_size");
config.thread_model = static_cast<cache_thread_model_t>(ppParams->get_enum("cached_data",
parameter_cached_data_values));
config.selects = static_cast<cache_selects_t>(ppParams->get_enum("selects",

View File

@ -234,8 +234,7 @@ static MXS_FILTER* createInstance(const char* name, MXS_CONFIG_PARAMETER* params
{
cinstance->name = name;
cinstance->config.max_resultset_rows = params->get_integer("max_resultset_rows");
cinstance->config.max_resultset_size = config_get_size(params,
"max_resultset_size");
cinstance->config.max_resultset_size = params->get_size("max_resultset_size");
cinstance->config.m_return =
static_cast<maxrows_return_mode>(params->get_enum("max_resultset_return",
return_option_values));

View File

@ -60,7 +60,7 @@ static bool conversion_task_ctl(Avro* inst, bool start);
*/
MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params)
{
uint64_t block_size = config_get_size(service->svc_config_param, "block_size");
uint64_t block_size = service->svc_config_param->get_size("block_size");
mxs_avro_codec_type codec = static_cast<mxs_avro_codec_type>(
service->svc_config_param->get_enum("codec", codec_values));
std::string avrodir = config_get_string(service->svc_config_param, "avrodir");

View File

@ -343,7 +343,7 @@ static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params
inst->short_burst = params->get_integer("shortburst");
inst->long_burst = params->get_integer("longburst");
inst->burst_size = config_get_size(params, "burstsize");
inst->burst_size = params->get_size("burstsize");
inst->binlogdir = config_copy_string(params, "binlogdir");
inst->heartbeat = params->get_integer("heartbeat");
inst->retry_interval = params->get_integer("connect_retry");

View File

@ -157,7 +157,7 @@ struct Config
, delayed_retry(params->get_bool("delayed_retry"))
, delayed_retry_timeout(params->get_integer("delayed_retry_timeout"))
, transaction_replay(params->get_bool("transaction_replay"))
, trx_max_size(config_get_size(params, "transaction_replay_max_size"))
, trx_max_size(params->get_size("transaction_replay_max_size"))
, optimistic_trx(params->get_bool("optimistic_trx"))
{
if (causal_reads)