summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Eduardo Luis <joao.luis@inktank.com>2013-03-17 18:41:42 +0000
committerJoao Eduardo Luis <joao.luis@inktank.com>2013-03-18 22:43:55 +0000
commitcecfe411bba37983eabee3da06ab930c8b025358 (patch)
tree1e19fea104b314decb97921e226689ba77393d83
parentb781400f1ffb41eb7b2fe5b84f867f8da305a5d6 (diff)
downloadceph-cecfe411bba37983eabee3da06ab930c8b025358.tar.gz
mon: Monitor: take advantage of the new HealthMonitor class.
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
-rw-r--r--src/mon/Monitor.cc17
-rw-r--r--src/mon/Monitor.h29
2 files changed, 46 insertions, 0 deletions
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index 769381ba499..9f35e0df615 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<PaxosService*>::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<PaxosService*>::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p)
(*p)->restart();
+ health_monitor->finish();
}
set<string> Monitor::get_sync_targets_names() {
@@ -1964,6 +1972,7 @@ void Monitor::win_election(epoch_t epoch, set<int>& active, uint64_t features)
paxos->leader_init();
for (vector<PaxosService*>::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<int> &q, int l, uint64_t features
paxos->peon_init();
for (vector<PaxosService*>::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<MTimeCheck *>(m));
break;
+ case MSG_MON_HEALTH:
+ health_monitor->dispatch(static_cast<MMonHealth *>(m));
+ break;
+
default:
ret = false;
}
diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h
index 9d2bd598823..55f27c7822d 100644
--- a/src/mon/Monitor.h
+++ b/src/mon/Monitor.h
@@ -51,6 +51,9 @@
#include <memory>
#include <tr1/memory>
#include <errno.h>
+#include <boost/intrusive_ptr.hpp>
+// 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<entity_inst_t,MonStatsEntry> 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<QuorumService> health_monitor;
// -- sessions --
MonSessionMap session_map;