MXS-553: List connections in sessions resource
The connections that relate to a particular session are now a part of the sessions resource. Currently, only the generic information is stored for each connection (id and server name).
This commit is contained in:
@ -400,6 +400,15 @@ int dcb_get_port(const DCB *dcb);
|
|||||||
*/
|
*/
|
||||||
DCB* dcb_get_current();
|
DCB* dcb_get_current();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get JSON representation of the DCB
|
||||||
|
*
|
||||||
|
* @param dcb DCB to convert to JSON
|
||||||
|
*
|
||||||
|
* @return The JSON representation
|
||||||
|
*/
|
||||||
|
json_t* dcb_to_json(DCB* dcb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DCB flags values
|
* DCB flags values
|
||||||
*/
|
*/
|
||||||
|
@ -3749,3 +3749,15 @@ static int downstream_throttle_callback(DCB *dcb, DCB_REASON reason, void *userd
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
json_t* dcb_to_json(DCB* dcb)
|
||||||
|
{
|
||||||
|
json_t* obj = json_object();
|
||||||
|
|
||||||
|
char buf[25];
|
||||||
|
snprintf(buf, sizeof(buf), "%p", dcb);
|
||||||
|
json_object_set_new(obj, "id", json_string(buf));
|
||||||
|
json_object_set_new(obj, "server", json_string(dcb->server->name));
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
@ -1042,6 +1042,15 @@ json_t* session_json_data(const MXS_SESSION *session, const char *host)
|
|||||||
json_object_set_new(attr, "idle", json_real(idle));
|
json_object_set_new(attr, "idle", json_real(idle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
json_t* dcb_arr = json_array();
|
||||||
|
|
||||||
|
for (auto it = session->dcb_set->begin(); it != session->dcb_set->end(); it++)
|
||||||
|
{
|
||||||
|
json_array_append_new(dcb_arr, dcb_to_json(*it));
|
||||||
|
}
|
||||||
|
|
||||||
|
json_object_set_new(attr, "connections", dcb_arr);
|
||||||
|
|
||||||
json_object_set_new(data, CN_ATTRIBUTES, attr);
|
json_object_set_new(data, CN_ATTRIBUTES, attr);
|
||||||
json_object_set_new(data, CN_LINKS, mxs_json_self_link(host, CN_SESSIONS, ss.str().c_str()));
|
json_object_set_new(data, CN_LINKS, mxs_json_self_link(host, CN_SESSIONS, ss.str().c_str()));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user