summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2009-09-01 00:27:13 +0200
committerSage Weil <sage@newdream.net>2009-09-01 00:27:13 +0200
commit0009d675c66c29c0a708f56cf09e57b6c5d2bc8e (patch)
tree26126888b8eece444f972870d070e19a0ee9881a
parentmonc: resubscribe on monitor connection reset (diff)
downloadceph-0009d675c66c29c0a708f56cf09e57b6c5d2bc8e.tar.xz
ceph-0009d675c66c29c0a708f56cf09e57b6c5d2bc8e.zip
mon: do one-time subscriptions, too
-rw-r--r--src/client/Client.cc5
-rw-r--r--src/messages/MMonSubscribe.h32
-rw-r--r--src/mon/MDSMonitor.cc3
-rw-r--r--src/mon/MonClient.h23
-rw-r--r--src/mon/Monitor.cc6
-rw-r--r--src/mon/OSDMonitor.cc3
-rw-r--r--src/mon/SubscriptionMap.h11
-rwxr-xr-xsrc/vstart.sh4
8 files changed, 70 insertions, 17 deletions
diff --git a/src/client/Client.cc b/src/client/Client.cc
index bdf15642be0..e792ef6ba15 100644
--- a/src/client/Client.cc
+++ b/src/client/Client.cc
@@ -1202,7 +1202,7 @@ void Client::handle_mds_map(MMDSMap* m)
delete oldmap;
delete m;
- monclient->update_sub("mdsmap", mdsmap->get_epoch());
+ monclient->sub_got("mdsmap", mdsmap->get_epoch());
}
void Client::send_reconnect(int mds)
@@ -2554,7 +2554,8 @@ int Client::mount()
<< " and mdsmap " << mdsmap->get_epoch()
<< dendl;
- monclient->update_sub("mdsmap", mdsmap->get_epoch());
+ monclient->sub_want("mdsmap", mdsmap->get_epoch());
+ monclient->renew_subs();
// hack: get+pin root inode.
diff --git a/src/messages/MMonSubscribe.h b/src/messages/MMonSubscribe.h
index be9426b7251..05fca342ee7 100644
--- a/src/messages/MMonSubscribe.h
+++ b/src/messages/MMonSubscribe.h
@@ -18,10 +18,34 @@
#include "msg/Message.h"
struct MMonSubscribe : public Message {
- map<nstring, version_t> what;
+ struct sub_rec {
+ version_t have;
+ bool onetime; // just one version, or keep sending them?
+
+ void encode(bufferlist& bl) const {
+ ::encode(have, bl);
+ ::encode(onetime, bl);
+ }
+ void decode(bufferlist::iterator& bl) {
+ ::decode(have, bl);
+ ::decode(onetime, bl);
+ }
+ };
+ WRITE_CLASS_ENCODER(sub_rec)
+
+ map<nstring, sub_rec> what;
MMonSubscribe() : Message(CEPH_MSG_MON_SUBSCRIBE) {}
+ void sub_onetime(const char *w, version_t have) {
+ what[w].onetime = true;
+ what[w].have = have;
+ }
+ void sub_persistent(const char *w, version_t have) {
+ what[w].onetime = false;
+ what[w].have = have;
+ }
+
const char *get_type_name() { return "mon_subscribe"; }
void print(ostream& o) {
o << "mon_subscribe(" << what << ")";
@@ -35,5 +59,11 @@ struct MMonSubscribe : public Message {
::encode(what, payload);
}
};
+WRITE_CLASS_ENCODER(MMonSubscribe::sub_rec)
+
+static inline ostream& operator<<(ostream& out, const MMonSubscribe::sub_rec& r)
+{
+ return out << r.have << (r.onetime ? "(onetime)":"(persistent)");
+}
#endif
diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc
index d9b6a3cff89..0dc0b5f8a97 100644
--- a/src/mon/MDSMonitor.cc
+++ b/src/mon/MDSMonitor.cc
@@ -563,7 +563,8 @@ void MDSMonitor::check_subs()
send_full(p->first);
p->second.last = mdsmap.get_epoch();
}
- }
+ }
+ subs.trim_onetime();
}
diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h
index a7a925f8dc5..f2eb81e8531 100644
--- a/src/mon/MonClient.h
+++ b/src/mon/MonClient.h
@@ -23,6 +23,7 @@
#include "common/Timer.h"
+#include "messages/MMonSubscribe.h"
class MonMap;
class MMonMap;
@@ -67,16 +68,26 @@ private:
// mon subscriptions
private:
- map<nstring,version_t> sub_have; // my subs, and current versions
+ map<nstring,MMonSubscribe::sub_rec> sub_have; // my subs, and current versions
utime_t sub_renew_sent, sub_renew_after;
public:
void renew_subs();
- void update_sub(nstring what, version_t have) {
- bool had = sub_have.count(what);
- sub_have[what] = have;
- if (!had)
- renew_subs();
+ void sub_want(nstring what, version_t have) {
+ sub_have[what].have = have;
+ sub_have[what].onetime = false;
+ }
+ void sub_want_onetime(nstring what, version_t have) {
+ sub_have[what].have = have;
+ sub_have[what].onetime = true;
+ }
+ void sub_got(nstring what, version_t have) {
+ if (sub_have.count(what)) {
+ if (sub_have[what].onetime)
+ sub_have.erase(what);
+ else
+ sub_have[what].have = have;
+ }
}
void handle_subscribe_ack(MMonSubscribeAck* m);
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index 360fcc55328..20733acba8d 100644
--- a/src/mon/Monitor.cc
+++ b/src/mon/Monitor.cc
@@ -499,13 +499,13 @@ void Monitor::handle_subscribe(MMonSubscribe *m)
utime_t until = g_clock.now();
until += g_conf.mon_subscribe_interval;
- for (map<nstring,version_t>::iterator p = m->what.begin();
+ for (map<nstring,MMonSubscribe::sub_rec>::iterator p = m->what.begin();
p != m->what.end();
p++) {
if (p->first == "osdmap")
- osdmon()->subscribe(m->get_source_inst(), p->second, until);
+ osdmon()->subscribe(m->get_source_inst(), p->second.have, p->second.onetime ? utime_t() : until);
else if (p->first == "mdsmap")
- mdsmon()->subscribe(m->get_source_inst(), p->second, until);
+ mdsmon()->subscribe(m->get_source_inst(), p->second.have, p->second.onetime ? utime_t() : until);
else
dout(10) << " ignoring sub for '" << p->first << "'" << dendl;
}
diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc
index da958b5e4a6..e728da894b3 100644
--- a/src/mon/OSDMonitor.cc
+++ b/src/mon/OSDMonitor.cc
@@ -856,7 +856,8 @@ void OSDMonitor::check_subs()
send_latest(p->first, p->second.last);
p->second.last = osdmap.get_epoch();
}
- }
+ }
+ subs.trim_onetime();
}
diff --git a/src/mon/SubscriptionMap.h b/src/mon/SubscriptionMap.h
index fcf32240fe9..1f4eec6ec58 100644
--- a/src/mon/SubscriptionMap.h
+++ b/src/mon/SubscriptionMap.h
@@ -33,7 +33,16 @@ struct SubscriptionMap {
void trim(utime_t now) {
map<entity_inst_t, sub_info>::iterator p = subs.begin();
while (p != subs.end())
- if (p->second.until < now)
+ if (p->second.until != utime_t() &&
+ p->second.until < now)
+ subs.erase(p++);
+ else
+ p++;
+ }
+ void trim_onetime() {
+ map<entity_inst_t, sub_info>::iterator p = subs.begin();
+ while (p != subs.end())
+ if (p->second.until == utime_t())
subs.erase(p++);
else
p++;
diff --git a/src/vstart.sh b/src/vstart.sh
index f382c3d295e..40c333e9a57 100755
--- a/src/vstart.sh
+++ b/src/vstart.sh
@@ -128,7 +128,7 @@ else
lockdep = 1
debug mon = 20
debug paxos = 20
- debug ms = 1'
+ debug ms = 20'
COSDDEBUG='
lockdep = 1
debug ms = 1
@@ -137,7 +137,7 @@ else
debug filestore = 10'
CMDSDEBUG='
lockdep = 1
- debug ms = 1
+ debug ms = 20
debug mds = 20
mds log max segments = 2'
fi