]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PaxosService: forward-declare class Monitor
authorMax Kellermann <max.kellermann@ionos.com>
Fri, 15 Aug 2025 09:38:47 +0000 (11:38 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Tue, 16 Sep 2025 10:42:05 +0000 (12:42 +0200)
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/mon/PaxosService.cc
src/mon/PaxosService.h

index 2f7d8c38218cac873dd568d9c9b83ffc47e16b16..3f10a41b185b68c659109b5f1cf3eaae9154fcad 100644 (file)
@@ -19,6 +19,7 @@
 #include "include/ceph_assert.h"
 #include "messages/PaxosServiceMessage.h"
 #include "mon/MonOpRequest.h"
+#include "mon/Monitor.h"
 
 using std::ostream;
 using std::string;
@@ -35,6 +36,12 @@ static ostream& _prefix(std::ostream *_dout, Monitor &mon, Paxos &paxos, string
                << ").paxosservice(" << service_name << " " << fc << ".." << lc << ") ";
 }
 
+void PaxosService::C_ReplyOp::_finish(int r) {
+  if (r >= 0) {
+    mon.send_reply(op, reply.detach());
+  }
+}
+
 bool PaxosService::dispatch(MonOpRequestRef op)
 {
   ceph_assert(op->is_type_service() || op->is_type_command());
@@ -273,6 +280,39 @@ bool PaxosService::should_stash_full()
          (get_last_committed() - latest_full > (version_t)g_conf()->paxos_stash_full_interval));
 }
 
+void PaxosService::put_version_full(MonitorDBStore::TransactionRef t,
+                                   version_t ver, ceph::buffer::list& bl) {
+  std::string key = mon.store->combine_strings(full_prefix_name, ver);
+  t->put(get_service_name(), key, bl);
+}
+
+void PaxosService::put_version_latest_full(MonitorDBStore::TransactionRef t, version_t ver) {
+  std::string key = mon.store->combine_strings(full_prefix_name, full_latest_name);
+  t->put(get_service_name(), key, ver);
+}
+
+int PaxosService::get_version(version_t ver, ceph::buffer::list& bl) {
+  return mon.store->get(get_service_name(), ver, bl);
+}
+
+int PaxosService::get_version_full(version_t ver, ceph::buffer::list& bl) {
+  std::string key = mon.store->combine_strings(full_prefix_name, ver);
+  return mon.store->get(get_service_name(), key, bl);
+}
+
+version_t PaxosService::get_version_latest_full() {
+  std::string key = mon.store->combine_strings(full_prefix_name, full_latest_name);
+  return mon.store->get(get_service_name(), key);
+}
+
+int PaxosService::get_value(const std::string& key, ceph::buffer::list& bl) {
+  return mon.store->get(get_service_name(), key, bl);
+}
+
+version_t PaxosService::get_value(const std::string& key) {
+  return mon.store->get(get_service_name(), key);
+}
+
 void PaxosService::restart()
 {
   dout(10) << __func__ << dendl;
@@ -465,6 +505,15 @@ void PaxosService::trim(MonitorDBStore::TransactionRef t,
   }
 }
 
+void PaxosService::encode_health(const health_check_map_t& next,
+                                MonitorDBStore::TransactionRef t) {
+  using ceph::encode;
+  ceph::buffer::list bl;
+  encode(next, bl);
+  t->put("health", service_name, bl);
+  mon.log_health(next, health_checks, t);
+}
+
 void PaxosService::load_health()
 {
   bufferlist bl;
index cfd7f65e380fede30f668d31293ea4fa59fc7574..c343d366d4126560f3e7f31a0a6dbd184c474aee 100644 (file)
 #include <vector>
 
 #include "include/Context.h"
+#include "health_check.h"
 #include "Paxos.h"
-#include "Monitor.h"
 #include "MonitorDBStore.h"
 #include "MonOpRequest.h"
 
+class Monitor;
+
 /**
  * A Paxos Service is an abstraction that easily allows one to obtain an
  * association between a Monitor and a Paxos class, in order to implement any
@@ -133,11 +135,7 @@ public:
   public:
     C_ReplyOp(PaxosService *s, MonOpRequestRef o, MessageRef r) :
       C_MonOp(o), mon(s->mon), op(o), reply(r) { }
-    void _finish(int r) override {
-      if (r >= 0) {
-       mon.send_reply(op, reply.detach());
-      }
-    }
+    void _finish(int r) override;
   };
 
   /**
@@ -441,13 +439,7 @@ public:
   virtual void tick() {}
 
   void encode_health(const health_check_map_t& next,
-                    MonitorDBStore::TransactionRef t) {
-    using ceph::encode;
-    ceph::buffer::list bl;
-    encode(next, bl);
-    t->put("health", service_name, bl);
-    mon.log_health(next, health_checks, t);
-  }
+                    MonitorDBStore::TransactionRef t);
   void load_health();
 
   /**
@@ -786,10 +778,7 @@ public:
    * @param bl A ceph::buffer::list containing the version's value
    */
   void put_version_full(MonitorDBStore::TransactionRef t,
-                       version_t ver, ceph::buffer::list& bl) {
-    std::string key = mon.store->combine_strings(full_prefix_name, ver);
-    t->put(get_service_name(), key, bl);
-  }
+                       version_t ver, ceph::buffer::list& bl);
   /**
    * Put the version number in @p ver into the key pointing to the latest full
    * version of this service.
@@ -797,10 +786,7 @@ public:
    * @param t The transaction to which we will add this put operation
    * @param ver A version number
    */
-  void put_version_latest_full(MonitorDBStore::TransactionRef t, version_t ver) {
-    std::string key = mon.store->combine_strings(full_prefix_name, full_latest_name);
-    t->put(get_service_name(), key, ver);
-  }
+  void put_version_latest_full(MonitorDBStore::TransactionRef t, version_t ver);
   /**
    * Put the contents of @p bl into the key @p key.
    *
@@ -868,9 +854,7 @@ public:
    * @param bl The ceph::buffer::list to be populated
    * @return 0 on success; <0 otherwise
    */
-  virtual int get_version(version_t ver, ceph::buffer::list& bl) {
-    return mon.store->get(get_service_name(), ver, bl);
-  }
+  virtual int get_version(version_t ver, ceph::buffer::list& bl);
   /**
    * Get the contents of a given full version of this service.
    *
@@ -878,19 +862,13 @@ public:
    * @param bl The ceph::buffer::list to be populated
    * @returns 0 on success; <0 otherwise
    */
-  virtual int get_version_full(version_t ver, ceph::buffer::list& bl) {
-    std::string key = mon.store->combine_strings(full_prefix_name, ver);
-    return mon.store->get(get_service_name(), key, bl);
-  }
+  virtual int get_version_full(version_t ver, ceph::buffer::list& bl);
   /**
    * Get the latest full version number
    *
    * @returns A version number
    */
-  version_t get_version_latest_full() {
-    std::string key = mon.store->combine_strings(full_prefix_name, full_latest_name);
-    return mon.store->get(get_service_name(), key);
-  }
+  version_t get_version_latest_full();
 
   /**
    * Get a value from a given key.
@@ -898,17 +876,13 @@ public:
    * @param[in] key The key
    * @param[out] bl The ceph::buffer::list to be populated with the value
    */
-  int get_value(const std::string& key, ceph::buffer::list& bl) {
-    return mon.store->get(get_service_name(), key, bl);
-  }
+  int get_value(const std::string& key, ceph::buffer::list& bl);
   /**
    * Get an integer value from a given key.
    *
    * @param[in] key The key
    */
-  version_t get_value(const std::string& key) {
-    return mon.store->get(get_service_name(), key);
-  }
+  version_t get_value(const std::string& key);
 
   /**
    * @}