From 808a851d6b0bb8e7246b32887d15f1875ed6f916 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 8 Dec 2011 13:02:12 -0800 Subject: [PATCH] mdsmap: rename get_num_*_mds() methods Signed-off-by: Sage Weil --- src/client/Client.cc | 4 ++-- src/mds/MDBalancer.cc | 6 +++--- src/mds/MDS.cc | 6 +++--- src/mds/MDSMap.h | 9 +++++++-- src/mon/MDSMonitor.cc | 4 ++-- src/tools/gui.cc | 8 ++++---- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index a13ee8f7ee787..3ddbbc700fda6 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -4790,7 +4790,7 @@ int Client::lookup_hash(inodeno_t ino, inodeno_t dirino, const char *name) path2.push_dentry(string(f)); req->set_filepath2(path2); - int r = make_request(req, -1, -1, NULL, rand() % mdsmap->get_num_mds()); + int r = make_request(req, -1, -1, NULL, rand() % mdsmap->get_num_in_mds()); ldout(cct, 3) << "lookup_hash exit(" << ino << ", #" << dirino << "/" << name << ") = " << r << dendl; return r; } @@ -4804,7 +4804,7 @@ int Client::lookup_ino(inodeno_t ino) filepath path(ino); req->set_filepath(path); - int r = make_request(req, -1, -1, NULL, rand() % mdsmap->get_num_mds()); + int r = make_request(req, -1, -1, NULL, rand() % mdsmap->get_num_in_mds()); ldout(cct, 3) << "lookup_ino exit(" << ino << ") = " << r << dendl; return r; } diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index eb8fb7530311d..d81b9ead2e43b 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -274,7 +274,7 @@ void MDBalancer::handle_heartbeat(MHeartbeat *m) //dout(0) << " load is " << load << " have " << mds_load.size() << dendl; { - unsigned cluster_size = mds->get_mds_map()->get_num_mds(); + unsigned cluster_size = mds->get_mds_map()->get_num_in_mds(); if (mds_load.size() == cluster_size) { // let's go! //export_empties(); // no! @@ -433,7 +433,7 @@ void MDBalancer::prep_rebalance(int beat) ++i) my_targets[*i] = 0.0; } else { - int cluster_size = mds->get_mds_map()->get_num_mds(); + int cluster_size = mds->get_mds_map()->get_num_in_mds(); int whoami = mds->get_nodeid(); rebalance_time = ceph_clock_now(g_ceph_context); @@ -1050,7 +1050,7 @@ void MDBalancer::hit_dir(utime_t now, CDir *dir, int type, int who, double amoun dir_pop >= g_conf->mds_bal_replicate_threshold) { // replicate float rdp = dir->pop_me.get(META_POP_IRD).get(now, mds->mdcache->decayrate); - rd_adj = rdp / mds->get_mds_map()->get_num_mds() - rdp; + rd_adj = rdp / mds->get_mds_map()->get_num_in_mds() - rdp; rd_adj /= 2.0; // temper somewhat dout(0) << "replicating dir " << *dir << " pop " << dir_pop << " .. rdp " << rdp << " adj " << rd_adj << dendl; diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index 3cad9d119b237..8672fe9d7fe62 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -1386,8 +1386,8 @@ void MDS::replay_done() inotable->save(new C_NoopContext); } - if (mdsmap->get_num_mds() == 1 && - mdsmap->get_num_failed() == 0) { // just me! + if (mdsmap->get_num_in_mds() == 1 && + mdsmap->get_num_failed_mds() == 0) { // just me! dout(2) << "i am alone, moving to state reconnect" << dendl; request_state(MDSMap::STATE_RECONNECT); } else { @@ -1531,7 +1531,7 @@ void MDS::stopping_start() { dout(2) << "stopping_start" << dendl; - if (mdsmap->get_num_mds() == 1 && !sessionmap.empty()) { + if (mdsmap->get_num_in_mds() == 1 && !sessionmap.empty()) { // we're the only mds up! dout(0) << "we are the last MDS, and have mounted clients: we cannot flush our journal. suicide!" << dendl; suicide(); diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index 00a46e85ee78e..e4fdd7a8b754e 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -255,9 +255,15 @@ public: } // counts - unsigned get_num_mds() { + unsigned get_num_in_mds() { return in.size(); } + unsigned get_num_up_mds() { + return up.size(); + } + int get_num_failed_mds() { + return failed.size(); + } unsigned get_num_mds(int state) { unsigned n = 0; for (map::const_iterator p = mds_info.begin(); @@ -266,7 +272,6 @@ public: if (p->second.state == state) ++n; return n; } - int get_num_failed() { return failed.size(); } // data pools void add_data_pg_pool(int64_t poolid) { diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 57043d0f9e834..5488180c852f2 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -710,7 +710,7 @@ bool MDSMonitor::prepare_command(MMonCommand *m) << ceph_mds_state_name(mdsmap.get_state(who)) << ")"; } else if ((mdsmap.get_root() == who || mdsmap.get_tableserver() == who) && - mdsmap.get_num_mds() > 1) { + mdsmap.get_num_in_mds() > 1) { r = -EBUSY; ss << "can't tell the root (" << mdsmap.get_root() << ") or tableserver (" << mdsmap.get_tableserver() << " to stop unless it is the last mds in the cluster"; @@ -903,7 +903,7 @@ void MDSMonitor::tick() if (!mon->is_leader()) return; // expand mds cluster (add new nodes to @in)? - while (pending_mdsmap.get_num_mds() < pending_mdsmap.get_max_mds() && + while (pending_mdsmap.get_num_in_mds() < pending_mdsmap.get_max_mds() && !pending_mdsmap.is_degraded()) { int mds = 0; string name; diff --git a/src/tools/gui.cc b/src/tools/gui.cc index 05fb32b338851..dcf62e7ae7947 100644 --- a/src/tools/gui.cc +++ b/src/tools/gui.cc @@ -528,8 +528,8 @@ void GuiMonitor::update_mds_cluster_view() view_mds_nodes(); ostringstream oss; - oss << ctx->mdsmap.get_num_mds() << " In, " - << ctx->mdsmap.get_num_failed() << " Failed, " + oss << ctx->mdsmap.get_num_in_mds() << " In, " + << ctx->mdsmap.get_num_failed_mds() << " Failed, " << ctx->mdsmap.get_num_mds(MDSMap::STATE_STOPPED) << " Stopped, " << ctx->mdsmap.get_max_mds() << " Max"; guiMonitorMDSClusterStatsLabel->set_label(oss.str()); @@ -1516,9 +1516,9 @@ void GuiMonitor::StatsWindowInfo::gen_mds_cluster_columns() ctx->mdsmap.get_max_mds())); insert_stats("Amount of Up MDSes", str(boost::format("%d") % up_mds.size())); insert_stats("Amount of In MDSes", str(boost::format("%u") % - ctx->mdsmap.get_num_mds())); + ctx->mdsmap.get_num_in_mds())); insert_stats("Amount of Failed MDSes", str(boost::format("%d") % - ctx->mdsmap.get_num_failed())); + ctx->mdsmap.get_num_failed_mds())); insert_stats("Amount of Stopped MDSes", str(boost::format("%d") % stopped_mds.size())); } -- 2.39.5