Commit Graph

231 Commits

Author SHA1 Message Date
40f24aaaee MXS-2271 Remove m_monitor self pointer 2019-03-12 10:29:55 +02:00
a8c878fbca MXS-2271 Remove unused setters
Runtime configuration changes now go through configure().
2019-03-12 10:29:55 +02:00
1858fe9127 MXS-2271 Monitor modifications always go through Monitor::configure()
Previously, runtime monitor modifications could directly alter monitor fields,
which could leave the text-form parameters and reality out-of-sync. Also,
the configure-function was not called for the entire monitor-object, only the
module-implementation.

Now, all modifications go through the overridden configure-function, which calls the
base-class function. As most configuration changes are given in text-form, this
removes the need for specific setters. The only exceptions are the server add/remove
operations, which must modify the text-form serverlist.
2019-03-12 10:19:45 +02:00
900cbb4cff MXS-2304 Move last config_get_x() functions inside class 2019-03-04 12:27:36 +02:00
2a63fb0776 MXS-2304 Store config parameter container as value in monitor and service 2019-02-22 16:53:17 +02:00
5828c93112 MXS-2304 Convert static config parameter methods to non-static
Parameter handling changed in several places.
2019-02-22 15:17:55 +02:00
7a99b5d253 MXS-2314 Define monitor state in terms of worker state
Worker::STOPPED    -> MONITOR_STATE_STOPPED
Worker::POLLING    -> MONITOR_STATE_RUNNING
Worker::PROCESSING -> MONITOR_STATE_RUNNING

By defining the monitor state from the worker state there is
no risk they will ever get out of sync. And there is one thing
less to maintain.
2019-02-11 13:03:18 +02:00
544e88a0b8 MXS-2314 Remove unnecessary monitor state 2019-02-11 13:03:18 +02:00
6425d4ed0c MXS-2314 Ensure that connections are closed
As m_servers is a member of Monitor, it is better if the closing
of the MYSQL connections is done there, so that derived classes
do not need to remember doing that.
2019-02-11 13:03:18 +02:00
dffb933efa MXS-2314 Do not accept NULL when starting/stopping monitor 2019-02-11 13:03:18 +02:00
3646c118c9 MXS-2314 Move journal checking inside Monitor 2019-02-11 13:03:18 +02:00
cac1d76e48 MXS-2314 Monitor decides whether servers are added to services
When the servers of a service are defined by a monitor, then
at startup all servers of the monitor should be added to relevant
services. Likewise, when a server is added to or removed from a
monitor at runtime, those changes should affect services as well.

However, whether that should happen or not depends upon the monitor.
In the case of the Clustrix monitor this should not happen as it
adds and removes servers depending on the runtime state of the
Clustrix cluster.
2019-02-11 13:03:18 +02:00
ab93216064 MXS-2314 Server added to monitor should be added to service
If the servers of a service are defined by a monitor (the config
has 'cluster=SomeMonitor'), then the addition of a server to a
a monitor should lead to that server being added to the service.
2019-02-11 13:03:18 +02:00
b4eb87dfcc MXS-2314 Populate services with servers
The services whose servers are defined using a monitor, will
now be populated from the monitor.

Note, no consideration has yet been given to runtime changes.
2019-02-11 13:03:18 +02:00
35ab911d5c MXS-2304 Use configuration class methods instead of separate implementations
Replaces parameter add/set/remove/free.
2019-02-07 13:51:16 +02:00
ed80680da9 MXS-2304 Add ctor/dtor and other functions to parameter class
The manipulation functions are currently static so that the container can be initialized
if required. This will be fixed later.

The new functions are taken into use in monitor management.
2019-02-07 13:51:16 +02:00
934be45b68 MXS-2304 Remove config_get_string() and config_get_value_string()
Some functions accessing internal pointers still remain.
2019-02-06 12:58:59 +02:00
4132c9bbbc MXS-2304 Use get_c_str_copy instead of config_copy_string()
Also uses get_string() in core-code when appropriate.
2019-02-05 10:28:37 +02:00
7cb969b0d9 MXS-2271 Clean up server list parsing functions, use in monitor config
The functions now return the parsed array.
2019-02-01 14:59:51 +02:00
f2d2202ea3 MXS-2304 Use get_enum() instead of config_get_enum() 2019-02-01 10:29:24 +02:00
c8a84cebd0 MXS-2304 Use get_integer() instead of config_get_integer() 2019-01-31 18:12:25 +02:00
03411e825d MXS-2271 Move journal_max_age inside settings container 2019-01-31 17:05:35 +02:00
ce9b49d8d5 MXS-2271 Move script-related settings to the settings-container
Also moves related functions to class methods.
2019-01-31 17:05:34 +02:00
0903648542 MXS-2271 Move connection settings inside settings struct
Since the settings are now protected fields, all related functions were
moved inside the monitor class. mon_ping_or_connect_to_db() is now a method
of MXS_MONITORED_SERVER. The connection settings class is defined inside the
server since that is the class actually using the settings.
2019-01-31 17:00:47 +02:00
8204b7d875 MXS-2273 Fix issues related to changes in Monitor 2019-01-30 12:38:36 +02:00
b650dd4f67 MXS-2273 Drop unnecessary SERVER prefix in names
MXS_MONITORED_SERVER provides enough scope.
2019-01-30 12:16:57 +02:00
bc4a52acb0 MXS-2273 Set SERVER_BEING_DRAINED properly
The maintenance and being-drained modes are now set using the same
mechanism.
2019-01-30 12:16:57 +02:00
e3d74bd18d MXS-2273 Generalise names
The maintenance flag and being-drain flags will be turned on using
the same variable, so the variable and constant names needs to be
generalized.
2019-01-30 12:16:57 +02:00
159d9ccba9 MXS-2273 Move constants to more appropriate locations
Constants now used in the context of MXS_MONITORED_SERVER or
Monitor are now moved from SERVER to MXS_MONITORED_SERVER or
Monitor, respectively.
2019-01-30 12:16:57 +02:00
57a94b417d MXS-2273 Move maint_request from SERVER to MXS_MONITORED_SERVER
The _request_ for setting the status of a server relates to the
monitor and its MXS_MONITORED_SERVER, not to the SERVER itself.
2019-01-30 12:16:57 +02:00
727d3feb3b MXS-2273 Move code for setting maintenance bit to monitor.cc
Applies to being-drained as well.

Better that this special handling is handled by Monitor that needs it.
2019-01-30 12:16:57 +02:00
6326172325 MXS-2271 Rename basic Monitor fields
Adds the m_-prefix.
2019-01-28 15:41:00 +02:00
cef4e836bc MXS-2271 Store monitored servers in a vector
The array is still a public member because it's used in several non-member functions.
2019-01-28 15:41:00 +02:00
546b80de4b MXS-2271 Move monitor interval to settings container 2019-01-25 13:46:01 +02:00
10dc0f53e0 MXS-2177 Move check_monitor_permissions() into class 2019-01-25 13:46:01 +02:00
0fe5b0bec9 MXS-2276 Expose lower level mon_ping_or_connect_to_db
The functionality is useful also when you do not have a
MXS_MONITORED_SERVER instance.
2019-01-25 10:28:34 +02:00
f559bf3d95 MXS-2271 Move disk space settings to a settings-container 2019-01-24 09:49:53 +02:00
00594cc369 MXS-2271 Move global monitor list inside a local class
Cleans up list locking and handling.
2019-01-24 09:49:53 +02:00
f6cec41dd8 MXS-2271 Monitor config name and instance name are parameters of createInstance()
Also adds/moves some comments from previous entrypoints. Name and module
are now constant fields.
2019-01-24 09:49:53 +02:00
9ac8bf93bb MXS-2271 Rename monitor-related classes
MXS_MONITOR->Monitor
MonitorInstance->MonitorWorker
MonitorInstanceSimple->MonitorWorkerSimple
2019-01-22 15:59:17 +02:00
dadb6a1a79 MXS-2271 All monitors inherit from MXS_MONITOR
Most of the API entrypoints are replaced with virtual functions.
2019-01-22 15:59:17 +02:00
3321a591ef MXS-2271 Move some monitor management functions to an internal class
The class MonitorManager contains monitor-related functions that should not
be called from modules. MonitorManager can access private fields and methods
of the monitor.
2019-01-22 10:31:06 +02:00
dd16a09342 MXS-2271 Move some initializers out of monitor_create() 2019-01-17 18:24:28 +02:00
40f58ddec8 MXS-2271 Use std::mutex instead of pthread_mutex 2019-01-17 17:51:39 +02:00
3125d1babf MXS-2271 Convert MXS_MONITOR and MXS_MONITORED_SERVER to classes
First step in monitor refactoring and cleanup.
2019-01-17 17:43:54 +02:00
f7d97825fb MXS-2219 Add monitor_stash_current_status
The functions stores the current server status to the monitored
server's mon_prev_status and pending_status fields.

To be used at the start of the monitor loop, before the pending
status fields are updated.
2019-01-17 11:11:21 +02:00
1c647f3753 MXS-2220 Move most remaining functions inside class
Most of the ones still remaining outside are special cases.
Also, removed locking from status manipulation functions as it
has not been required for quite some time.
2019-01-08 15:15:34 +02:00
d5c78eb31f MXS-2220 Move more server functions inside class 2019-01-08 15:12:47 +02:00
8b53e30678 MXS-2220 Move server status functions inside class 2019-01-08 15:12:47 +02:00
93aff0640c MXS-2220 Cleanup server header
Moved items around in preparation for more changes.
2019-01-07 16:10:15 +02:00