MXS-2220 Move rest of dcb printing functions to private class
This commit is contained in:
parent
2b0eac2cd0
commit
3f81a37e70
@ -498,9 +498,6 @@ extern uint64_t server_get_version(const SERVER* server);
|
||||
|
||||
extern void printServer(const SERVER*);
|
||||
extern void printAllServers();
|
||||
extern void dprintAllServers(DCB*);
|
||||
extern void dprintAllServersJson(DCB*);
|
||||
extern void dListServers(DCB*);
|
||||
|
||||
int server_response_time_num_samples(const SERVER* server);
|
||||
double server_response_time_average(const SERVER* server);
|
||||
|
@ -51,9 +51,6 @@ 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*);
|
||||
|
||||
bool have_disk_space_limits() const override
|
||||
{
|
||||
@ -73,6 +70,56 @@ public:
|
||||
m_settings.disk_space_limits = new_limits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print server details to a dcb.
|
||||
*
|
||||
* @param dcb Dcb to print to
|
||||
*/
|
||||
void print_to_dcb(DCB* dcb) const;
|
||||
|
||||
/**
|
||||
* @brief Find a server with the specified name
|
||||
*
|
||||
* @param name Name of the server
|
||||
* @return The server or NULL if not found
|
||||
*/
|
||||
static Server* find_by_unique_name(const std::string& name);
|
||||
|
||||
/**
|
||||
* Print server details to a DCB
|
||||
*
|
||||
* Designed to be called within a debugger session in order
|
||||
* to display all active servers within the gateway
|
||||
*/
|
||||
static void dprintServer(DCB*, const Server*);
|
||||
|
||||
/**
|
||||
* Diagnostic to print number of DCBs in persistent pool for a server
|
||||
*
|
||||
* @param pdcb DCB to print results to
|
||||
* @param server SERVER for which DCBs are to be printed
|
||||
*/
|
||||
static void dprintPersistentDCBs(DCB*, const Server*);
|
||||
|
||||
/**
|
||||
* Print all servers to a DCB
|
||||
*
|
||||
* Designed to be called within a debugger session in order
|
||||
* to display all active servers within the gateway
|
||||
*/
|
||||
static void dprintAllServers(DCB*);
|
||||
|
||||
/**
|
||||
* Print all servers in Json format to a DCB
|
||||
*/
|
||||
static void dprintAllServersJson(DCB*);
|
||||
|
||||
/**
|
||||
* List all servers in a tabular form to a DCB
|
||||
*
|
||||
*/
|
||||
static void dListServers(DCB*);
|
||||
|
||||
mutable std::mutex m_lock;
|
||||
|
||||
private:
|
||||
|
@ -413,16 +413,9 @@ void printAllServers()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print all servers to a DCB
|
||||
*
|
||||
* Designed to be called within a debugger session in order
|
||||
* to display all active servers within the gateway
|
||||
*/
|
||||
void dprintAllServers(DCB* dcb)
|
||||
void Server::dprintAllServers(DCB* dcb)
|
||||
{
|
||||
Guard guard(server_lock);
|
||||
|
||||
for (Server* server : all_servers)
|
||||
{
|
||||
if (server->is_active)
|
||||
@ -432,10 +425,7 @@ void dprintAllServers(DCB* dcb)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print all servers in Json format to a DCB
|
||||
*/
|
||||
void dprintAllServersJson(DCB* dcb)
|
||||
void Server::dprintAllServersJson(DCB* dcb)
|
||||
{
|
||||
json_t* all_servers_json = server_list_to_json("");
|
||||
char* dump = json_dumps(all_servers_json, JSON_INDENT(4));
|
||||
@ -481,21 +471,19 @@ static void cleanup_persistent_connections(const SERVER* server)
|
||||
RoutingWorker::execute_concurrently(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print server details to a DCB
|
||||
*
|
||||
* Designed to be called within a debugger session in order
|
||||
* to display all active servers within the gateway
|
||||
*/
|
||||
void Server::dprintServer(DCB* dcb, const Server* srv)
|
||||
{
|
||||
if (!server_is_active(srv))
|
||||
srv->print_to_dcb(dcb);
|
||||
}
|
||||
|
||||
void Server::print_to_dcb(DCB* dcb) const
|
||||
{
|
||||
const Server* server = this;
|
||||
if (!server_is_active(server))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Server* server = srv;
|
||||
|
||||
dcb_printf(dcb, "Server %p (%s)\n", server, server->name);
|
||||
dcb_printf(dcb, "\tServer: %s\n", server->address);
|
||||
string stat = mxs::server_status(server);
|
||||
@ -597,22 +585,12 @@ void Server::dprintServer(DCB* dcb, const Server* srv)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Diagnostic to print number of DCBs in persistent pool for a server
|
||||
*
|
||||
* @param pdcb DCB to print results to
|
||||
* @param server SERVER for which DCBs are to be printed
|
||||
*/
|
||||
void Server::dprintPersistentDCBs(DCB* pdcb, const Server* server)
|
||||
{
|
||||
dcb_printf(pdcb, "Number of persistent DCBs: %d\n", server->stats.n_persistent);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all servers in a tabular form to a DCB
|
||||
*
|
||||
*/
|
||||
void dListServers(DCB* dcb)
|
||||
void Server::dListServers(DCB* dcb)
|
||||
{
|
||||
Guard guard(server_lock);
|
||||
bool have_servers = std::any_of(all_servers.begin(),
|
||||
@ -1585,12 +1563,6 @@ void Server::response_time_add(double ave, int num_samples)
|
||||
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);
|
||||
|
@ -336,13 +336,13 @@ struct subcommand showoptions[] =
|
||||
{ARG_TYPE_SERVER }
|
||||
},
|
||||
{
|
||||
"servers", 0, 0, (FN)dprintAllServers,
|
||||
"servers", 0, 0, (FN)Server::dprintAllServers,
|
||||
"Show all servers",
|
||||
"Usage: show servers",
|
||||
{0 }
|
||||
},
|
||||
{
|
||||
"serversjson", 0, 0, (FN)dprintAllServersJson,
|
||||
"serversjson", 0, 0, (FN)Server::dprintAllServersJson,
|
||||
"Show all servers in JSON",
|
||||
"Usage: show serversjson",
|
||||
{0 }
|
||||
@ -494,7 +494,7 @@ struct subcommand listoptions[] =
|
||||
{0 }
|
||||
},
|
||||
{
|
||||
"servers", 0, 0, (FN)dListServers,
|
||||
"servers", 0, 0, (FN)Server::dListServers,
|
||||
"List all servers",
|
||||
"Usage: list servers",
|
||||
{0 }
|
||||
|
Loading…
x
Reference in New Issue
Block a user