From f311bb77e37ead1315969ef08bd9f35ea1e74a45 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 26 Mar 2015 12:45:45 +0000 Subject: [PATCH] mds: add get_down_mds_set method For places where we would like to treat failed and damaged MDS ranks the same, like detecting when someone has dropped offline. Signed-off-by: John Spray --- src/mds/MDSMap.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index b0818e5d5a082..fa0446f583fe1 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -349,6 +349,17 @@ public: void get_failed_mds_set(std::set& s) { s = failed; } + + /** + * Get MDS ranks which are in but not up. + */ + void get_down_mds_set(std::set *s) + { + assert(s != NULL); + s->insert(failed.begin(), failed.end()); + s->insert(damaged.begin(), damaged.end()); + } + int get_failed() { if (!failed.empty()) return *failed.begin(); return -1; @@ -551,10 +562,19 @@ public: return up.empty(); } - // inst + /** + * Get whether a rank is 'up', i.e. has + * an MDS daemon's entity_inst_t associated + * with it. + */ bool have_inst(mds_rank_t m) { return up.count(m); } + + /** + * Get the MDS daemon entity_inst_t for a rank + * known to be up. + */ const entity_inst_t get_inst(mds_rank_t m) { assert(up.count(m)); return mds_info[up[m]].get_inst(); @@ -563,6 +583,14 @@ public: assert(up.count(m)); return mds_info[up[m]].addr; } + + /** + * Get the MDS daemon entity_inst_t for a rank, + * if it is up. + * + * @return true if the rank was up and the inst + * was populated, else false. + */ bool get_inst(mds_rank_t m, entity_inst_t& inst) { if (up.count(m)) { inst = get_inst(m); -- 2.39.5