summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Eduardo Luis <joao.luis@inktank.com>2013-04-22 16:20:37 +0100
committerJoao Eduardo Luis <joao.luis@inktank.com>2013-04-22 17:08:27 +0100
commit4b9a2a39c9126c79358e3b7d276b6ecc36946f8f (patch)
treef4f831eb5fba15023b8f7ecfcb5b9c57121452bb
parent41b874cb707976091472f93bac0c33323b880573 (diff)
downloadceph-4b9a2a39c9126c79358e3b7d276b6ecc36946f8f.tar.gz
mon: MonmapMonitor: add function to obtain latest monmap
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
-rw-r--r--src/mon/MonmapMonitor.cc30
-rw-r--r--src/mon/MonmapMonitor.h3
2 files changed, 33 insertions, 0 deletions
diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc
index f1c6dfa3325..badac7e0922 100644
--- a/src/mon/MonmapMonitor.cc
+++ b/src/mon/MonmapMonitor.cc
@@ -502,3 +502,33 @@ void MonmapMonitor::get_health(list<pair<health_status_t, string> >& summary,
}
}
}
+
+int MonmapMonitor::get_monmap(bufferlist &bl)
+{
+ version_t latest_ver = get_last_committed();
+ dout(10) << __func__ << " ver " << latest_ver << dendl;
+
+ if (!exists_version(latest_ver))
+ return -ENOENT;
+
+ int err = get_version(latest_ver, bl);
+ if (err < 0) {
+ dout(1) << __func__ << " error obtaining monmap: "
+ << cpp_strerror(err) << dendl;
+ return err;
+ }
+ return 0;
+}
+
+int MonmapMonitor::get_monmap(MonMap &m)
+{
+ dout(10) << __func__ << dendl;
+ bufferlist monmap_bl;
+
+ int err = get_monmap(monmap_bl);
+ if (err < 0) {
+ return err;
+ }
+ m.decode(monmap_bl);
+ return 0;
+}
diff --git a/src/mon/MonmapMonitor.h b/src/mon/MonmapMonitor.h
index 2861fbbd34f..0690fb7409f 100644
--- a/src/mon/MonmapMonitor.h
+++ b/src/mon/MonmapMonitor.h
@@ -70,6 +70,9 @@ class MonmapMonitor : public PaxosService {
void get_health(list<pair<health_status_t,string> >& summary,
list<pair<health_status_t,string> > *detail) const;
+ int get_monmap(bufferlist &bl);
+ int get_monmap(MonMap &m);
+
/*
* Since monitors are pretty
* important, this implementation will just write 0.0.