MXS-2329 Use durations in monitor (common parts)

This commit is contained in:
Johan Wikman 2019-04-29 14:23:47 +03:00
parent aa3057695b
commit c60c5e4626
3 changed files with 88 additions and 48 deletions

View File

@ -19,47 +19,67 @@ the `monitorpw` parameter, that value will be used instead.
### `monitor_interval`
Defines, in milliseconds, how often the monitor updates the status of the
servers. The default value is 2000 (2 seconds). Choose a lower value if servers
should be queried more often. The smallest possible value is 100. If querying
the servers takes longer than `monitor_interval`, the effective update rate is
reduced.
Defines how often the monitor updates the status of the
servers. The default value is 2 seconds. Choose a lower value if servers
should be queried more often. The smallest possible value is 100 milliseconds.
If querying the servers takes longer than `monitor_interval`, the effective
update rate is reduced.
The default value of `monitor_interval` was updated from 10000 milliseconds to
2000 milliseconds in MaxScale 2.2.0.
```
monitor_interval=2500
monitor_interval=2500ms
```
The interval 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.
### `backend_connect_timeout`
This parameter controls the timeout for connecting to a monitored server. It is
in seconds and the minimum value is 1 second. The default value for this
parameter is 3 seconds.
This parameter controls the timeout for connecting to a monitored server.
The interval is specified as documented
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
versions a value without a unit may be rejected. Note that since the granularity
of the timeout is seconds, a timeout specified in milliseconds will be rejected,
even if the duration is longer than a second. The minimum value is 1 second and
the default value for this is 3 seconds.
```
backend_connect_timeout=6
backend_connect_timeout=6s
```
### `backend_write_timeout`
This parameter controls the timeout for writing to a monitored server. It is in
seconds and the minimum value is 1 second. The default value for this parameter
is 3 seconds.
This parameter controls the timeout for writing to a monitored server.
The timeout is specified as documented
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
versions a value without a unit may be rejected. Note that since the granularity
of the timeout is seconds, a timeout specified in milliseconds will be rejected,
even if the duration is longer than a second. The minimum value is 1 second and
the default value for this is 3 seconds.
```
backend_write_timeout=4
backend_write_timeout=4s
```
### `backend_read_timeout`
This parameter controls the timeout for reading from a monitored server. It is
in seconds and the minimum value is 1 second. The default value for this
parameter is 3 seconds.
This parameter controls the timeout for reading from a monitored server.
The timeout is specified as documented
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
versions a value without a unit may be rejected. Note that since the granularity
of the timeout is seconds, a timeout specified in milliseconds will be rejected,
even if the duration is longer than a second. The minimum value is 1 second and
the default value for this is 3 seconds.
```
backend_read_timeout=2
backend_read_timeout=2s
```
### `backend_connect_attempts`
@ -161,10 +181,13 @@ at `/DbData` while both `server2` and `server3` have it mounted on
### `disk_space_check_interval`
With this positive integer parameter it can be specified in milliseconds
the minimum amount of time between disk space checks. The default value
is `20000`, which means that the disk space situation will be checked
once every 20 seconds.
With this parameter it can be specified the minimum amount of time
between disk space checks. The interval 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.
The default value is 0, which means that by default the disk space
will not be checked.
Note that as the checking is made as part of the regular monitor interval
cycle, the disk space check interval is affected by the value of
@ -172,7 +195,7 @@ cycle, the disk space check interval is affected by the value of
`disk_space_check_interval` is smaller than that of `monitor_interval`,
the checking will still take place at `monitor_interval` intervals.
```
disk_space_check_interval=10000
disk_space_check_interval=10000ms
```
### `script`
@ -220,8 +243,12 @@ case-insensitive.
### `script_timeout`
The timeout for the executed script in seconds. The default value is 90
seconds.
The timeout for the executed script. The interval is specified as documented
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
versions a value without a unit may be rejected. Note that since the granularity
of the timeout is seconds, a timeout specified in milliseconds will be rejected,
even if the duration is longer than a second. The default value is 90 seconds.
If the script execution exceeds the configured timeout, it is stopped by sending
a SIGTERM signal to it. If the process does not stop, a SIGKILL signal will be
@ -254,7 +281,12 @@ new_slave |A new Slave was detected
### `journal_max_age`
The maximum journal file age in seconds. The default value is 28800 seconds.
The maximum journal file age. The interval is specified as documented
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
versions a value without a unit may be rejected. Note that since the granularity
of the max age is seconds, a max age specified in milliseconds will be rejected,
even if the duration is longer than a second. The default value is 28800 seconds.
When the monitor starts, it reads any stored journal files. If the journal file
is older than the value of _journal_max_age_, it will be removed and the monitor

View File

@ -522,13 +522,14 @@ const MXS_MODULE_PARAM config_monitor_params[] =
},
{
CN_MONITOR_INTERVAL,
MXS_MODULE_PARAM_COUNT,
"2000"
MXS_MODULE_PARAM_DURATION,
"2000ms"
},
{
CN_BACKEND_CONNECT_TIMEOUT,
MXS_MODULE_PARAM_COUNT,
"3"
MXS_MODULE_PARAM_DURATION,
"3s",
MXS_MODULE_OPT_DURATION_S
},
{
CN_BACKEND_READ_TIMEOUT,
@ -537,8 +538,9 @@ const MXS_MODULE_PARAM config_monitor_params[] =
},
{
CN_BACKEND_WRITE_TIMEOUT,
MXS_MODULE_PARAM_COUNT,
"2"
MXS_MODULE_PARAM_DURATION,
"2s",
MXS_MODULE_OPT_DURATION_S
},
{
CN_BACKEND_CONNECT_ATTEMPTS,
@ -547,8 +549,9 @@ const MXS_MODULE_PARAM config_monitor_params[] =
},
{
CN_JOURNAL_MAX_AGE,
MXS_MODULE_PARAM_COUNT,
"28800"
MXS_MODULE_PARAM_DURATION,
"28800s",
MXS_MODULE_OPT_DURATION_S
},
{
CN_DISK_SPACE_THRESHOLD,
@ -556,8 +559,8 @@ const MXS_MODULE_PARAM config_monitor_params[] =
},
{
CN_DISK_SPACE_CHECK_INTERVAL,
MXS_MODULE_PARAM_COUNT,
"0"
MXS_MODULE_PARAM_DURATION,
"0ms"
},
{
CN_SCRIPT, // Cannot be a path type as the script may have parameters
@ -565,8 +568,9 @@ const MXS_MODULE_PARAM config_monitor_params[] =
},
{
CN_SCRIPT_TIMEOUT,
MXS_MODULE_PARAM_COUNT,
"90"
MXS_MODULE_PARAM_DURATION,
"90s",
MXS_MODULE_OPT_DURATION_S
},
{
CN_EVENTS,

View File

@ -433,23 +433,27 @@ const char* Monitor::name() const
return m_name.c_str();
}
using std::chrono::milliseconds;
using std::chrono::seconds;
bool Monitor::configure(const MXS_CONFIG_PARAMETER* params)
{
m_settings.interval = params->get_integer(CN_MONITOR_INTERVAL);
m_settings.journal_max_age = params->get_integer(CN_JOURNAL_MAX_AGE);
m_settings.script_timeout = params->get_integer(CN_SCRIPT_TIMEOUT);
m_settings.interval = params->get_duration<milliseconds>(CN_MONITOR_INTERVAL).count();
m_settings.journal_max_age = params->get_duration<seconds>(CN_JOURNAL_MAX_AGE).count();
m_settings.script_timeout = params->get_duration<seconds>(CN_SCRIPT_TIMEOUT).count();
m_settings.script = params->get_string(CN_SCRIPT);
m_settings.events = params->get_enum(CN_EVENTS, mxs_monitor_event_enum_values);
m_settings.conn_settings.read_timeout = params->get_integer(CN_BACKEND_READ_TIMEOUT);
m_settings.conn_settings.write_timeout = params->get_integer(CN_BACKEND_WRITE_TIMEOUT);
m_settings.conn_settings.connect_timeout = params->get_integer(CN_BACKEND_CONNECT_TIMEOUT);
m_settings.conn_settings.connect_attempts = params->get_integer(CN_BACKEND_CONNECT_ATTEMPTS);
m_settings.conn_settings.username = params->get_string(CN_USER);
m_settings.conn_settings.password = params->get_string(CN_PASSWORD);
MonitorServer::ConnectionSettings& conn_settings = m_settings.conn_settings;
conn_settings.read_timeout = params->get_duration<seconds>(CN_BACKEND_READ_TIMEOUT).count();
conn_settings.write_timeout = params->get_duration<seconds>(CN_BACKEND_WRITE_TIMEOUT).count();
conn_settings.connect_timeout = params->get_duration<seconds>(CN_BACKEND_CONNECT_TIMEOUT).count();
conn_settings.connect_attempts = params->get_integer(CN_BACKEND_CONNECT_ATTEMPTS);
conn_settings.username = params->get_string(CN_USER);
conn_settings.password = params->get_string(CN_PASSWORD);
// Disk check interval is given in ms, duration is constructed from seconds.
auto dsc_interval = params->get_integer(CN_DISK_SPACE_CHECK_INTERVAL);
auto dsc_interval = params->get_duration<milliseconds>(CN_DISK_SPACE_CHECK_INTERVAL).count();
// 0 implies disabling -> save negative value to interval.
m_settings.disk_space_check_interval = (dsc_interval > 0) ?
mxb::Duration(static_cast<double>(dsc_interval) / 1000) : mxb::Duration(-1);