]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mon/MgrMonitor.h
update sources to 12.2.2
[ceph.git] / ceph / src / mon / MgrMonitor.h
index ea1a0a91a4acaa6251f5f0ff4129698b28cea2eb..82315d3550de574d3d7ebb627ffd7cb6b6370a4f 100644 (file)
 #ifndef CEPH_MGRMONITOR_H
 #define CEPH_MGRMONITOR_H
 
+#include <map>
+#include <set>
+
 #include "include/Context.h"
 #include "MgrMap.h"
 #include "PaxosService.h"
+#include "MonCommand.h"
 
 class MgrMonitor: public PaxosService
 {
   MgrMap map;
   MgrMap pending_map;
+  bool ever_had_active_mgr = false;
+
+  std::map<std::string, bufferlist> pending_metadata;
+  std::set<std::string>             pending_metadata_rm;
 
   utime_t first_seen_inactive;
 
@@ -35,13 +43,28 @@ class MgrMonitor: public PaxosService
    */
   bool promote_standby();
   void drop_active();
-  void drop_standby(uint64_t gid);
+
+  /**
+   * Remove this gid from the list of standbys.  By default,
+   * also remove metadata (i.e. forget the daemon entirely).
+   *
+   * Set `drop_meta` to false if you would like to keep
+   * the daemon's metadata, for example if you're dropping
+   * it as a standby before reinstating it as the active daemon.
+   */
+  void drop_standby(uint64_t gid, bool drop_meta=true);
 
   Context *digest_event = nullptr;
   void cancel_timer();
 
   bool check_caps(MonOpRequestRef op, const uuid_d& fsid);
 
+  health_status_t should_warn_about_mgr_down();
+
+  // Command descriptions we've learned from the active mgr
+  std::vector<MonCommand> command_descs;
+  std::vector<MonCommand> pending_command_descs;
+
 public:
   MgrMonitor(Monitor *mn, Paxos *p, const string& service_name)
     : PaxosService(mn, p, service_name)
@@ -56,6 +79,7 @@ public:
   bool in_use() const { return map.epoch > 0; }
 
   void create_initial() override;
+  void get_store_prefixes(std::set<string>& s) override;
   void update_from_paxos(bool *need_bootstrap) override;
   void create_pending() override;
   void encode_pending(MonitorDBStore::TransactionRef t) override;
@@ -76,6 +100,8 @@ public:
   void send_digests();
 
   void on_active() override;
+  void on_restart() override;
+
   void get_health(list<pair<health_status_t,string> >& summary,
                  list<pair<health_status_t,string> > *detail,
                  CephContext *cct) const override;
@@ -83,7 +109,20 @@ public:
 
   void print_summary(Formatter *f, std::ostream *ss) const;
 
+  const std::vector<MonCommand> &get_command_descs() const;
+
+  int load_metadata(const string& name, std::map<string, string>& m,
+                   ostream *err);
+  int dump_metadata(const string& name, Formatter *f, ostream *err);
+  void count_metadata(const string& field, Formatter *f);
+  void count_metadata(const string& field, std::map<string,int> *out);
+
   friend class C_Updated;
+
+  // When did the mon last call into our tick() method?  Used for detecting
+  // when the mon was not updating us for some period (e.g. during slow
+  // election) to reset last_beacon timeouts
+  ceph::coarse_mono_clock::time_point last_tick;
 };
 
 #endif