Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / mon / MonmapMonitor.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) 2009 Sage Weil <sage@newdream.net>
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
15 /*
16  * The Monmap Monitor is used to track the monitors in the cluster.
17  */
18
19 #ifndef CEPH_MONMAPMONITOR_H
20 #define CEPH_MONMAPMONITOR_H
21
22 #include <map>
23 #include <set>
24
25 using namespace std;
26
27 #include "include/types.h"
28 #include "msg/Messenger.h"
29
30 #include "PaxosService.h"
31 #include "MonMap.h"
32 #include "MonitorDBStore.h"
33
34 class MMonGetMap;
35 class MMonMap;
36 class MMonCommand;
37 class MMonJoin;
38
39 class MonmapMonitor : public PaxosService {
40  public:
41   MonmapMonitor(Monitor *mn, Paxos *p, const string& service_name)
42     : PaxosService(mn, p, service_name)
43   {
44   }
45   MonMap pending_map; //the pending map awaiting passage
46
47   void create_initial() override;
48
49   void update_from_paxos(bool *need_bootstrap) override;
50
51   void create_pending() override;
52
53   void encode_pending(MonitorDBStore::TransactionRef t) override;
54   // we always encode the full map; we have no use for full versions
55   void encode_full(MonitorDBStore::TransactionRef t) override { }
56
57   void on_active() override;
58   void apply_mon_features(const mon_feature_t& features);
59
60   void dump_info(Formatter *f);
61
62   bool preprocess_query(MonOpRequestRef op) override;
63   bool prepare_update(MonOpRequestRef op) override;
64
65   bool preprocess_join(MonOpRequestRef op);
66   bool prepare_join(MonOpRequestRef op);
67
68   bool preprocess_command(MonOpRequestRef op);
69   bool prepare_command(MonOpRequestRef op);
70
71   void get_health(list<pair<health_status_t,string> >& summary,
72                   list<pair<health_status_t,string> > *detail,
73                   CephContext *cct) const override;
74
75   int get_monmap(bufferlist &bl);
76
77   /*
78    * Since monitors are pretty
79    * important, this implementation will just write 0.0.
80    */
81   bool should_propose(double& delay) override;
82
83   void check_sub(Subscription *sub);
84
85 private:
86   void check_subs();
87
88 private:
89   bufferlist monmap_bl;
90 };
91
92
93 #endif