crimson/mon: add mon::Client::wait_for_config()

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>
This commit is contained in:
Kefu Chai 2021-01-21 20:40:06 +08:00
parent 264e710a37
commit 9a248da3fe
2 changed files with 14 additions and 1 deletions

View 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;

View 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) {