Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / mon / DataHealthService.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2013 Inktank, Inc
7  *
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.
12  *
13  */
14 #ifndef CEPH_MON_DATA_HEALTH_SERVICE_H
15 #define CEPH_MON_DATA_HEALTH_SERVICE_H
16
17 #include <errno.h>
18
19 #include "include/types.h"
20 #include "mon/mon_types.h"
21 #include "mon/HealthService.h"
22 #include "common/config.h"
23 #include "global/signal_handler.h"
24
25 struct MMonHealth;
26 namespace ceph { class Formatter; }
27
28
29 class DataHealthService :
30   public HealthService
31 {
32   map<entity_inst_t,DataStats> stats;
33   int last_warned_percent;
34
35   void handle_tell(MonOpRequestRef op);
36   int update_store_stats(DataStats &ours);
37   int update_stats();
38   void share_stats();
39
40   void force_shutdown() {
41     generic_dout(0) << "** Shutdown via Data Health Service **" << dendl;
42     queue_async_signal(SIGINT);
43   }
44
45 protected:
46   void service_tick() override;
47   bool service_dispatch_op(MonOpRequestRef op) override;
48   void service_shutdown() override { }
49
50   void start_epoch() override;
51   void finish_epoch() override { }
52   void cleanup() override { }
53
54 public:
55   DataHealthService(Monitor *m) :
56     HealthService(m),
57     last_warned_percent(0)
58   {
59     set_update_period(g_conf->mon_health_data_update_interval);
60   }
61   ~DataHealthService() override { }
62
63   void init() override {
64     generic_dout(20) << "data_health " << __func__ << dendl;
65     start_tick();
66   }
67
68   void get_health(
69     list<pair<health_status_t,string> >& summary,
70     list<pair<health_status_t,string> > *detail) override;
71
72   int get_type() override {
73     return HealthService::SERVICE_HEALTH_DATA;
74   }
75
76   string get_name() const override {
77     return "data_health";
78   }
79 };
80
81 #endif /* CEPH_MON_DATA_HEALTH_SERVICE_H */