MXS-1262: Move journal_max_age to MaxScale core
The parameter is now defined in the monitor. Further refactoring is needed to make the interface of the journal system simpler.
This commit is contained in:
@ -237,6 +237,7 @@ const char *config_monitor_params[] =
|
||||
CN_SCRIPT,
|
||||
CN_EVENTS,
|
||||
CN_MONITOR_INTERVAL,
|
||||
CN_JOURNAL_MAX_AGE,
|
||||
CN_BACKEND_CONNECT_TIMEOUT,
|
||||
CN_BACKEND_READ_TIMEOUT,
|
||||
CN_BACKEND_WRITE_TIMEOUT,
|
||||
@ -3152,14 +3153,39 @@ int create_new_monitor(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj, HASHTABLE*
|
||||
{
|
||||
MXS_NOTICE("Invalid '%s' parameter for monitor '%s', "
|
||||
"using default value of %d milliseconds.",
|
||||
CN_MONITOR_INTERVAL, obj->object, MONITOR_DEFAULT_INTERVAL);
|
||||
CN_MONITOR_INTERVAL, obj->object, DEFAULT_MONITOR_INTERVAL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_NOTICE("Monitor '%s' is missing the '%s' parameter, "
|
||||
"using default value of %d milliseconds.",
|
||||
CN_MONITOR_INTERVAL, obj->object, MONITOR_DEFAULT_INTERVAL);
|
||||
CN_MONITOR_INTERVAL, obj->object, DEFAULT_MONITOR_INTERVAL);
|
||||
}
|
||||
|
||||
char *journal_age = config_get_value(obj->parameters, CN_JOURNAL_MAX_AGE);
|
||||
if (journal_age)
|
||||
{
|
||||
char *endptr;
|
||||
long interval = strtol(journal_age, &endptr, 0);
|
||||
/* The interval must be >0 because it is used as a divisor.
|
||||
Perhaps a greater minimum value should be added? */
|
||||
if (*endptr == '\0' && interval > 0)
|
||||
{
|
||||
monitorSetJournalMaxAge(monitor, (time_t)interval);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_count++;
|
||||
MXS_NOTICE("Invalid '%s' parameter for monitor '%s'",
|
||||
CN_JOURNAL_MAX_AGE, obj->object);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_NOTICE("Monitor '%s' is missing the '%s' parameter, "
|
||||
"using default value of %d milliseconds.",
|
||||
CN_JOURNAL_MAX_AGE, obj->object, DEFAULT_JOURNAL_MAX_AGE);
|
||||
}
|
||||
|
||||
char *connect_timeout = config_get_value(obj->parameters, CN_BACKEND_CONNECT_TIMEOUT);
|
||||
|
||||
@ -27,7 +27,10 @@ MXS_BEGIN_DECLS
|
||||
#define DEFAULT_WRITE_TIMEOUT 2
|
||||
#define DEFAULT_CONNECTION_ATTEMPTS 1
|
||||
|
||||
#define MONITOR_DEFAULT_INTERVAL 2000 // in milliseconds
|
||||
#define DEFAULT_MONITOR_INTERVAL 2000 // in milliseconds
|
||||
|
||||
/** Default maximum journal age in seconds */
|
||||
#define DEFAULT_JOURNAL_MAX_AGE 28800
|
||||
|
||||
/**
|
||||
* Monitor network timeout types
|
||||
@ -66,6 +69,7 @@ bool monitorRemoveParameter(MXS_MONITOR *monitor, const char *key);
|
||||
|
||||
void monitorSetInterval (MXS_MONITOR *, unsigned long);
|
||||
bool monitorSetNetworkTimeout(MXS_MONITOR *, int, int);
|
||||
void monitorSetJournalMaxAge(MXS_MONITOR *mon, time_t value);
|
||||
|
||||
/**
|
||||
* @brief Serialize a monitor to a file
|
||||
|
||||
@ -67,6 +67,7 @@ const char CN_BACKEND_READ_TIMEOUT[] = "backend_read_timeout";
|
||||
const char CN_BACKEND_WRITE_TIMEOUT[] = "backend_write_timeout";
|
||||
const char CN_BACKEND_CONNECT_TIMEOUT[] = "backend_connect_timeout";
|
||||
const char CN_MONITOR_INTERVAL[] = "monitor_interval";
|
||||
const char CN_JOURNAL_MAX_AGE[] = "journal_max_age";
|
||||
const char CN_SCRIPT[] = "script";
|
||||
const char CN_EVENTS[] = "events";
|
||||
|
||||
@ -125,7 +126,8 @@ MXS_MONITOR* monitor_alloc(const char *name, const char *module)
|
||||
mon->write_timeout = DEFAULT_WRITE_TIMEOUT;
|
||||
mon->connect_timeout = DEFAULT_CONNECT_TIMEOUT;
|
||||
mon->connect_attempts = DEFAULT_CONNECTION_ATTEMPTS;
|
||||
mon->interval = MONITOR_DEFAULT_INTERVAL;
|
||||
mon->interval = DEFAULT_MONITOR_INTERVAL;
|
||||
mon->journal_max_age = DEFAULT_JOURNAL_MAX_AGE;
|
||||
mon->parameters = NULL;
|
||||
mon->server_pending_changes = false;
|
||||
spinlock_init(&mon->lock);
|
||||
@ -627,6 +629,17 @@ monitorSetInterval(MXS_MONITOR *mon, unsigned long interval)
|
||||
mon->interval = interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum age of the monitor journal
|
||||
*
|
||||
* @param mon The monitor instance
|
||||
* @param interval The journal age in seconds
|
||||
*/
|
||||
void monitorSetJournalMaxAge(MXS_MONITOR *mon, time_t value)
|
||||
{
|
||||
mon->journal_max_age = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Monitor timeouts for connect/read/write
|
||||
*
|
||||
@ -1585,6 +1598,7 @@ json_t* monitor_parameters_to_json(const MXS_MONITOR* monitor)
|
||||
json_object_set_new(rval, CN_BACKEND_READ_TIMEOUT, json_integer(monitor->read_timeout));
|
||||
json_object_set_new(rval, CN_BACKEND_WRITE_TIMEOUT, json_integer(monitor->write_timeout));
|
||||
json_object_set_new(rval, CN_BACKEND_CONNECT_ATTEMPTS, json_integer(monitor->connect_attempts));
|
||||
json_object_set_new(rval, CN_JOURNAL_MAX_AGE, json_integer(monitor->journal_max_age));
|
||||
|
||||
/** Add custom module parameters */
|
||||
const MXS_MODULE* mod = get_module(monitor->module_name, MODULE_MONITOR);
|
||||
|
||||
Reference in New Issue
Block a user