From 787a0b50ef9839a4178153cdbc4814b86fc1146b Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 16 May 2018 09:06:16 +0300 Subject: [PATCH] MXS-1775 Cleanup monitor class headers - All classes now declared in separate header file - Header files have .hh-suffix --- server/modules/monitor/auroramon/auroramon.cc | 32 +----------- server/modules/monitor/auroramon/auroramon.hh | 49 +++++++++++++++++++ server/modules/monitor/galeramon/galeramon.cc | 12 ++++- .../galeramon/{galeramon.h => galeramon.hh} | 32 ++---------- server/modules/monitor/grmon/grmon.cc | 33 +------------ server/modules/monitor/grmon/grmon.hh | 49 +++++++++++++++++++ server/modules/monitor/mmmon/mmmon.cc | 14 +++++- .../monitor/mmmon/{mmmon.h => mmmon.hh} | 15 +----- .../monitor/ndbclustermon/ndbclustermon.cc | 2 +- .../{ndbclustermon.h => ndbclustermon.hh} | 8 +-- 10 files changed, 134 insertions(+), 112 deletions(-) create mode 100644 server/modules/monitor/auroramon/auroramon.hh rename server/modules/monitor/galeramon/{galeramon.h => galeramon.hh} (87%) create mode 100644 server/modules/monitor/grmon/grmon.hh rename server/modules/monitor/mmmon/{mmmon.h => mmmon.hh} (82%) rename server/modules/monitor/ndbclustermon/{ndbclustermon.h => ndbclustermon.hh} (94%) diff --git a/server/modules/monitor/auroramon/auroramon.cc b/server/modules/monitor/auroramon/auroramon.cc index 7f1547cc1..fe75f9c9a 100644 --- a/server/modules/monitor/auroramon/auroramon.cc +++ b/server/modules/monitor/auroramon/auroramon.cc @@ -17,42 +17,12 @@ #define MXS_MODULE_NAME "auroramon" -#include +#include "auroramon.hh" #include #include #include #include -#include #include -#include - -class AuroraMonitor : public MXS_MONITOR_INSTANCE -{ -public: - AuroraMonitor(const AuroraMonitor&) = delete; - AuroraMonitor& operator = (const AuroraMonitor&) = delete; - - static AuroraMonitor* create(MXS_MONITOR* monitor); - void destroy(); - bool start(const MXS_CONFIG_PARAMETER* param); - void stop(); - void diagnostics(DCB* dcb) const; - json_t* diagnostics_json() const; - -private: - bool m_shutdown; /**< True if the monitor is stopped */ - THREAD m_thread; /**< Monitor thread */ - char* m_script; /**< Launchable script */ - uint64_t m_events; /**< Enabled monitor events */ - MXS_MONITOR* m_monitor; /**< Pointer to generic monitor structure */ - bool m_checked; /**< Whether server access has been checked */ - - AuroraMonitor(MXS_MONITOR* monitor); - ~AuroraMonitor(); - - void main(); - static void main(void* data); -}; AuroraMonitor::AuroraMonitor(MXS_MONITOR* monitor) diff --git a/server/modules/monitor/auroramon/auroramon.hh b/server/modules/monitor/auroramon/auroramon.hh new file mode 100644 index 000000000..269dde0e2 --- /dev/null +++ b/server/modules/monitor/auroramon/auroramon.hh @@ -0,0 +1,49 @@ +#pragma once +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2020-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include +#include +#include + +/** + * @file auroramon.hh - The Aurora monitor + */ + +class AuroraMonitor : public MXS_MONITOR_INSTANCE +{ +public: + AuroraMonitor(const AuroraMonitor&) = delete; + AuroraMonitor& operator = (const AuroraMonitor&) = delete; + + static AuroraMonitor* create(MXS_MONITOR* monitor); + void destroy(); + bool start(const MXS_CONFIG_PARAMETER* param); + void stop(); + void diagnostics(DCB* dcb) const; + json_t* diagnostics_json() const; + +private: + bool m_shutdown; /**< True if the monitor is stopped */ + THREAD m_thread; /**< Monitor thread */ + char* m_script; /**< Launchable script */ + uint64_t m_events; /**< Enabled monitor events */ + MXS_MONITOR* m_monitor; /**< Pointer to generic monitor structure */ + bool m_checked; /**< Whether server access has been checked */ + + AuroraMonitor(MXS_MONITOR* monitor); + ~AuroraMonitor(); + + void main(); + static void main(void* data); +}; diff --git a/server/modules/monitor/galeramon/galeramon.cc b/server/modules/monitor/galeramon/galeramon.cc index 3be7cab2b..69e8551f0 100644 --- a/server/modules/monitor/galeramon/galeramon.cc +++ b/server/modules/monitor/galeramon/galeramon.cc @@ -17,10 +17,20 @@ #define MXS_MODULE_NAME "galeramon" -#include "galeramon.h" +#include "galeramon.hh" +#include +#include +#include +#include +#include #include +#include #include +#include +#include #include +#include +#include #define DONOR_NODE_NAME_MAX_LEN 60 #define DONOR_LIST_SET_VAR "SET GLOBAL wsrep_sst_donor = \"" diff --git a/server/modules/monitor/galeramon/galeramon.h b/server/modules/monitor/galeramon/galeramon.hh similarity index 87% rename from server/modules/monitor/galeramon/galeramon.h rename to server/modules/monitor/galeramon/galeramon.hh index 7e0da9ecf..de20dc1d9 100644 --- a/server/modules/monitor/galeramon/galeramon.h +++ b/server/modules/monitor/galeramon/galeramon.hh @@ -1,6 +1,4 @@ #pragma once -#ifndef _GALERAMON_H -#define _GALERAMON_H /* * Copyright (c) 2016 MariaDB Corporation Ab * @@ -15,31 +13,13 @@ */ /** - * @file galeramon.h - The Galera cluster monitor - * - * @verbatim - * Revision History - * - * Date Who Description - * 07/05/15 Markus Makela Initial Implementation of galeramon.h - * @endverbatim + * @file galeramon.hh - The Galera cluster monitor */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include /** * Galera Variables and server reference for each @@ -71,9 +51,7 @@ typedef struct galera_cluster_info char *c_uuid; /**< The Cluster UUID */ } GALERA_CLUSTER_INFO; -/** - * The handle for an instance of a Galera Monitor module - */ + class GaleraMonitor : public MXS_MONITOR_INSTANCE { public: @@ -124,5 +102,3 @@ private: void main(); static void main(void* data); }; - -#endif diff --git a/server/modules/monitor/grmon/grmon.cc b/server/modules/monitor/grmon/grmon.cc index 3bfa88064..5eb59b69c 100644 --- a/server/modules/monitor/grmon/grmon.cc +++ b/server/modules/monitor/grmon/grmon.cc @@ -17,45 +17,14 @@ #define MXS_MODULE_NAME "grmon" -#include +#include "grmon.hh" #include #include -#include -#include #include #include -/** - * The instance of a Group Replication Monitor - */ -struct GRMon : public MXS_MONITOR_INSTANCE -{ - GRMon(const GRMon&); - GRMon& operator&(const GRMon&); -public: - static GRMon* create(MXS_MONITOR* monitor); - void destroy(); - bool start(const MXS_CONFIG_PARAMETER* params); - void stop(); - void diagnostics(DCB* dcb) const; - json_t* diagnostics_json() const; - -private: - THREAD m_thread; /**< Monitor thread */ - int m_shutdown; /**< Flag to shutdown the monitor thread */ - MXS_MONITORED_SERVER* m_master; /**< The master server */ - std::string m_script; - uint64_t m_events; /**< Enabled events */ - MXS_MONITOR* m_monitor; - - GRMon(MXS_MONITOR* monitor); - ~GRMon(); - - void main(); - static void main(void* data); -}; GRMon::GRMon(MXS_MONITOR* monitor): m_shutdown(0), diff --git a/server/modules/monitor/grmon/grmon.hh b/server/modules/monitor/grmon/grmon.hh new file mode 100644 index 000000000..f339f8eba --- /dev/null +++ b/server/modules/monitor/grmon/grmon.hh @@ -0,0 +1,49 @@ +#pragma once +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2020-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include +#include +#include + +/** + * @file grmon.hh A MySQL Group Replication cluster monitor + */ + +class GRMon : public MXS_MONITOR_INSTANCE +{ +public: + GRMon(const GRMon&) = delete; + GRMon& operator&(const GRMon&) = delete; + + static GRMon* create(MXS_MONITOR* monitor); + void destroy(); + bool start(const MXS_CONFIG_PARAMETER* params); + void stop(); + void diagnostics(DCB* dcb) const; + json_t* diagnostics_json() const; + +private: + THREAD m_thread; /**< Monitor thread */ + int m_shutdown; /**< Flag to shutdown the monitor thread */ + MXS_MONITORED_SERVER* m_master; /**< The master server */ + std::string m_script; + uint64_t m_events; /**< Enabled events */ + MXS_MONITOR* m_monitor; + + GRMon(MXS_MONITOR* monitor); + ~GRMon(); + + void main(); + static void main(void* data); +}; diff --git a/server/modules/monitor/mmmon/mmmon.cc b/server/modules/monitor/mmmon/mmmon.cc index d8277bb35..dfb6b6fb7 100644 --- a/server/modules/monitor/mmmon/mmmon.cc +++ b/server/modules/monitor/mmmon/mmmon.cc @@ -17,10 +17,20 @@ #define MXS_MODULE_NAME "mmmon" -#include "mmmon.h" -#include +#include "mmmon.hh" +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #include +#include static void detectStaleMaster(void *, int); static bool isMySQLEvent(mxs_monitor_event_t event); diff --git a/server/modules/monitor/mmmon/mmmon.h b/server/modules/monitor/mmmon/mmmon.hh similarity index 82% rename from server/modules/monitor/mmmon/mmmon.h rename to server/modules/monitor/mmmon/mmmon.hh index 1d56d6cb5..e58ddd9c3 100644 --- a/server/modules/monitor/mmmon/mmmon.h +++ b/server/modules/monitor/mmmon/mmmon.hh @@ -13,26 +13,13 @@ */ #include -#include -#include -#include #include #include -#include -#include -#include -#include -#include -#include -#include /** - * @file mmmon.h - The Multi-Master monitor + * @file mmmon.hh - The Multi-Master monitor */ -/** - * The handle for an instance of a Multi-Master Monitor module - */ class MMMonitor : public MXS_MONITOR_INSTANCE { public: diff --git a/server/modules/monitor/ndbclustermon/ndbclustermon.cc b/server/modules/monitor/ndbclustermon/ndbclustermon.cc index 3bd39aa97..46363f570 100644 --- a/server/modules/monitor/ndbclustermon/ndbclustermon.cc +++ b/server/modules/monitor/ndbclustermon/ndbclustermon.cc @@ -17,7 +17,7 @@ #define MXS_MODULE_NAME "ndbclustermon" -#include "ndbclustermon.h" +#include "ndbclustermon.hh" #include #include diff --git a/server/modules/monitor/ndbclustermon/ndbclustermon.h b/server/modules/monitor/ndbclustermon/ndbclustermon.hh similarity index 94% rename from server/modules/monitor/ndbclustermon/ndbclustermon.h rename to server/modules/monitor/ndbclustermon/ndbclustermon.hh index 025e9de0c..a5b877d36 100644 --- a/server/modules/monitor/ndbclustermon/ndbclustermon.h +++ b/server/modules/monitor/ndbclustermon/ndbclustermon.hh @@ -1,5 +1,4 @@ #pragma once - /* * Copyright (c) 2016 MariaDB Corporation Ab * @@ -13,11 +12,14 @@ * Public License. */ +#include #include -#include #include -// The handle for an instance of a NDB Cluster Monitor module +/** + * @file ndbcclustermon.hh A NDBC cluster monitor + */ + class NDBCMonitor : public MXS_MONITOR_INSTANCE { public: