]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: define OSDMapService interface
authorKefu Chai <kchai@redhat.com>
Wed, 30 Jan 2019 08:35:55 +0000 (16:35 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 2 Feb 2019 05:20:00 +0000 (13:20 +0800)
* define OSDMapService interface to decouple the consumers of
  this interface from its implementation -- the `OSD` class
* implement its methods in `OSD`

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/osd.cc
src/crimson/osd/osd.h
src/crimson/osd/osdmap_service.h [new file with mode: 0644]

index 3df81765949dafc146f9044e41826f6e832cbcae..8dc8350bacb044b2e878e55396f5728cbdd86bf8 100644 (file)
@@ -296,6 +296,11 @@ seastar::future<> OSD::ms_handle_remote_reset(ceph::net::ConnectionRef conn)
   return seastar::now();
 }
 
+seastar::lw_shared_ptr<OSDMap> OSD::get_map() const
+{
+  return osdmap;
+}
+
 seastar::future<seastar::lw_shared_ptr<OSDMap>> OSD::get_map(epoch_t e)
 {
   // TODO: use LRU cache for managing osdmap, fallback to disk if we have to
index dad7eae5cff20d609d80be7ceaae36b9c6d49334..ea75b0e98e1a87d6b1dab326f7046868b26b674e 100644 (file)
@@ -12,6 +12,7 @@
 #include "crimson/mon/MonClient.h"
 #include "crimson/net/Dispatcher.h"
 #include "crimson/osd/chained_dispatchers.h"
+#include "crimson/osd/osdmap_service.h"
 #include "crimson/osd/state.h"
 
 #include "osd/OSDMap.h"
@@ -33,7 +34,8 @@ namespace ceph::os {
 
 template<typename T> using Ref = boost::intrusive_ptr<T>;
 
-class OSD : public ceph::net::Dispatcher {
+class OSD : public ceph::net::Dispatcher,
+           private OSDMapService {
   seastar::gate gate;
   seastar::timer<seastar::lowres_clock> beacon_timer;
   const int whoami;
@@ -74,7 +76,7 @@ class OSD : public ceph::net::Dispatcher {
 
 public:
   OSD(int id, uint32_t nonce);
-  ~OSD();
+  ~OSD() override;
 
   seastar::future<> mkfs(uuid_d fsid);
 
@@ -89,7 +91,10 @@ private:
   seastar::future<Ref<PG>> load_pg(spg_t pgid);
   seastar::future<> load_pgs();
 
-  seastar::future<seastar::lw_shared_ptr<OSDMap>> get_map(epoch_t e);
+  // OSDMapService methods
+  seastar::future<seastar::lw_shared_ptr<OSDMap>> get_map(epoch_t e) override;
+  seastar::lw_shared_ptr<OSDMap> get_map() const override;
+
   seastar::future<bufferlist> load_map_bl(epoch_t e);
   void store_map_bl(ceph::os::Transaction& t,
                     epoch_t e, bufferlist&& bl);
diff --git a/src/crimson/osd/osdmap_service.h b/src/crimson/osd/osdmap_service.h
new file mode 100644 (file)
index 0000000..8af4e74
--- /dev/null
@@ -0,0 +1,19 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include <seastar/core/shared_ptr.hh>
+
+#include "include/types.h"
+
+class OSDMap;
+
+class OSDMapService {
+public:
+  virtual ~OSDMapService() = default;
+  virtual seastar::future<seastar::lw_shared_ptr<OSDMap>>
+  get_map(epoch_t e) = 0;
+  /// get the latest map
+  virtual seastar::lw_shared_ptr<OSDMap> get_map() const = 0;
+};