]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mon/OldHealthMonitor.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2013 Inktank, Inc
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
19 // #include <boost/intrusive_ptr.hpp>
20 // Because intusive_ptr clobbers our assert...
21 #include "include/assert.h"
23 #include "mon/Monitor.h"
24 #include "mon/HealthService.h"
25 #include "mon/OldHealthMonitor.h"
26 #include "mon/DataHealthService.h"
28 #include "messages/MMonHealth.h"
29 #include "common/Formatter.h"
30 // #include "common/config.h"
32 #define dout_subsys ceph_subsys_mon
34 #define dout_prefix _prefix(_dout, mon, this)
35 static ostream
& _prefix(std::ostream
*_dout
, const Monitor
*mon
,
36 const OldHealthMonitor
*hmon
) {
37 return *_dout
<< "mon." << mon
->name
<< "@" << mon
->rank
38 << "(" << mon
->get_state_name() << ")." << hmon
->get_name()
39 << "(" << hmon
->get_epoch() << ") ";
42 void OldHealthMonitor::init()
44 dout(10) << __func__
<< dendl
;
45 assert(services
.empty());
46 services
[HealthService::SERVICE_HEALTH_DATA
] = new DataHealthService(mon
);
48 for (map
<int,HealthService
*>::iterator it
= services
.begin();
55 bool OldHealthMonitor::service_dispatch(MonOpRequestRef op
)
57 assert(op
->get_req()->get_type() == MSG_MON_HEALTH
);
58 MMonHealth
*hm
= static_cast<MMonHealth
*>(op
->get_req());
59 int service_type
= hm
->get_service_type();
60 if (services
.count(service_type
) == 0) {
61 dout(1) << __func__
<< " service type " << service_type
62 << " not registered -- drop message!" << dendl
;
65 return services
[service_type
]->service_dispatch(op
);
68 void OldHealthMonitor::start_epoch() {
69 epoch_t epoch
= get_epoch();
70 for (map
<int,HealthService
*>::iterator it
= services
.begin();
71 it
!= services
.end(); ++it
) {
72 it
->second
->start(epoch
);
76 void OldHealthMonitor::finish_epoch() {
77 generic_dout(20) << "OldHealthMonitor::finish_epoch()" << dendl
;
78 for (map
<int,HealthService
*>::iterator it
= services
.begin();
79 it
!= services
.end(); ++it
) {
80 assert(it
->second
!= NULL
);
85 void OldHealthMonitor::service_shutdown()
87 dout(0) << "OldHealthMonitor::service_shutdown "
88 << services
.size() << " services" << dendl
;
89 for (map
<int,HealthService
*>::iterator it
= services
.begin();
92 it
->second
->shutdown();
98 void OldHealthMonitor::get_health(
99 list
<pair
<health_status_t
,string
> >& summary
,
100 list
<pair
<health_status_t
,string
> > *detail
)
102 for (map
<int,HealthService
*>::iterator it
= services
.begin();
103 it
!= services
.end();
105 it
->second
->get_health(summary
, detail
);