MXS-2314 Populate services with servers
The services whose servers are defined using a monitor, will now be populated from the monitor. Note, no consideration has yet been given to runtime changes.
This commit is contained in:
@ -394,6 +394,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
int launch_command(MXS_MONITORED_SERVER* ptr, EXTERNCMD* cmd);
|
int launch_command(MXS_MONITORED_SERVER* ptr, EXTERNCMD* cmd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate services with the servers of the monitor.
|
||||||
|
*/
|
||||||
|
virtual void populate_services();
|
||||||
|
|
||||||
bool journal_is_stale();
|
bool journal_is_stale();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1692,7 +1692,11 @@ static bool process_config_context(CONFIG_CONTEXT* context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error_count)
|
if (error_count == 0)
|
||||||
|
{
|
||||||
|
MonitorManager::populate_services();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
MXS_ERROR("%d errors were encountered while processing the configuration "
|
MXS_ERROR("%d errors were encountered while processing the configuration "
|
||||||
"file '%s'.",
|
"file '%s'.",
|
||||||
|
@ -107,6 +107,11 @@ public:
|
|||||||
static void destroy_all_monitors();
|
static void destroy_all_monitors();
|
||||||
|
|
||||||
static void monitor_start(Monitor*, const MXS_CONFIG_PARAMETER*);
|
static void monitor_start(Monitor*, const MXS_CONFIG_PARAMETER*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Populate services with the servers of the monitors.
|
||||||
|
*/
|
||||||
|
static void populate_services();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include "internal/monitor.hh"
|
#include "internal/monitor.hh"
|
||||||
#include "internal/modules.hh"
|
#include "internal/modules.hh"
|
||||||
#include "internal/server.hh"
|
#include "internal/server.hh"
|
||||||
|
#include "internal/service.hh"
|
||||||
|
|
||||||
/** Schema version, journals must have a matching version */
|
/** Schema version, journals must have a matching version */
|
||||||
#define MMB_SCHEMA_VERSION 2
|
#define MMB_SCHEMA_VERSION 2
|
||||||
@ -278,6 +279,14 @@ void MonitorManager::monitor_start(Monitor* monitor, const MXS_CONFIG_PARAMETER*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MonitorManager::populate_services()
|
||||||
|
{
|
||||||
|
this_unit.foreach_monitor([](Monitor* pMonitor) -> bool {
|
||||||
|
pMonitor->populate_services();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start all monitors
|
* Start all monitors
|
||||||
*/
|
*/
|
||||||
@ -2364,8 +2373,16 @@ bool Monitor::clear_server_status(SERVER* srv, int bit, string* errmsg_out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return written;
|
return written;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Monitor::populate_services()
|
||||||
|
{
|
||||||
|
mxb_assert(m_state == MONITOR_STATE_STOPPED);
|
||||||
|
|
||||||
|
for (MXS_MONITORED_SERVER* pMs : m_servers)
|
||||||
|
{
|
||||||
|
service_add_server(this, pMs->server);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void monitor_debug_wait()
|
void monitor_debug_wait()
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <maxscale/json_api.h>
|
#include <maxscale/json_api.h>
|
||||||
#include "../../../core/internal/config_runtime.hh"
|
#include "../../../core/internal/config_runtime.hh"
|
||||||
|
#include "../../../core/internal/service.hh"
|
||||||
|
|
||||||
namespace http = mxb::http;
|
namespace http = mxb::http;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -65,6 +66,15 @@ bool ClustrixMonitor::configure(const MXS_CONFIG_PARAMETER* pParams)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClustrixMonitor::populate_services()
|
||||||
|
{
|
||||||
|
mxb_assert(Monitor::m_state == MONITOR_STATE_STOPPED);
|
||||||
|
|
||||||
|
// The servers that the Clustrix monitor has been configured with are
|
||||||
|
// only used for bootstrapping and services will not be populated
|
||||||
|
// with them.
|
||||||
|
}
|
||||||
|
|
||||||
bool ClustrixMonitor::softfail(SERVER* pServer, json_t** ppError)
|
bool ClustrixMonitor::softfail(SERVER* pServer, json_t** ppError)
|
||||||
{
|
{
|
||||||
bool rv = false;
|
bool rv = false;
|
||||||
@ -335,6 +345,10 @@ void ClustrixMonitor::refresh_nodes()
|
|||||||
health_check_threshold, pServer);
|
health_check_threshold, pServer);
|
||||||
|
|
||||||
m_nodes.insert(make_pair(id, node));
|
m_nodes.insert(make_pair(id, node));
|
||||||
|
|
||||||
|
// New server, so it needs to be added to all services that
|
||||||
|
// use this monitor for defining its cluster of servers.
|
||||||
|
service_add_server(this, pServer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -64,6 +64,8 @@ public:
|
|||||||
|
|
||||||
bool configure(const MXS_CONFIG_PARAMETER* pParams) override;
|
bool configure(const MXS_CONFIG_PARAMETER* pParams) override;
|
||||||
|
|
||||||
|
void populate_services() override;
|
||||||
|
|
||||||
bool softfail(SERVER* pServer, json_t** ppError);
|
bool softfail(SERVER* pServer, json_t** ppError);
|
||||||
bool unsoftfail(SERVER* pServer, json_t** ppError);
|
bool unsoftfail(SERVER* pServer, json_t** ppError);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user