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.
This commit is contained in:
Johan Wikman
2018-05-04 10:02:06 +03:00
parent 1f6cc6db8a
commit d4008f7b28
11 changed files with 34 additions and 30 deletions

View File

@ -30,7 +30,8 @@ static void monitorMain(void *);
/** Log a warning when a bad 'wsrep_local_index' is found */
static bool warn_erange_on_local_index = true;
static void *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *params);
static MXS_SPECIFIC_MONITOR *startMonitor(MXS_MONITOR *,
const MXS_CONFIG_PARAMETER *params);
static void stopMonitor(MXS_MONITOR *);
static void diagnostics(DCB *, const MXS_MONITOR *);
static json_t* diagnostics_json(const MXS_MONITOR *);
@ -119,7 +120,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
*
* @return A handle to use when interacting with the monitor
*/
static void *
static MXS_SPECIFIC_MONITOR *
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
{
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon->handle);

View File

@ -41,8 +41,6 @@
#include <maxscale/config.h>
#include <maxscale/hashtable.h>
MXS_BEGIN_DECLS
/**
* Galera Variables and server reference for each
* monitored node that could be part of cluster.
@ -76,7 +74,7 @@ typedef struct galera_cluster_info
/**
* The handle for an instance of a Galera Monitor module
*/
typedef struct
struct GALERA_MONITOR : public MXS_SPECIFIC_MONITOR
{
THREAD thread; /**< Monitor thread */
int shutdown; /**< Flag to shutdown the monitor thread */
@ -96,8 +94,6 @@ typedef struct
HASHTABLE *galera_nodes_info; /**< Contains Galera Cluster variables of all nodes */
GALERA_CLUSTER_INFO cluster_info; /**< Contains Galera cluster info */
MXS_MONITOR* monitor;
} GALERA_MONITOR;
MXS_END_DECLS
};
#endif