f->dump_int("mds", *p);
f->close_section();
f->open_object_section("info");
- for (map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.begin(); p != mds_info.end(); ++p) {
+ for (const auto& [gid, info] : mds_info) {
char s[25]; // 'gid_' + len(str(ULLONG_MAX)) + '\0'
- sprintf(s, "gid_%llu", (long long unsigned)p->first);
+ sprintf(s, "gid_%llu", (long long unsigned)gid);
f->open_object_section(s);
- p->second.dump(f);
+ info.dump(f);
f->close_section();
}
f->close_section();
f->open_array_section("data_pools");
- for (const auto p: data_pools)
+ for (const auto& p: data_pools)
f->dump_int("pool", p);
f->close_section();
f->dump_int("metadata_pool", metadata_pool);
if (!is_up(i))
continue;
mds_gid_t gid = up.find(i)->second;
- map<mds_gid_t,mds_info_t>::const_iterator info = mds_info.find(gid);
+ const auto& info = mds_info.at(gid);
stringstream ss;
if (is_resolve(i))
- ss << "mds." << info->second.name << " at " << info->second.addrs
+ ss << "mds." << info.name << " at " << info.addrs
<< " rank " << i << " is resolving";
if (is_replay(i))
- ss << "mds." << info->second.name << " at " << info->second.addrs
+ ss << "mds." << info.name << " at " << info.addrs
<< " rank " << i << " is replaying journal";
if (is_rejoin(i))
- ss << "mds." << info->second.name << " at " << info->second.addrs
+ ss << "mds." << info.name << " at " << info.addrs
<< " rank " << i << " is rejoining";
if (is_reconnect(i))
- ss << "mds." << info->second.name << " at " << info->second.addrs
+ ss << "mds." << info.name << " at " << info.addrs
<< " rank " << i << " is reconnecting to clients";
if (ss.str().length())
detail->push_back(make_pair(HEALTH_WARN, ss.str()));
summary.push_back(make_pair(HEALTH_WARN, ss.str()));
}
- map<mds_gid_t, mds_info_t>::const_iterator m_end = mds_info.end();
set<string> laggy;
for (const auto &u : up) {
- map<mds_gid_t, mds_info_t>::const_iterator m = mds_info.find(u.second);
- if (m == m_end) {
- std::cerr << "Up rank " << u.first << " GID " << u.second << " not found!" << std::endl;
- }
- ceph_assert(m != m_end);
- const mds_info_t &mds_info(m->second);
- if (mds_info.laggy()) {
- laggy.insert(mds_info.name);
+ const auto& info = mds_info.at(u.second);
+ if (info.laggy()) {
+ laggy.insert(info.name);
if (detail) {
std::ostringstream oss;
- oss << "mds." << mds_info.name << " at " << mds_info.addrs
+ oss << "mds." << info.name << " at " << info.addrs
<< " is laggy/unresponsive";
detail->push_back(make_pair(HEALTH_WARN, oss.str()));
}
if (!is_up(i))
continue;
mds_gid_t gid = up.find(i)->second;
- map<mds_gid_t,mds_info_t>::const_iterator info = mds_info.find(gid);
+ const auto& info = mds_info.at(gid);
stringstream ss;
- ss << "fs " << fs_name << " mds." << info->second.name << " at "
- << info->second.addrs << " rank " << i;
+ ss << "fs " << fs_name << " mds." << info.name << " at "
+ << info.addrs << " rank " << i;
if (is_resolve(i))
ss << " is resolving";
if (is_replay(i))
return get_enabled() && (is_data_pool(poolid) || metadata_pool == poolid);
}
- const std::map<mds_gid_t,mds_info_t>& get_mds_info() const { return mds_info; }
- const mds_info_t& get_mds_info_gid(mds_gid_t gid) const {
+ const auto& get_mds_info() const { return mds_info; }
+ const auto& get_mds_info_gid(mds_gid_t gid) const {
return mds_info.at(gid);
}
const mds_info_t& get_mds_info(mds_rank_t m) const {
return mds_info.at(up.at(m));
}
mds_gid_t find_mds_gid_by_name(std::string_view s) const {
- for (std::map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.begin();
- p != mds_info.end();
- ++p) {
- if (p->second.name == s) {
- return p->first;
+ for (const auto& [gid, info] : mds_info) {
+ if (info.name == s) {
+ return gid;
}
}
return MDS_GID_NONE;
bool is_dne_gid(mds_gid_t gid) const { return mds_info.count(gid) == 0; }
/**
- * Get MDS rank state if the rank is up, else STATE_NULL
+ * Get MDS daemon status by GID
*/
- DaemonState get_state(mds_rank_t m) const {
- std::map<mds_rank_t, mds_gid_t>::const_iterator u = up.find(m);
- if (u == up.end())
+ auto get_state_gid(mds_gid_t gid) const {
+ auto it = mds_info.find(gid);
+ if (it == mds_info.end())
return STATE_NULL;
- return get_state_gid(u->second);
+ return it->second.state;
}
/**
- * Get MDS daemon status by GID
+ * Get MDS rank state if the rank is up, else STATE_NULL
*/
- DaemonState get_state_gid(mds_gid_t gid) const {
- std::map<mds_gid_t,mds_info_t>::const_iterator i = mds_info.find(gid);
- if (i == mds_info.end())
+ auto get_state(mds_rank_t m) const {
+ auto it = up.find(m);
+ if (it == up.end())
return STATE_NULL;
- return i->second.state;
+ return get_state_gid(it->second);
}
- const mds_info_t& get_info(const mds_rank_t m) const {
+ const auto& get_info(mds_rank_t m) const {
return mds_info.at(up.at(m));
}
- const mds_info_t& get_info_gid(const mds_gid_t gid) const {
+ const auto& get_info_gid(mds_gid_t gid) const {
return mds_info.at(gid);
}