#define dout_prefix *_dout << "mds.beacon." << name << ' '
-Beacon::Beacon(MonClient *monc_, std::string name_) :
- lock("Beacon"), monc(monc_), timer(g_ceph_context, lock), name(name_)
+Beacon::Beacon(CephContext *cct_, MonClient *monc_, std::string name_) :
+ Dispatcher(cct_), lock("Beacon"), monc(monc_), timer(g_ceph_context, lock), name(name_)
{
last_seq = 0;
sender = NULL;
}
+bool Beacon::ms_dispatch(Message *m)
+{
+ if (m->get_type() == MSG_MDS_BEACON) {
+ if (m->get_connection()->get_peer_type() == CEPH_ENTITY_TYPE_MON) {
+ handle_mds_beacon(static_cast<MMDSBeacon*>(m));
+ }
+ }
+
+ // Let message fall through to MDS so that we get the execution of
+ // his finished_queue and waiting_for_nolaggy stuff.
+ return false;
+}
+
+
/**
* Update lagginess state based on response from remote MDSMonitor
*
dout(10) << "handle_mds_beacon " << ceph_mds_state_name(m->get_state())
<< " seq " << m->get_seq() << " dne" << dendl;
}
-
- m->put();
}
#include "include/types.h"
#include "include/Context.h"
#include "common/Mutex.h"
+#include "msg/Dispatcher.h"
class MonClient;
class MMDSBeacon;
+class Message;
/**
* we keep copies of the data needed to generate beacon messages. The MDS is
* responsible for calling Beacon::notify_* when things change.
*/
-class Beacon
+class Beacon : public Dispatcher
{
+ //CephContext *cct;
mutable Mutex lock;
MonClient* monc;
SafeTimer timer;
void _send();
public:
- Beacon(MonClient *monc_, std::string name);
+ Beacon(CephContext *cct_, MonClient *monc_, std::string name);
~Beacon();
void init(MDSMap const *mdsmap, MDSMap::DaemonState want_state_, int standby_rank_, std::string const &standby_name_);
void shutdown();
+ bool ms_dispatch(Message *m);
+ void ms_handle_connect(Connection *c) {}
+ bool ms_handle_reset(Connection *c) {return false;}
+ void ms_handle_remote_reset(Connection *c) {}
+
void notify_mdsmap(MDSMap const *mdsmap);
void notify_want_state(MDSMap::DaemonState const newstate);
Dispatcher(m->cct),
mds_lock("MDS::mds_lock"),
timer(m->cct, mds_lock),
- beacon(mc, n),
+ beacon(m->cct, mc, n),
authorize_handler_cluster_registry(new AuthAuthorizeHandlerRegistry(m->cct,
m->cct->_conf->auth_supported.length() ?
m->cct->_conf->auth_supported :
objecter->init();
messenger->add_dispatcher_tail(objecter);
+ messenger->add_dispatcher_tail(&beacon);
messenger->add_dispatcher_tail(this);
// get monmap
break;
case MSG_MDS_BEACON:
ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MON);
- beacon.handle_mds_beacon(static_cast<MMDSBeacon*>(m));
+ // no-op, Beacon handles this on our behalf but we listen for the
+ // message to get the side effect of handling finished_queue and
+ // waiting_for_nolaggy at end of MDS dispatch.
+ m->put();
break;
-
+
// misc
case MSG_MON_COMMAND:
ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MON);
s->put();
}
}
+
+void MDS::set_want_state(MDSMap::DaemonState newstate)
+{
+ if (want_state != newstate) {
+ dout(10) << __func__ << " "
+ << ceph_mds_state_name(want_state) << " -> "
+ << ceph_mds_state_name(newstate) << dendl;
+ want_state = newstate;
+ beacon.notify_want_state(newstate);
+ }
+}
private:
Beacon beacon;
- void set_want_state(MDSMap::DaemonState newstate)
- {
- want_state = newstate;
- beacon.notify_want_state(newstate);
- }
+ void set_want_state(MDSMap::DaemonState newstate);
public:
utime_t get_laggy_until() {return beacon.get_laggy_until();}