#undef dout_prefix
#define dout_prefix *_dout << "mgr " << __func__ << " "
-ClusterState::ClusterState(MonClient *monc_, Objecter *objecter_)
- : monc(monc_), objecter(objecter_), lock("ClusterState"), pgservice(pg_map)
+ClusterState::ClusterState(
+ MonClient *monc_,
+ Objecter *objecter_,
+ const MgrMap& mgrmap)
+ : monc(monc_),
+ objecter(objecter_),
+ lock("ClusterState"),
+ mgr_map(mgrmap),
+ pgservice(pg_map)
{}
void ClusterState::set_objecter(Objecter *objecter_)
fsmap = new_fsmap;
}
+void ClusterState::set_mgr_map(MgrMap const &new_mgrmap)
+{
+ Mutex::Locker l(lock);
+ mgr_map = new_mgrmap;
+}
+
void ClusterState::load_digest(MMgrDigest *m)
{
health_json = std::move(m->health_json);
#define CLUSTER_STATE_H_
#include "mds/FSMap.h"
+#include "mon/MgrMap.h"
#include "common/Mutex.h"
#include "osdc/Objecter.h"
FSMap fsmap;
mutable Mutex lock;
+ MgrMap mgr_map;
+
set<int64_t> existing_pools; ///< pools that exist, as of PGMap epoch
PGMap pg_map;
PGMap::Incremental pending_inc;
const bufferlist &get_health() const {return health_json;}
const bufferlist &get_mon_status() const {return mon_status_json;}
- ClusterState(MonClient *monc_, Objecter *objecter_);
+ ClusterState(MonClient *monc_, Objecter *objecter_, const MgrMap& mgrmap);
void set_objecter(Objecter *objecter_);
void set_fsmap(FSMap const &new_fsmap);
+ void set_mgr_map(MgrMap const &new_mgrmap);
void notify_osdmap(const OSDMap &osd_map);
std::forward<Callback>(cb)(fsmap, std::forward<Args>(args)...);
}
+ template<typename Callback, typename...Args>
+ void with_mgrmap(Callback&& cb, Args&&...args) const
+ {
+ Mutex::Locker l(lock);
+ std::forward<Callback>(cb)(mgr_map, std::forward<Args>(args)...);
+ }
+
template<typename Callback, typename...Args>
auto with_pgmap(Callback&& cb, Args&&...args) const ->
decltype(cb(pg_map, std::forward<Args>(args)...))
#define dout_prefix *_dout << "mgr " << __func__ << " "
-Mgr::Mgr(MonClient *monc_, Messenger *clientm_, Objecter *objecter_,
+Mgr::Mgr(MonClient *monc_, const MgrMap& mgrmap,
+ Messenger *clientm_, Objecter *objecter_,
Client* client_, LogChannelRef clog_, LogChannelRef audit_clog_) :
monc(monc_),
objecter(objecter_),
finisher(g_ceph_context, "Mgr", "mgr-fin"),
py_modules(daemon_state, cluster_state, *monc, clog_, *objecter, *client,
finisher),
- cluster_state(monc, nullptr),
+ cluster_state(monc, nullptr, mgrmap),
server(monc, finisher, daemon_state, cluster_state, py_modules,
clog_, audit_clog_),
initialized(false),
daemon_state.cull(CEPH_ENTITY_TYPE_MDS, names_exist);
}
+void Mgr::got_mgr_map(const MgrMap& m)
+{
+ Mutex::Locker l(lock);
+ dout(10) << m << dendl;
+ cluster_state.set_mgr_map(m);
+}
void Mgr::handle_mgr_digest(MMgrDigest* m)
{
bool initializing;
public:
- Mgr(MonClient *monc_, Messenger *clientm_, Objecter *objecter_,
+ Mgr(MonClient *monc_, const MgrMap& mgrmap,
+ Messenger *clientm_, Objecter *objecter_,
Client *client_, LogChannelRef clog_, LogChannelRef audit_clog_);
~Mgr();
void handle_osd_map();
void handle_log(MLog *m);
+ void got_mgr_map(const MgrMap& m);
+
bool ms_dispatch(Message *m);
void tick();
if (active_in_map) {
if (!active_mgr) {
dout(1) << "Activating!" << dendl;
- active_mgr.reset(new Mgr(&monc, client_messenger.get(), &objecter,
+ active_mgr.reset(new Mgr(&monc, map, client_messenger.get(), &objecter,
&client, clog, audit_clog));
active_mgr->background_init();
dout(1) << "I am now active" << dendl;
} else {
dout(10) << "I was already active" << dendl;
+ active_mgr->got_mgr_map(map);
}
} else {
if (active_mgr != nullptr) {