MXS-2329 Use durations in throttle filter
This commit is contained in:
parent
f3acf77a9f
commit
bd3d5bb010
@ -71,11 +71,16 @@ sampling duration (see `sampling_duration`).
|
||||
|
||||
#### `throttling_duration`
|
||||
|
||||
Required parameter. Time in milliseconds.
|
||||
Required parameter.
|
||||
|
||||
This defines how long a session is allowed to be throttled before MaxScale
|
||||
disconnects the session.
|
||||
|
||||
The value is specified as documented
|
||||
[here](Getting-Started/Configuration-Guide.md#durations).
|
||||
If no explicit unit is provided, the value is interpreted as milliseconds
|
||||
in MaxScale 2.4. In subsequent versions a value without a unit may be rejected.
|
||||
|
||||
### `sampling_duration`
|
||||
|
||||
Optional parameter. Default 250 milliseconds.
|
||||
@ -90,6 +95,11 @@ longer this time is, the longer bursts of high frequency querying is allowed.
|
||||
Due to the underlying granularity of time measurment (as of June 2018), it is
|
||||
not recommended that this value is set to less than 100 milliseconds.
|
||||
|
||||
The value is specified as documented
|
||||
[here](Getting-Started/Configuration-Guide.md#durations).
|
||||
If no explicit unit is provided, the value is interpreted as milliseconds
|
||||
in MaxScale 2.4. In subsequent versions a value without a unit may be rejected.
|
||||
|
||||
### `continuous_duration`
|
||||
|
||||
Optional parameter. Default 2000 milliseconds or 2 seconds.
|
||||
@ -97,3 +107,8 @@ Optional parameter. Default 2000 milliseconds or 2 seconds.
|
||||
This value defines what continuous throttling means. Continuous throttling
|
||||
starts as soon as the filter throttles the frequency. Continuous throttling ends
|
||||
when no throttling has been performed in the past `continuous_duration` time.
|
||||
|
||||
The value is specified as documented
|
||||
[here](Getting-Started/Configuration-Guide.md#durations).
|
||||
If no explicit unit is provided, the value is interpreted as milliseconds
|
||||
in MaxScale 2.4. In subsequent versions a value without a unit may be rejected.
|
||||
|
@ -44,9 +44,9 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
NULL, /* Thread finish. */
|
||||
{
|
||||
{MAX_QPS_CFG, MXS_MODULE_PARAM_INT },
|
||||
{SAMPLING_DURATION_CFG, MXS_MODULE_PARAM_INT, "250"},
|
||||
{THROTTLE_DURATION_CFG, MXS_MODULE_PARAM_INT },
|
||||
{CONTINUOUS_DURATION_CFG, MXS_MODULE_PARAM_INT, "2000"},
|
||||
{SAMPLING_DURATION_CFG, MXS_MODULE_PARAM_DURATION, "250ms"},
|
||||
{THROTTLE_DURATION_CFG, MXS_MODULE_PARAM_DURATION },
|
||||
{CONTINUOUS_DURATION_CFG, MXS_MODULE_PARAM_DURATION, "2000ms"},
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
}
|
||||
};
|
||||
@ -64,9 +64,12 @@ ThrottleFilter::ThrottleFilter(const ThrottleConfig& config) : m_config(config)
|
||||
ThrottleFilter* ThrottleFilter::create(const char* zName, MXS_CONFIG_PARAMETER* pParams)
|
||||
{
|
||||
int max_qps = pParams->get_integer(MAX_QPS_CFG);
|
||||
int sample_msecs = pParams->get_integer(SAMPLING_DURATION_CFG);
|
||||
int throttle_msecs = pParams->get_integer(THROTTLE_DURATION_CFG);
|
||||
int cont_msecs = pParams->get_integer(CONTINUOUS_DURATION_CFG);
|
||||
int sample_msecs =
|
||||
pParams->get_duration(SAMPLING_DURATION_CFG, mxs::config::INTERPRET_AS_MILLISECONDS).count();
|
||||
int throttle_msecs =
|
||||
pParams->get_duration(THROTTLE_DURATION_CFG, mxs::config::INTERPRET_AS_MILLISECONDS).count();
|
||||
int cont_msecs =
|
||||
pParams->get_duration(CONTINUOUS_DURATION_CFG, mxs::config::INTERPRET_AS_MILLISECONDS).count();
|
||||
bool config_ok = true;
|
||||
|
||||
if (max_qps < 2)
|
||||
@ -75,6 +78,7 @@ ThrottleFilter* ThrottleFilter::create(const char* zName, MXS_CONFIG_PARAMETER*
|
||||
config_ok = false;
|
||||
}
|
||||
|
||||
// TODO: These checks are unnecessary as a MXS_MODULE_PARAM_DURATION is required to be positive.
|
||||
if (sample_msecs < 0)
|
||||
{
|
||||
MXS_ERROR("Config value %s must be >= 0", SAMPLING_DURATION_CFG);
|
||||
|
Loading…
x
Reference in New Issue
Block a user