Remove redundant sort in monitor_relations_to_server
Servers can have only one monitor relationship.
This commit is contained in:
parent
752aa9de57
commit
a33996ab20
@ -488,32 +488,29 @@ json_t* MonitorManager::monitor_list_to_json(const char* host)
|
||||
json_t* MonitorManager::monitor_relations_to_server(const SERVER* server, const char* host)
|
||||
{
|
||||
mxb_assert(Monitor::is_admin_thread());
|
||||
std::vector<std::string> names;
|
||||
std::string name;
|
||||
this_unit.foreach_monitor(
|
||||
[&names, server](Monitor* mon) {
|
||||
[&name, server](Monitor* mon) {
|
||||
// The serverlist of an individual monitor should not change while a
|
||||
// monitor is running.
|
||||
for (MonitorServer* db : mon->servers())
|
||||
{
|
||||
if (db->server == server)
|
||||
{
|
||||
names.push_back(mon->m_name);
|
||||
mxb_assert(name.empty());
|
||||
name = mon->m_name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
std::sort(names.begin(), names.end());
|
||||
|
||||
json_t* rel = NULL;
|
||||
if (!names.empty())
|
||||
|
||||
if (!name.empty())
|
||||
{
|
||||
rel = mxs_json_relationship(host, MXS_JSON_API_MONITORS);
|
||||
for (auto& name : names)
|
||||
{
|
||||
mxs_json_add_relation(rel, name.c_str(), CN_MONITORS);
|
||||
}
|
||||
mxs_json_add_relation(rel, name.c_str(), CN_MONITORS);
|
||||
}
|
||||
|
||||
return rel;
|
||||
|
Loading…
x
Reference in New Issue
Block a user