MXS-2220 Move server_update_address inside class
Should be moved to internal class once blr is cleaned up.
This commit is contained in:
@ -161,7 +161,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Base settings
|
// Base settings
|
||||||
char address[MAX_ADDRESS_LEN] = {'\0'}; /**< Server hostname/IP-address */
|
char address[MAX_ADDRESS_LEN + 1] = {'\0'}; /**< Server hostname/IP-address */
|
||||||
int port = -1; /**< Server port */
|
int port = -1; /**< Server port */
|
||||||
int extra_port = -1; /**< Alternative monitor port if normal port fails */
|
int extra_port = -1; /**< Alternative monitor port if normal port fails */
|
||||||
|
|
||||||
@ -270,6 +270,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual std::string protocol() const = 0;
|
virtual std::string protocol() const = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update server address. TODO: Move this to internal class once blr is gone.
|
||||||
|
*
|
||||||
|
* @param address The new address
|
||||||
|
*/
|
||||||
|
bool server_update_address(const std::string& address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the server port. TODO: Move this to internal class once blr is gone.
|
* Update the server port. TODO: Move this to internal class once blr is gone.
|
||||||
*
|
*
|
||||||
@ -485,8 +492,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
void server_add_response_average(SERVER* server, double ave, int num_samples);
|
void server_add_response_average(SERVER* server, double ave, int num_samples);
|
||||||
|
|
||||||
extern void server_update_address(SERVER* server, const char* address);
|
|
||||||
|
|
||||||
int server_response_time_num_samples(const SERVER* server);
|
int server_response_time_num_samples(const SERVER* server);
|
||||||
double server_response_time_average(const SERVER* server);
|
double server_response_time_average(const SERVER* server);
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ bool runtime_alter_server(Server* server, const char* key, const char* value)
|
|||||||
|
|
||||||
if (strcmp(key, CN_ADDRESS) == 0)
|
if (strcmp(key, CN_ADDRESS) == 0)
|
||||||
{
|
{
|
||||||
server_update_address(server, value);
|
server->server_update_address(value);
|
||||||
}
|
}
|
||||||
else if (strcmp(key, CN_PORT) == 0)
|
else if (strcmp(key, CN_PORT) == 0)
|
||||||
{
|
{
|
||||||
|
@ -312,7 +312,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void printServer();
|
void printServer();
|
||||||
|
|
||||||
mutable std::mutex m_lock;
|
|
||||||
DCB** persistent = nullptr;/**< List of unused persistent connections to the server */
|
DCB** persistent = nullptr;/**< List of unused persistent connections to the server */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -790,21 +790,19 @@ std::unique_ptr<ResultSet> serverGetList()
|
|||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
bool SERVER::server_update_address(const string& new_address)
|
||||||
* Update the address value of a specific server
|
|
||||||
*
|
|
||||||
* @param server The server to update
|
|
||||||
* @param address The new address
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void server_update_address(SERVER* server, const char* address)
|
|
||||||
{
|
{
|
||||||
Guard guard(this_unit.all_servers_lock);
|
bool rval = false;
|
||||||
|
if (new_address.length() <= MAX_ADDRESS_LEN)
|
||||||
if (server && address)
|
|
||||||
{
|
{
|
||||||
strcpy(server->address, address);
|
careful_strcpy(address, MAX_ADDRESS_LEN, new_address);
|
||||||
|
rval = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MXS_ERROR(ERR_TOO_LONG_CONFIG_VALUE, CN_ADDRESS, MAX_ADDRESS_LEN);
|
||||||
|
}
|
||||||
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SERVER::update_port(int new_port)
|
void SERVER::update_port(int new_port)
|
||||||
|
@ -3206,7 +3206,7 @@ void blr_master_set_config(ROUTER_INSTANCE* inst, const ChangeMasterConfig& conf
|
|||||||
|
|
||||||
if (!config.host.empty())
|
if (!config.host.empty())
|
||||||
{
|
{
|
||||||
server_update_address(backend_server, config.host.c_str());
|
backend_server->server_update_address(config.host);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.port)
|
if (config.port)
|
||||||
|
@ -4655,7 +4655,7 @@ static int blr_set_master_hostname(ROUTER_INSTANCE* router, const char* hostname
|
|||||||
{
|
{
|
||||||
mxb_assert((*hostname != '\'') && (*hostname != '"'));
|
mxb_assert((*hostname != '\'') && (*hostname != '"'));
|
||||||
|
|
||||||
server_update_address(router->service->dbref->server, hostname);
|
router->service->dbref->server->server_update_address(hostname);
|
||||||
|
|
||||||
MXS_INFO("%s: New MASTER_HOST is [%s]",
|
MXS_INFO("%s: New MASTER_HOST is [%s]",
|
||||||
router->service->name,
|
router->service->name,
|
||||||
@ -4883,7 +4883,7 @@ static void blr_master_get_config(ROUTER_INSTANCE* router, MasterServerConfig* c
|
|||||||
static void blr_master_restore_config(ROUTER_INSTANCE* router,
|
static void blr_master_restore_config(ROUTER_INSTANCE* router,
|
||||||
const MasterServerConfig& prev_master)
|
const MasterServerConfig& prev_master)
|
||||||
{
|
{
|
||||||
server_update_address(router->service->dbref->server, prev_master.host.c_str());
|
router->service->dbref->server->server_update_address(prev_master.host);
|
||||||
router->service->dbref->server->update_port(prev_master.port);
|
router->service->dbref->server->update_port(prev_master.port);
|
||||||
|
|
||||||
router->ssl_enabled = prev_master.ssl_enabled;
|
router->ssl_enabled = prev_master.ssl_enabled;
|
||||||
@ -4903,7 +4903,7 @@ static void blr_master_restore_config(ROUTER_INSTANCE* router,
|
|||||||
*/
|
*/
|
||||||
static void blr_master_set_empty_config(ROUTER_INSTANCE* router)
|
static void blr_master_set_empty_config(ROUTER_INSTANCE* router)
|
||||||
{
|
{
|
||||||
server_update_address(router->service->dbref->server, "none");
|
router->service->dbref->server->server_update_address("none");
|
||||||
router->service->dbref->server->update_port(3306);
|
router->service->dbref->server->update_port(3306);
|
||||||
|
|
||||||
router->current_pos = 4;
|
router->current_pos = 4;
|
||||||
@ -4925,7 +4925,7 @@ static void blr_master_set_empty_config(ROUTER_INSTANCE* router)
|
|||||||
*/
|
*/
|
||||||
static void blr_master_apply_config(ROUTER_INSTANCE* router, const MasterServerConfig& prev_master)
|
static void blr_master_apply_config(ROUTER_INSTANCE* router, const MasterServerConfig& prev_master)
|
||||||
{
|
{
|
||||||
server_update_address(router->service->dbref->server, prev_master.host.c_str());
|
router->service->dbref->server->server_update_address(prev_master.host);
|
||||||
router->service->dbref->server->update_port(prev_master.port);
|
router->service->dbref->server->update_port(prev_master.port);
|
||||||
router->current_pos = prev_master.pos;
|
router->current_pos = prev_master.pos;
|
||||||
router->binlog_position = prev_master.safe_pos;
|
router->binlog_position = prev_master.safe_pos;
|
||||||
|
Reference in New Issue
Block a user