}
}
+void DaemonServer::got_mgr_map()
+{
+ Mutex::Locker l(lock);
+ set<std::string> have;
+ cluster_state.with_mgrmap([&](const MgrMap& mgrmap) {
+ if (mgrmap.active_name.size()) {
+ DaemonKey key("mgr", mgrmap.active_name);
+ have.insert(mgrmap.active_name);
+ if (!daemon_state.exists(key)) {
+ auto daemon = std::make_shared<DaemonState>(daemon_state.types);
+ daemon->key = key;
+ daemon_state.insert(daemon);
+ dout(10) << "added missing " << key << dendl;
+ }
+ }
+ for (auto& i : mgrmap.standbys) {
+ DaemonKey key("mgr", i.second.name);
+ have.insert(i.second.name);
+ if (!daemon_state.exists(key)) {
+ auto daemon = std::make_shared<DaemonState>(daemon_state.types);
+ daemon->key = key;
+ daemon_state.insert(daemon);
+ dout(10) << "added missing " << key << dendl;
+ }
+ }
+ });
+ daemon_state.cull("mgr", have);
+}
const char** DaemonServer::get_tracked_conf_keys() const
{
MgrStandby::MgrStandby(int argc, const char **argv) :
Dispatcher(g_ceph_context),
monc{g_ceph_context},
- client_messenger(Messenger::create_client_messenger(g_ceph_context, "mgr")),
+ client_messenger(Messenger::create(
+ g_ceph_context,
+ cct->_conf->get_val<std::string>("ms_type"),
+ entity_name_t::MGR(),
+ "mgr",
+ getpid(),
+ 0)),
objecter{g_ceph_context, client_messenger.get(), &monc, NULL, 0, 0},
client{client_messenger.get(), &monc, &objecter},
+ mgrc(g_ceph_context, client_messenger.get()),
log_client(g_ceph_context, client_messenger.get(), &monc.monmap, LogClient::NO_FLAGS),
clog(log_client.create_channel(CLOG_CHANNEL_CLUSTER)),
audit_clog(log_client.create_channel(CLOG_CHANNEL_AUDIT)),
client_messenger->wait();
return r;
}
+ mgrc.init();
+ client_messenger->add_dispatcher_tail(&mgrc);
+
r = monc.authenticate();
if (r < 0) {
derr << "Authentication failed, did you specify a mgr ID with a valid keyring?" << dendl;
}
client_t whoami = monc.get_global_id();
- client_messenger->set_myname(entity_name_t::CLIENT(whoami.v));
+ client_messenger->set_myname(entity_name_t::MGR(whoami.v));
monc.set_log_client(&log_client);
_update_log_config();
objecter.set_client_incarnation(0);
timer.shutdown();
// client uses monc and objecter
client.shutdown();
+ mgrc.shutdown();
// stop monc, so mon won't be able to instruct me to shutdown/activate after
// the active_mgr is stopped
monc.shutdown();
}
}
}
-
- mmap->put();
}
bool MgrStandby::ms_dispatch(Message *m)
if (m->get_type() == MSG_MGR_MAP) {
handle_mgr_map(static_cast<MMgrMap*>(m));
- return true;
- } else if (active_mgr) {
+ }
+ bool handled = false;
+ if (active_mgr) {
auto am = active_mgr;
lock.Unlock();
- bool handled = am->ms_dispatch(m);
+ handled = am->ms_dispatch(m);
lock.Lock();
- return handled;
- } else {
- return false;
}
+ if (m->get_type() == MSG_MGR_MAP && !handled) {
+ m->put();
+ handled = true;
+ }
+ return handled;
}