40 Commits

Author SHA1 Message Date
Esa Korhonen
37841183b3 Cleanup server.h
Renamed, rearranged and clarified status bits. Removed unused macros.
2018-06-01 14:29:51 +03:00
Johan Wikman
ebcb807438 MXS-1775 Add default implementations 2018-06-01 13:48:15 +03:00
Johan Wikman
9b7e37e112 MXS-1775 Change MonitorInstance::configure() prototype
Now return boolean, to allow derived class to signal a failure
to configure.
2018-06-01 13:48:15 +03:00
Johan Wikman
0783af88ed MXS-1775 Make general cleanup
Document and rearrrange so that things look nice and tidy.
2018-06-01 13:48:15 +03:00
Johan Wikman
76cfe7291d MXS-1775 Move module entry point to the end of the file
Now the same way in all monitors.
2018-06-01 13:48:15 +03:00
Johan Wikman
b439857a84 MXS-1775 Remove destroy()
Now the instance is deleted simply by deleting it.
2018-06-01 13:48:15 +03:00
Johan Wikman
0833db8a48 MXS-1775 Flush pending status to servers using common code 2018-06-01 13:48:15 +03:00
Johan Wikman
15b1c270a3 MXS-1775 Check connection in MonitorInstance::tick()
Since the connection checking is done in an identical fashion in
all monitors, it can be moved to the base-class.
2018-06-01 13:48:15 +03:00
Johan Wikman
a8205824f8 MXS-1775 Update statuses the usual way in MMMon
As all other monitors MMMon now only manipulates the pending_status
of the monitor object during analysis and only in the end touches
the server status.
2018-06-01 13:48:15 +03:00
Johan Wikman
f50ebfce2a MXS-1775 Set/clear initial bits similarly in all monitors 2018-06-01 13:48:15 +03:00
Johan Wikman
8d1b8a1774 MXS-1775 Handle connection error the same way
All monitors (but for MariaDBMon) now handle connection errors in
the same manner.

An exception is MMMon that modifies both the server status and the
monitor status. However, in fact, all other monitors do it the wrong
way and update the server status directly instead of only the monitor
status that then at the end of the loop should be copied to the server
status.
2018-06-01 13:48:15 +03:00
Johan Wikman
5196371762 MXS-1775 Use same arrangement in update_server_status
All monitors (but possible for MariaDBMon) now handle the
connecting to the server in the same way, that is, if the
connecting fails, then the status is updated and we return.
2018-06-01 13:48:15 +03:00
Johan Wikman
df4e19eb27 MXS-1775 Provide default implementation for MonitorInstance::tick 2018-06-01 13:48:15 +03:00
Johan Wikman
68505a0bcb MXS-1775 Consistently name the argument to update_server_status() 2018-06-01 13:48:15 +03:00
Johan Wikman
cb1da5538c MXS-1775 Monitoring function named consistently
The main monitoring function now has the same name in all
monitors (except MariaDBMonitor) and is a member function.
2018-06-01 13:48:15 +03:00
Johan Wikman
650a739c92 MXS-1775 Move monitor loop to MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
db30ea96f2 MXS-1775 m_master is now a member variable of MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
6eef6f52db MXS-1775 Wait the same way in all monitors 2018-05-18 16:00:05 +03:00
Johan Wikman
2396b555f8 MXS-1775 Monitor loop and monitoring separated
In preparation for moving the monitor loop to MonitorInstance.
2018-05-18 16:00:05 +03:00
Johan Wikman
6fff5a4f23 MXS-1775 Preparatory work for moving main loop to MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
6db4ce54a9 MXS-1775 MonitorInstance now calls mysql_thread_[init|finish]() 2018-05-18 16:00:05 +03:00
Johan Wikman
15e3a2887c MXS-1775 Move status management to MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
1e084b78b1 MXS-1775 MonitorInstance::m_script is now a std::string 2018-05-18 16:00:05 +03:00
Johan Wikman
c7eb0a9958 MXS-1775 Thread starting is now handled by MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
adb7f156d6 MXS-1775 Introduce MonitorInstance::has_sufficient_permissions()
With this function in place, it is now possible to move the thread
starting to MonitorInstance.
2018-05-18 16:00:05 +03:00
Johan Wikman
3606a5ed1c MXS-1775 Introduce MonitorInstance::configure() function
The configuring of the monitor instance is now performed in a
separate function. That is in preparation for the moving of the
start function to maxscale::MonitorInstance.
2018-05-18 16:00:05 +03:00
Johan Wikman
bcb7d09a15 MXS-1775 Monitor stopping moved to maxscale::MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
1304fd6147 MXS-1775 Move thread main function to maxscale::MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
3c277f4e5e MXS-1775 Introduce maxscale::MonitorInstance
- All monitors (but MariaDBMon for the time being) inherit
  from that.
- All common member variables moved to that class. Still
  manipulated in derived classes.

In subsequent commits common functionality will be moved to
that class.
2018-05-18 16:00:05 +03:00
Johan Wikman
787a0b50ef MXS-1775 Cleanup monitor class headers
- All classes now declared in separate header file
- Header files have .hh-suffix
2018-05-18 16:00:05 +03:00
Johan Wikman
cd233fe594 MXS-1775 Turn MM monitor into a class
A mechanical change, without any functional modifications.
2018-05-18 16:00:05 +03:00
Esa Korhonen
b29bae6e84 MXS-1865 Update server version only when (re)connecting
Updating it every iteration is needless.
2018-05-16 13:55:45 +03:00
Johan Wikman
44fa2a4be2 MXS-1848 Change prototype of startMonitor
StartMonitor() now takes a MXS_MONITOR_INSTANCE and returns
true, if the monitor could be started and false otherwise.
So, the setup is such that in createInstance(), the instance
data is created and then using startMonitor() and stopMonitor()
the monitor is started/stopped. Finally in destroyInstance(),
the actual instance data is deleted.
2018-05-07 14:08:36 +03:00
Johan Wikman
5c1083c4aa MXS-1848 Parameters are not available at createInstance time
The monitor parameters are not available when the monitor instance
is created so at least for the time being they are removed from
the API.
2018-05-07 14:08:36 +03:00
Johan Wikman
81654fb0e7 MXS-1848 Rename monitor types and instance variable
The following type name changes

  MXS_MONITOR_OBJECT   -> MXS_MONITOR_API
  MXS_SPECIFIC_MONITOR -> MXS_MONITOR_INSTANCE

Further, the 'handle' instance variable of what used to be
called MXS_MONITOR_OBJECT has been renamed to 'api'.

An example, what used to look like

   mon->module->stopMonitor(mon->handle);

now looks like

  mon->api->stopMonitor(mon->instance);

which makes it more obvious what is going on.
2018-05-07 14:08:36 +03:00
Johan Wikman
60228f0f26 MXS-1848 Implement createInstance() and destroyInstance()
CreateInstance() (renamed from initMonitor()) and destroyInstance()
(renamed from finishMonitor()) have now tentatively been
implemented for all monitors.

Next step is to

1) change the prototype of startMonitor() to

       bool (*startMonitor)(MXS_SPECIFIC_MONITOR*,
                            const MXS_MONITOR_PARAMETER*);

   and assume that mon->handle will always contain the
   instance,
2) not delete any data in stopMonitor(),
3) add monitorCreateAll() that calls createInstance() for all
   monitors (and call that in main()), and
4) add monitorDestroyAll() that calls destroyInstance() for
   all monitors (and call that in main()).
2018-05-07 14:07:05 +03:00
Johan Wikman
02cd7b9275 MXS-1848 Add initMonitor() and finishMonitor() functions.
Not called and implementations are dummies.
2018-05-07 14:07:05 +03:00
Johan Wikman
ec8b9c773a MXS-1848 Use MXS_SPECIFIC_MONITOR type in monitor APIs
Now, all monitor functions but startMonitor takes a
MXS_SPECIFIC_MONITOR instead of MXS_MONITOR. That is, startMonitor
is now like a static factory member returning a new specific
monitor instance and the other functions are like member functions
of that instance.
2018-05-07 14:07:05 +03:00
Johan Wikman
d4008f7b28 MXS-1848 Introduce a specific monitor type
Instead of using void there's now a MXS_SPECIFIC_MONITOR struct
from which monitor specific types can be derived. This change
does not bring about other benefits than a bit of clarity but
this is the first step in clearing up the monitor API.
2018-05-07 14:07:05 +03:00
Johan Wikman
da16ba538d MXS-1834 Compile all monitors as C++ 2018-05-02 09:51:16 +03:00