]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mon/MDSMonitor.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / mon / MDSMonitor.h
index e83df726340653103b238de71120474f1b5f8ce6..56762a8afb7ba0b47cfb359f5b8474ce01d70031 100644 (file)
 
 #include <map>
 #include <set>
-using namespace std;
 
 #include "include/types.h"
 #include "PaxosFSMap.h"
 #include "PaxosService.h"
 #include "msg/Messenger.h"
 #include "messages/MMDSBeacon.h"
+#include "CommandHandler.h"
 
-class MMonCommand;
-class MMDSLoadTargets;
-class MMDSMap;
 class FileSystemCommandHandler;
 
-class MDSMonitor : public PaxosService, public PaxosFSMap {
+class MDSMonitor : public PaxosService, public PaxosFSMap, protected CommandHandler {
  public:
   MDSMonitor(Monitor *mn, Paxos *p, string service_name);
 
   // service methods
   void create_initial() override;
-  void get_store_prefixes(std::set<string>& s) override;
+  void get_store_prefixes(std::set<string>& s) const override;
   void update_from_paxos(bool *need_bootstrap) override;
   void init() override;
   void create_pending() override; 
   void encode_pending(MonitorDBStore::TransactionRef t) override;
   // we don't require full versions; don't encode any.
   void encode_full(MonitorDBStore::TransactionRef t) override { }
-  version_t get_trim_to() override;
+  version_t get_trim_to() const override;
 
   bool preprocess_query(MonOpRequestRef op) override;  // true if processed.
   bool prepare_update(MonOpRequestRef op) override;
   bool should_propose(double& delay) override;
 
+  bool should_print_status() const {
+    auto& fs = get_fsmap();
+    auto fs_count = fs.filesystem_count();
+    auto standby_count = fs.get_num_standby();
+    return fs_count > 0 || standby_count > 0;
+  }
+
   void on_active() override;
   void on_restart() override;
 
@@ -69,9 +73,11 @@ class MDSMonitor : public PaxosService, public PaxosFSMap {
   bool is_leader() const override { return mon->is_leader(); }
 
  protected:
+  using mds_info_t = MDSMap::mds_info_t;
+
   // my helpers
-  void print_map(const FSMap &m, int dbl=7);
-  void update_logger();
+  template<int dblV = 7>
+  void print_map(const FSMap &m);
 
   void _updated(MonOpRequestRef op);
 
@@ -82,30 +88,18 @@ class MDSMonitor : public PaxosService, public PaxosFSMap {
   bool preprocess_offload_targets(MonOpRequestRef op);
   bool prepare_offload_targets(MonOpRequestRef op);
 
-  void get_health(list<pair<health_status_t,string> >& summary,
-                 list<pair<health_status_t,string> > *detail,
-                 CephContext *cct) const override;
   int fail_mds(FSMap &fsmap, std::ostream &ss,
       const std::string &arg,
-      MDSMap::mds_info_t *failed_info);
+      mds_info_t *failed_info);
 
   bool preprocess_command(MonOpRequestRef op);
   bool prepare_command(MonOpRequestRef op);
 
-  void modify_legacy_filesystem(
-      FSMap &fsmap,
-      std::function<void(std::shared_ptr<Filesystem> )> fn);
-  int legacy_filesystem_command(
-      FSMap &fsmap,
-      MonOpRequestRef op,
-      std::string const &prefix,
-      map<string, cmd_vartype> &cmdmap,
-      std::stringstream &ss);
   int filesystem_command(
       FSMap &fsmap,
       MonOpRequestRef op,
       std::string const &prefix,
-      map<string, cmd_vartype> &cmdmap,
+      const cmdmap_t& cmdmap,
       std::stringstream &ss);
 
   // beacons
@@ -117,15 +111,12 @@ class MDSMonitor : public PaxosService, public PaxosFSMap {
   };
   map<mds_gid_t, beacon_info_t> last_beacon;
 
-  bool try_standby_replay(FSMap &fsmap, const MDSMap::mds_info_t& finfo,
-      const Filesystem &leader_fs, const MDSMap::mds_info_t& ainfo);
-
   std::list<std::shared_ptr<FileSystemCommandHandler> > handlers;
 
-  bool maybe_promote_standby(FSMap &fsmap, std::shared_ptr<Filesystem> &fs);
-  bool maybe_expand_cluster(FSMap &fsmap, fs_cluster_id_t fscid);
-  void maybe_replace_gid(FSMap &fsmap, mds_gid_t gid,
-      const MDSMap::mds_info_t& info, bool *mds_propose, bool *osd_propose);
+  bool maybe_promote_standby(FSMap& fsmap, Filesystem& fs);
+  bool maybe_resize_cluster(FSMap &fsmap, fs_cluster_id_t fscid);
+  bool drop_mds(FSMap &fsmap, mds_gid_t gid, const mds_info_t* rep_info, bool* osd_propose);
+  bool check_health(FSMap &fsmap, bool* osd_propose);
   void tick() override;     // check state, take actions
 
   int dump_metadata(const FSMap &fsmap, const std::string &who, Formatter *f,