MXS-2271 Move disk space settings to a settings-container

This commit is contained in:
Esa Korhonen
2019-01-23 11:01:52 +02:00
parent 00594cc369
commit f559bf3d95
9 changed files with 50 additions and 52 deletions

View File

@ -598,7 +598,7 @@ bool config_set_writeq_low_water(uint32_t size);
* @return True, if @ config_value was valid, false otherwise.
*
*/
bool config_parse_disk_space_threshold(MxsDiskSpaceThreshold* disk_space_threshold,
bool config_parse_disk_space_threshold(SERVER::DiskSpaceLimits* disk_space_threshold,
const char* config_value);

View File

@ -200,6 +200,14 @@ public:
*/
virtual json_t* diagnostics_json() const = 0;
/**
* Set disk space threshold setting.
*
* @param dst_setting The disk space threshold as specified in the config file.
* @return True, if the provided string is valid and the threshold could be set.
*/
bool set_disk_space_threshold(const std::string& dst_setting);
const char* const name; /**< Monitor instance name. TODO: change to string */
const std::string module_name; /**< Name of the monitor module */
bool active = true; /**< True if monitor exists and has not been "destroyed". */
@ -235,9 +243,22 @@ public:
const char* script; /**< Launchable script. */
uint64_t events; /**< Enabled monitor events. */
MxsDiskSpaceThreshold* disk_space_threshold = NULL; /**< Disk space thresholds */
int64_t disk_space_check_interval = -1; /**< How often should a disk space check be made
* at most. */
protected:
/**
* Contains monitor base class settings. Since monitors are stopped before a setting change,
* the items cannot be modified while a monitor is running. No locking required.
*/
class Settings
{
public:
SERVER::DiskSpaceLimits disk_space_limits; /**< Disk space thresholds */
/**
* How often should a disk space check be made at most, in milliseconds. Negative values imply
* disabling. */
int64_t disk_space_check_interval = -1;
};
Settings m_settings;
private:
friend class MonitorManager;
@ -414,16 +435,6 @@ int mon_config_get_servers(const MXS_CONFIG_PARAMETER* params,
const Monitor* mon,
MXS_MONITORED_SERVER*** monitored_array_out);
/**
* @brief Set the disk space threshold of a monitor
*
* @param server The monitor.
* @param disk_space_threshold The disk space threshold as specified in the config file.
*
* @return True, if the provided string is valid and the threshold could be set.
*/
bool monitor_set_disk_space_threshold(Monitor* monitor, const char* disk_space_threshold);
// Function for waiting one monitor interval
void monitor_debug_wait();

View File

@ -20,9 +20,6 @@
#include <maxbase/average.hh>
#include <maxscale/ssl.hh>
// A mapping from a path to a percentage, e.g.: "/disk" -> 80.
typedef std::unordered_map<std::string, int32_t> MxsDiskSpaceThreshold;
/**
* Server configuration parameters names
*/
@ -135,6 +132,9 @@ public:
static const int MAINTENANCE_FLAG_NOCHECK = 0;
static const int MAINTENANCE_FLAG_CHECK = -1;
// A mapping from a path to a percentage, e.g.: "/disk" -> 80.
typedef std::unordered_map<std::string, int32_t> DiskSpaceLimits;
enum class Type
{
MARIADB,
@ -219,7 +219,7 @@ public:
*
* @return A copy of settings
*/
virtual MxsDiskSpaceThreshold get_disk_space_limits() const = 0;
virtual DiskSpaceLimits get_disk_space_limits() const = 0;
/**
* Is persistent connection pool enabled.