From: Kefu Chai Date: Wed, 30 Jan 2019 08:35:55 +0000 (+0800) Subject: crimson/osd: define OSDMapService interface X-Git-Tag: v14.1.0~225^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a0307f5d1ffc03f19f3163b4c67112b814e9fa79;p=ceph.git crimson/osd: define OSDMapService interface * 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 --- diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 3df81765949d..8dc8350bacb0 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -296,6 +296,11 @@ seastar::future<> OSD::ms_handle_remote_reset(ceph::net::ConnectionRef conn) return seastar::now(); } +seastar::lw_shared_ptr OSD::get_map() const +{ + return osdmap; +} + seastar::future> OSD::get_map(epoch_t e) { // TODO: use LRU cache for managing osdmap, fallback to disk if we have to diff --git a/src/crimson/osd/osd.h b/src/crimson/osd/osd.h index dad7eae5cff2..ea75b0e98e1a 100644 --- a/src/crimson/osd/osd.h +++ b/src/crimson/osd/osd.h @@ -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 using Ref = boost::intrusive_ptr; -class OSD : public ceph::net::Dispatcher { +class OSD : public ceph::net::Dispatcher, + private OSDMapService { seastar::gate gate; seastar::timer 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> load_pg(spg_t pgid); seastar::future<> load_pgs(); - seastar::future> get_map(epoch_t e); + // OSDMapService methods + seastar::future> get_map(epoch_t e) override; + seastar::lw_shared_ptr get_map() const override; + seastar::future 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 index 000000000000..8af4e74f0e98 --- /dev/null +++ b/src/crimson/osd/osdmap_service.h @@ -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 + +#include "include/types.h" + +class OSDMap; + +class OSDMapService { +public: + virtual ~OSDMapService() = default; + virtual seastar::future> + get_map(epoch_t e) = 0; + /// get the latest map + virtual seastar::lw_shared_ptr get_map() const = 0; +};