MXS-2220 Use private server class in runtime alter commands
This only affects commands started from MaxAdmin.
This commit is contained in:
parent
c7d5794953
commit
84e8efceca
@ -475,8 +475,6 @@ extern void printServer(const SERVER*);
|
||||
extern void printAllServers();
|
||||
extern void dprintAllServers(DCB*);
|
||||
extern void dprintAllServersJson(DCB*);
|
||||
extern void dprintServer(DCB*, const SERVER*);
|
||||
extern void dprintPersistentDCBs(DCB*, const SERVER*);
|
||||
extern void dListServers(DCB*);
|
||||
|
||||
int server_response_time_num_samples(const SERVER* server);
|
||||
|
@ -31,7 +31,6 @@ std::unique_ptr<ResultSet> serverGetList();
|
||||
class Server : public SERVER
|
||||
{
|
||||
public:
|
||||
|
||||
Server()
|
||||
: m_response_time(maxbase::EMAverage {0.04, 0.35, 500})
|
||||
{
|
||||
@ -48,6 +47,9 @@ public:
|
||||
}
|
||||
|
||||
void response_time_add(double ave, int num_samples);
|
||||
static Server* find_by_unique_name(const std::string& name);
|
||||
static void dprintServer(DCB*, const Server*);
|
||||
static void dprintPersistentDCBs(DCB*, const Server*);
|
||||
|
||||
mutable std::mutex m_lock;
|
||||
|
||||
|
@ -429,7 +429,7 @@ void dprintAllServers(DCB* dcb)
|
||||
{
|
||||
if (server->is_active)
|
||||
{
|
||||
dprintServer(dcb, server);
|
||||
Server::dprintServer(dcb, server);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -489,14 +489,14 @@ static void cleanup_persistent_connections(const SERVER* server)
|
||||
* Designed to be called within a debugger session in order
|
||||
* to display all active servers within the gateway
|
||||
*/
|
||||
void dprintServer(DCB* dcb, const SERVER* srv)
|
||||
void Server::dprintServer(DCB* dcb, const Server* srv)
|
||||
{
|
||||
if (!server_is_active(srv))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Server* server = static_cast<const Server*>(srv);
|
||||
const Server* server = srv;
|
||||
|
||||
dcb_printf(dcb, "Server %p (%s)\n", server, server->name);
|
||||
dcb_printf(dcb, "\tServer: %s\n", server->address);
|
||||
@ -605,7 +605,7 @@ void dprintServer(DCB* dcb, const SERVER* srv)
|
||||
* @param pdcb DCB to print results to
|
||||
* @param server SERVER for which DCBs are to be printed
|
||||
*/
|
||||
void dprintPersistentDCBs(DCB* pdcb, const SERVER* server)
|
||||
void Server::dprintPersistentDCBs(DCB* pdcb, const Server* server)
|
||||
{
|
||||
dcb_printf(pdcb, "Number of persistent DCBs: %d\n", server->stats.n_persistent);
|
||||
}
|
||||
@ -1595,3 +1595,22 @@ void Server::response_time_add(double ave, int num_samples)
|
||||
m_response_time.set_sample_max(new_max);
|
||||
m_response_time.add(ave, num_samples);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find a server with the specified name
|
||||
*
|
||||
* @param name Name of the server
|
||||
* @return The server or NULL if not found
|
||||
*/
|
||||
Server* Server::find_by_unique_name(const string& name)
|
||||
{
|
||||
Guard guard(server_lock);
|
||||
for (Server* server : all_servers)
|
||||
{
|
||||
if (server->is_active && name == server->name)
|
||||
{
|
||||
return server;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -62,6 +62,7 @@
|
||||
#include "../../../core/internal/monitor.hh"
|
||||
#include "../../../core/internal/poll.hh"
|
||||
#include "../../../core/internal/session.hh"
|
||||
#include "../../../core/internal/server.hh"
|
||||
#include "../../../core/internal/filter.hh"
|
||||
|
||||
#define MAXARGS 14
|
||||
@ -307,7 +308,7 @@ struct subcommand showoptions[] =
|
||||
{0 }
|
||||
},
|
||||
{
|
||||
"persistent", 1, 1, (FN)dprintPersistentDCBs,
|
||||
"persistent", 1, 1, (FN)Server::dprintPersistentDCBs,
|
||||
"Show the persistent connection pool of a server",
|
||||
"Usage: show persistent SERVER\n"
|
||||
"\n"
|
||||
@ -324,7 +325,7 @@ struct subcommand showoptions[] =
|
||||
{0 }
|
||||
},
|
||||
{
|
||||
"server", 1, 1, (FN)dprintServer,
|
||||
"server", 1, 1, (FN)Server::dprintServer,
|
||||
"Show server details",
|
||||
"Usage: show server SERVER\n"
|
||||
"\n"
|
||||
@ -679,7 +680,7 @@ struct subcommand restartoptions[] =
|
||||
{EMPTY_OPTION }
|
||||
};
|
||||
|
||||
static void set_server(DCB* dcb, SERVER* server, char* bit);
|
||||
static void set_server(DCB* dcb, Server* server, char* bit);
|
||||
static void set_pollsleep(DCB* dcb, int);
|
||||
static void set_nbpoll(DCB* dcb, int);
|
||||
static void set_log_throttling(DCB* dcb, int count, int window_ms, int suppress_ms);
|
||||
@ -728,7 +729,7 @@ struct subcommand setoptions[] =
|
||||
{EMPTY_OPTION}
|
||||
};
|
||||
|
||||
static void clear_server(DCB* dcb, SERVER* server, char* bit);
|
||||
static void clear_server(DCB* dcb, Server* server, char* bit);
|
||||
/**
|
||||
* The subcommands of the clear command
|
||||
*/
|
||||
@ -948,19 +949,11 @@ struct subcommand disableoptions[] =
|
||||
static void inet_add_user(DCB*, char* user, char* password);
|
||||
static void inet_add_admin_user(DCB*, char* user, char* password);
|
||||
|
||||
static void cmd_AddServer(DCB* dcb,
|
||||
SERVER* server,
|
||||
char* v1,
|
||||
char* v2,
|
||||
char* v3,
|
||||
char* v4,
|
||||
char* v5,
|
||||
char* v6,
|
||||
char* v7,
|
||||
char* v8,
|
||||
char* v9,
|
||||
char* v10,
|
||||
char* v11)
|
||||
static void cmd_AddServer(DCB* dcb, Server* server,
|
||||
char* v1, char* v2, char* v3,
|
||||
char* v4, char* v5, char* v6,
|
||||
char* v7, char* v8, char* v9,
|
||||
char* v10, char* v11)
|
||||
{
|
||||
char* values[11] = {v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11};
|
||||
const int items = sizeof(values) / sizeof(values[0]);
|
||||
@ -1066,19 +1059,11 @@ struct subcommand addoptions[] =
|
||||
|
||||
static void telnetdRemoveUser(DCB*, char* user);
|
||||
|
||||
static void cmd_RemoveServer(DCB* dcb,
|
||||
SERVER* server,
|
||||
char* v1,
|
||||
char* v2,
|
||||
char* v3,
|
||||
char* v4,
|
||||
char* v5,
|
||||
char* v6,
|
||||
char* v7,
|
||||
char* v8,
|
||||
char* v9,
|
||||
char* v10,
|
||||
char* v11)
|
||||
static void cmd_RemoveServer(DCB* dcb, Server* server,
|
||||
char* v1, char* v2, char* v3,
|
||||
char* v4, char* v5, char* v6,
|
||||
char* v7, char* v8, char* v9,
|
||||
char* v10, char* v11)
|
||||
{
|
||||
char* values[11] = {v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11};
|
||||
const int items = sizeof(values) / sizeof(values[0]);
|
||||
@ -1398,7 +1383,7 @@ struct subcommand createoptions[] =
|
||||
}
|
||||
};
|
||||
|
||||
static void destroyServer(DCB* dcb, SERVER* server)
|
||||
static void destroyServer(DCB* dcb, Server* server)
|
||||
{
|
||||
/** Do this so that we don't directly access the server. Currently, the
|
||||
* destruction of a server does not free any memory and the server stays
|
||||
@ -1495,20 +1480,11 @@ struct subcommand destroyoptions[] =
|
||||
* with one function. This could be handled with a variadic function but the
|
||||
* required complexity would probably negate any benefits.
|
||||
*/
|
||||
static void alterServer(DCB* dcb,
|
||||
SERVER* server,
|
||||
char* v1,
|
||||
char* v2,
|
||||
char* v3,
|
||||
char* v4,
|
||||
char* v5,
|
||||
char* v6,
|
||||
char* v7,
|
||||
char* v8,
|
||||
char* v9,
|
||||
char* v10,
|
||||
char* v11,
|
||||
char* v12,
|
||||
static void alterServer(DCB* dcb, Server* server,
|
||||
char* v1, char* v2, char* v3,
|
||||
char* v4, char* v5, char* v6,
|
||||
char* v7, char* v8, char* v9,
|
||||
char* v10, char* v11, char* v12,
|
||||
char* v13)
|
||||
{
|
||||
char* values[] = {v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13};
|
||||
@ -2008,7 +1984,7 @@ static unsigned long convert_arg(char* arg, int arg_type)
|
||||
|
||||
case ARG_TYPE_SERVER:
|
||||
fix_object_name(arg);
|
||||
rval = (unsigned long)server_find_by_unique_name(arg);
|
||||
rval = (unsigned long)Server::find_by_unique_name(arg);
|
||||
break;
|
||||
|
||||
case ARG_TYPE_SESSION:
|
||||
@ -2541,7 +2517,7 @@ static void restart_service(DCB* dcb, SERVICE* service)
|
||||
* @param server The server to set the status of
|
||||
* @param bit String representation of the status bit
|
||||
*/
|
||||
static void set_server(DCB* dcb, SERVER* server, char* bit)
|
||||
static void set_server(DCB* dcb, Server* server, char* bit)
|
||||
{
|
||||
unsigned int bitvalue;
|
||||
|
||||
@ -2567,7 +2543,7 @@ static void set_server(DCB* dcb, SERVER* server, char* bit)
|
||||
* @param server The server to set the status of
|
||||
* @param bit String representation of the status bit
|
||||
*/
|
||||
static void clear_server(DCB* dcb, SERVER* server, char* bit)
|
||||
static void clear_server(DCB* dcb, Server* server, char* bit)
|
||||
{
|
||||
unsigned int bitvalue;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user