MXS-2219 Dynamically create Clustrix servers
MaxScale server objects are now created for all Clustrix nodes. Currently the name is "Clustrix-Server-N" where N is the number of the node. The server is created using runtime_create_server() that has been modified so that it optionally will not persist the created server. That is probably just a temporary solution as a monitor should not need to include .../core/internal-stuff.
This commit is contained in:
@ -209,7 +209,8 @@ bool runtime_create_server(const char* name,
|
|||||||
const char* address,
|
const char* address,
|
||||||
const char* port,
|
const char* port,
|
||||||
const char* protocol,
|
const char* protocol,
|
||||||
const char* authenticator)
|
const char* authenticator,
|
||||||
|
bool serialize)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(crt_lock);
|
std::lock_guard<std::mutex> guard(crt_lock);
|
||||||
bool rval = false;
|
bool rval = false;
|
||||||
@ -244,7 +245,7 @@ bool runtime_create_server(const char* name,
|
|||||||
|
|
||||||
Server* server = Server::server_alloc(name, ctx.parameters);
|
Server* server = Server::server_alloc(name, ctx.parameters);
|
||||||
|
|
||||||
if (server && server->serialize())
|
if (server && (!serialize || server->serialize()))
|
||||||
{
|
{
|
||||||
rval = true;
|
rval = true;
|
||||||
MXS_NOTICE("Created server '%s' at %s:%u",
|
MXS_NOTICE("Created server '%s' at %s:%u",
|
||||||
|
@ -57,7 +57,8 @@ bool runtime_create_server(const char* name,
|
|||||||
const char* address,
|
const char* address,
|
||||||
const char* port,
|
const char* port,
|
||||||
const char* protocol,
|
const char* protocol,
|
||||||
const char* authenticator);
|
const char* authenticator,
|
||||||
|
bool serialize = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroy a server
|
* @brief Destroy a server
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "clustrixmonitor.hh"
|
#include "clustrixmonitor.hh"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include "../../../core/internal/config_runtime.hh"
|
||||||
|
|
||||||
namespace http = mxb::http;
|
namespace http = mxb::http;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -149,12 +150,28 @@ void ClustrixMonitor::fetch_cluster_nodes_from(MXS_MONITORED_SERVER& ms)
|
|||||||
int health_port = row[3] ? atoi(row[3]) : DEFAULT_HEALTH_PORT;
|
int health_port = row[3] ? atoi(row[3]) : DEFAULT_HEALTH_PORT;
|
||||||
int health_check_threshold = m_config.health_check_threshold();
|
int health_check_threshold = m_config.health_check_threshold();
|
||||||
|
|
||||||
|
string name = "Clustrix-Server-" + std::to_string(id);
|
||||||
|
|
||||||
|
if (SERVER::find_by_unique_name(name) ||
|
||||||
|
runtime_create_server(name.c_str(),
|
||||||
|
ip.c_str(),
|
||||||
|
std::to_string(mysql_port).c_str(),
|
||||||
|
"mariadbbackend",
|
||||||
|
"mysqlbackendauth",
|
||||||
|
false))
|
||||||
|
{
|
||||||
node_infos.emplace_back(id, ip, mysql_port, health_port, health_check_threshold);
|
node_infos.emplace_back(id, ip, mysql_port, health_port, health_check_threshold);
|
||||||
|
|
||||||
string health_url = "http://" + ip + ":" + std::to_string(health_port);
|
string health_url = "http://" + ip + ":" + std::to_string(health_port);
|
||||||
health_urls.push_back(health_url);
|
health_urls.push_back(health_url);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
MXS_ERROR("Could not create server %s at %s:%d.",
|
||||||
|
name.c_str(), ip.c_str(), mysql_port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
MXS_WARNING("Either nodeid and/or iface_ip is missing, "
|
MXS_WARNING("Either nodeid and/or iface_ip is missing, "
|
||||||
"ignoring node.");
|
"ignoring node.");
|
||||||
|
Reference in New Issue
Block a user