]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/mon: add mon::Client::wait_for_config()
authorKefu Chai <kchai@redhat.com>
Thu, 21 Jan 2021 12:40:06 +0000 (20:40 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 22 Jan 2021 05:07:48 +0000 (13:07 +0800)
just for waiting for monmap and config from mon. crimson-osd needs this
for populating settings related to booting and transport layer before it
starts.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/mon/MonClient.cc
src/crimson/mon/MonClient.h

index defa03f3422c9b102d3920825c72c0df0d0f2487..4d66fd9792da55b2b22cf3cfd81d38c093d54af5 100644 (file)
@@ -894,7 +894,11 @@ seastar::future<> Client::handle_log_ack(Ref<MLogAck> m)
 
 seastar::future<> Client::handle_config(Ref<MConfig> m)
 {
-  return crimson::common::local_conf().set_mon_vals(m->config);
+  return crimson::common::local_conf().set_mon_vals(m->config).then([this] {
+    if (config_updated) {
+      config_updated->set_value();
+    }
+  });
 }
 
 std::vector<unsigned> Client::get_random_mons(unsigned n) const
@@ -1110,6 +1114,13 @@ seastar::future<> Client::renew_subs()
   });
 }
 
+seastar::future<> Client::wait_for_config()
+{
+  assert(!config_updated);
+  config_updated = seastar::promise<>();
+  return config_updated->get_future();
+}
+
 void Client::print(std::ostream& out) const
 {
   out << "mon." << entity_name;
index e7d2df86393036e2bbfeed5eca32c3a9c6de6c76..7e13846039b0ce3aa94beb833a969c5e2f70aac3 100644 (file)
@@ -90,6 +90,7 @@ public:
   void sub_unwant(const std::string& what);
   bool sub_want_increment(const std::string& what, version_t start, unsigned flags);
   seastar::future<> renew_subs();
+  seastar::future<> wait_for_config();
 
   void print(std::ostream&) const;
 private:
@@ -173,6 +174,7 @@ private:
     seastar::promise<> pr;
   };
   std::deque<pending_msg_t> pending_messages;
+  std::optional<seastar::promise<>> config_updated;
 };
 
 inline std::ostream& operator<<(std::ostream& out, const Client& client) {