MXS-1220: Implement JSON diagnostics for most routers

All routers except the binlogrouter now fully implement the JSON
diagnostic entry point. The binlogrouter needs to be handled in a separate
commit as it produces a large amount of diagnostic output.
This commit is contained in:
Markus Mäkelä
2017-04-18 10:48:22 +03:00
committed by Markus Mäkelä
parent 25c8fb8556
commit eb3ff1cc7b
14 changed files with 127 additions and 161 deletions

View File

@ -144,23 +144,31 @@ HintRouterSession* HintRouter::newSession(MXS_SESSION *pSession)
return rval;
}
void HintRouter::diagnostics(DCB* pOut)
json_t* HintRouter::diagnostics()
{
HR_ENTRY();
json_t* rval = json_object();
json_t* arr = json_array();
for (int i = 0; default_action_values[i].name; i++)
{
if (default_action_values[i].enum_value == (uint64_t)m_default_action)
{
dcb_printf(pOut, "\tDefault action: route to %s\n", default_action_values[i].name);
json_array_append(arr, json_string(default_action_values[i].name));
}
}
dcb_printf(pOut, "\tDefault server: %s\n", m_default_server.c_str());
dcb_printf(pOut, "\tMaximum slave connections/session: %d\n", m_max_slaves);
dcb_printf(pOut, "\tTotal cumulative slave connections: %d\n", m_total_slave_conns);
dcb_printf(pOut, "\tQueries routed to master: %d\n", m_routed_to_master);
dcb_printf(pOut, "\tQueries routed to single slave: %d\n", m_routed_to_slave);
dcb_printf(pOut, "\tQueries routed to named server: %d\n", m_routed_to_named);
dcb_printf(pOut, "\tQueries routed to all servers: %d\n", m_routed_to_all);
json_object_set_new(rval, "default_action", arr);
json_object_set_new(rval, "default_server", json_string(m_default_server.c_str()));
json_object_set_new(rval, "max_slave_connections", json_integer(m_max_slaves));
json_object_set_new(rval, "total_slave_connections", json_integer(m_total_slave_conns));
json_object_set_new(rval, "route_master", json_integer(m_routed_to_master));
json_object_set_new(rval, "route_slave", json_integer(m_routed_to_slave));
json_object_set_new(rval, "route_named_server", json_integer(m_routed_to_named));
json_object_set_new(rval, "route_all", json_integer(m_routed_to_all));
return rval;
}
Dcb HintRouter::connect_to_backend(MXS_SESSION* session, SERVER_REF* sref,