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:
Johan Wikman 2019-01-15 10:37:33 +02:00
parent bd2eb3d5dc
commit ac61e205d8
3 changed files with 25 additions and 6 deletions

View File

@ -209,7 +209,8 @@ bool runtime_create_server(const char* name,
const char* address,
const char* port,
const char* protocol,
const char* authenticator)
const char* authenticator,
bool serialize)
{
std::lock_guard<std::mutex> guard(crt_lock);
bool rval = false;
@ -244,7 +245,7 @@ bool runtime_create_server(const char* name,
Server* server = Server::server_alloc(name, ctx.parameters);
if (server && server->serialize())
if (server && (!serialize || server->serialize()))
{
rval = true;
MXS_NOTICE("Created server '%s' at %s:%u",

View File

@ -57,7 +57,8 @@ bool runtime_create_server(const char* name,
const char* address,
const char* port,
const char* protocol,
const char* authenticator);
const char* authenticator,
bool serialize = true);
/**
* @brief Destroy a server

View File

@ -13,6 +13,7 @@
#include "clustrixmonitor.hh"
#include <algorithm>
#include "../../../core/internal/config_runtime.hh"
namespace http = mxb::http;
using namespace std;
@ -149,10 +150,26 @@ void ClustrixMonitor::fetch_cluster_nodes_from(MXS_MONITORED_SERVER& ms)
int health_port = row[3] ? atoi(row[3]) : DEFAULT_HEALTH_PORT;
int health_check_threshold = m_config.health_check_threshold();
node_infos.emplace_back(id, ip, mysql_port, health_port, health_check_threshold);
string name = "Clustrix-Server-" + std::to_string(id);
string health_url = "http://" + ip + ":" + std::to_string(health_port);
health_urls.push_back(health_url);
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);
string health_url = "http://" + ip + ":" + std::to_string(health_port);
health_urls.push_back(health_url);
}
else
{
MXS_ERROR("Could not create server %s at %s:%d.",
name.c_str(), ip.c_str(), mysql_port);
}
}
else
{