From: Joao Eduardo Luis Date: Sun, 17 Mar 2013 18:41:42 +0000 (+0000) Subject: mon: Monitor: take advantage of the new HealthMonitor class. X-Git-Tag: v0.60~42^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F115%2Fhead;p=ceph.git mon: Monitor: take advantage of the new HealthMonitor class. Signed-off-by: Joao Eduardo Luis --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 769381ba499a..9f35e0df615b 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -49,6 +49,7 @@ #include "messages/MAuthReply.h" #include "messages/MTimeCheck.h" +#include "messages/MMonHealth.h" #include "common/strtol.h" #include "common/ceph_argparse.h" @@ -68,6 +69,8 @@ #include "PGMonitor.h" #include "LogMonitor.h" #include "AuthMonitor.h" +#include "mon/QuorumService.h" +#include "mon/HealthMonitor.h" #include "auth/AuthMethodList.h" #include "auth/KeyRing.h" @@ -163,6 +166,8 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s, paxos_service[PAXOS_LOG] = new LogMonitor(this, paxos, "logm"); paxos_service[PAXOS_AUTH] = new AuthMonitor(this, paxos, "auth"); + health_monitor = QuorumServiceRef(new HealthMonitor(this)); + mon_caps = new MonCaps(); mon_caps->set_allow_all(true); mon_caps->text = "allow *"; @@ -418,6 +423,7 @@ int Monitor::preinit() } init_paxos(); + health_monitor->init(); // we need to bootstrap authentication keys so we can form an // initial quorum. @@ -565,6 +571,7 @@ void Monitor::shutdown() // clean up for (vector::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p) (*p)->shutdown(); + health_monitor->shutdown(); finish_contexts(g_ceph_context, waitfor_quorum, -ECANCELED); finish_contexts(g_ceph_context, maybe_wait_for_quorum, -ECANCELED); @@ -683,6 +690,7 @@ void Monitor::reset() for (vector::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p) (*p)->restart(); + health_monitor->finish(); } set Monitor::get_sync_targets_names() { @@ -1964,6 +1972,7 @@ void Monitor::win_election(epoch_t epoch, set& active, uint64_t features) paxos->leader_init(); for (vector::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p) (*p)->election_finished(); + health_monitor->start(epoch); finish_election(); if (monmap->size() > 1) @@ -1997,6 +2006,7 @@ void Monitor::lose_election(epoch_t epoch, set &q, int l, uint64_t features paxos->peon_init(); for (vector::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p) (*p)->election_finished(); + health_monitor->start(epoch); finish_election(); } @@ -2283,6 +2293,9 @@ void Monitor::get_health(string& status, bufferlist *detailbl, Formatter *f) if (f) f->close_section(); + if (f) + health_monitor->get_health(f, (detailbl ? &detail : NULL)); + stringstream fss; fss << overall; status = fss.str() + ss.str(); @@ -3174,6 +3187,10 @@ bool Monitor::_ms_dispatch(Message *m) handle_timecheck(static_cast(m)); break; + case MSG_MON_HEALTH: + health_monitor->dispatch(static_cast(m)); + break; + default: ret = false; } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 9d2bd5988238..55f27c7822df 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -51,6 +51,9 @@ #include #include #include +#include +// Because intusive_ptr clobbers our assert... +#include "include/assert.h" #define CEPH_MON_PROTOCOL 10 /* cluster internal */ @@ -83,6 +86,7 @@ enum { l_cluster_last, }; +class QuorumService; class PaxosService; class PerfCounters; @@ -97,6 +101,7 @@ class MAuthRotating; class MRoute; class MForward; class MTimeCheck; +class MMonHealth; #define COMPAT_SET_LOC "feature_set" @@ -1135,7 +1140,30 @@ private: /** * @} */ + /** + * @defgroup Monitor_h_stats Keep track of monitor statistics + * @{ + */ + struct MonStatsEntry { + // data dir + uint64_t kb_total; + uint64_t kb_used; + uint64_t kb_avail; + unsigned int latest_avail_ratio; + utime_t last_update; + }; + + struct MonStats { + MonStatsEntry ours; + map others; + }; + + MonStats stats; + void stats_update(); + /** + * @} + */ Context *probe_timeout_event; // for probing @@ -1215,6 +1243,7 @@ public: friend class PGMonitor; friend class LogMonitor; + boost::intrusive_ptr health_monitor; // -- sessions -- MonSessionMap session_map;