From b9d80f6061d6b536d7a15febf0367e5f6dba0e84 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Mon, 19 Feb 2018 15:10:20 +0200 Subject: [PATCH] Use dedicated header in NDBClusterMon NDBClusterMonitor used the MariaDBMonitor header instead of its own. --- .../modules/monitor/mariadbmon/mariadbmon.cc | 2 +- .../{mysqlmon.h => mariadbmon/mariadbmon.h} | 4 +- .../monitor/ndbclustermon/ndbclustermon.c | 10 ++--- .../monitor/ndbclustermon/ndbclustermon.h | 39 +++++++------------ 4 files changed, 22 insertions(+), 33 deletions(-) rename server/modules/monitor/{mysqlmon.h => mariadbmon/mariadbmon.h} (98%) diff --git a/server/modules/monitor/mariadbmon/mariadbmon.cc b/server/modules/monitor/mariadbmon/mariadbmon.cc index d73bf4603..a0597f153 100644 --- a/server/modules/monitor/mariadbmon/mariadbmon.cc +++ b/server/modules/monitor/mariadbmon/mariadbmon.cc @@ -17,7 +17,7 @@ #define MXS_MODULE_NAME "mariadbmon" -#include "../mysqlmon.h" +#include "mariadbmon.h" #include #include #include diff --git a/server/modules/monitor/mysqlmon.h b/server/modules/monitor/mariadbmon/mariadbmon.h similarity index 98% rename from server/modules/monitor/mysqlmon.h rename to server/modules/monitor/mariadbmon/mariadbmon.h index 11ae6b591..59f71e9a4 100644 --- a/server/modules/monitor/mysqlmon.h +++ b/server/modules/monitor/mariadbmon/mariadbmon.h @@ -1,6 +1,6 @@ #pragma once -#ifndef _MYSQLMON_H -#define _MYSQLMON_H +#ifndef _MARIADBMON_H +#define _MARIADBMON_H /* * Copyright (c) 2016 MariaDB Corporation Ab * diff --git a/server/modules/monitor/ndbclustermon/ndbclustermon.c b/server/modules/monitor/ndbclustermon/ndbclustermon.c index 2f305716a..b31e995e2 100644 --- a/server/modules/monitor/ndbclustermon/ndbclustermon.c +++ b/server/modules/monitor/ndbclustermon/ndbclustermon.c @@ -17,7 +17,7 @@ #define MXS_MODULE_NAME "ndbclustermon" -#include "../mysqlmon.h" +#include "ndbclustermon.h" #include #include @@ -103,7 +103,7 @@ MXS_MODULE* MXS_CREATE_MODULE() static void * startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params) { - MYSQL_MONITOR *handle = mon->handle; + NDBC_MONITOR *handle = mon->handle; bool have_events = false, script_error = false; if (handle != NULL) @@ -113,7 +113,7 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params) } else { - if ((handle = (MYSQL_MONITOR *) MXS_MALLOC(sizeof(MYSQL_MONITOR))) == NULL) + if ((handle = (NDBC_MONITOR *) MXS_MALLOC(sizeof(NDBC_MONITOR))) == NULL) { return NULL; } @@ -154,7 +154,7 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params) static void stopMonitor(MXS_MONITOR *mon) { - MYSQL_MONITOR *handle = (MYSQL_MONITOR *) mon->handle; + NDBC_MONITOR *handle = (NDBC_MONITOR *) mon->handle; handle->shutdown = 1; thread_wait(handle->thread); @@ -306,7 +306,7 @@ monitorDatabase(MXS_MONITORED_SERVER *database, char *defaultUser, char *default static void monitorMain(void *arg) { - MYSQL_MONITOR *handle = (MYSQL_MONITOR*)arg; + NDBC_MONITOR *handle = (NDBC_MONITOR*)arg; MXS_MONITOR* mon = handle->monitor; MXS_MONITORED_SERVER *ptr; size_t nrounds = 0; diff --git a/server/modules/monitor/ndbclustermon/ndbclustermon.h b/server/modules/monitor/ndbclustermon/ndbclustermon.h index d01064d98..1d21d1aec 100644 --- a/server/modules/monitor/ndbclustermon/ndbclustermon.h +++ b/server/modules/monitor/ndbclustermon/ndbclustermon.h @@ -1,5 +1,6 @@ -#ifndef _MYSQLMON_H -#define _MYSQLMON_H +#pragma once +#ifndef _NDBCMON_H +#define _NDBCMON_H /* * Copyright (c) 2016 MariaDB Corporation Ab * @@ -13,39 +14,27 @@ * Public License. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - /** * @file ndbclustermon.h - The NDB Cluster monitor * */ -/** - * The handle for an instance of a NDB Cluster Monitor module - */ +#include +#include +#include + +// The handle for an instance of a NDB Cluster Monitor module typedef struct { + THREAD thread; /**< Monitor thread */ SPINLOCK lock; /**< The monitor spinlock */ - pthread_t tid; /**< id of monitor thread */ + unsigned long id; /**< Monitor ID */ + uint64_t events; /*< enabled events */ int shutdown; /**< Flag to shutdown the monitor thread */ int status; /**< Monitor status */ - unsigned long id; /**< Monitor ID */ - MONITOR_SERVERS *master; /**< Master server for MySQL Master/Slave replication */ + MXS_MONITORED_SERVER *master; /**< Master server for MySQL Master/Slave replication */ char* script; /*< Script to call when state changes occur on servers */ - bool events[MAX_MONITOR_EVENT]; /*< enabled events */ -} MYSQL_MONITOR; + MXS_MONITOR* monitor; +} NDBC_MONITOR; #endif