]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: MonmapMonitor: add function to obtain latest monmap
authorJoao Eduardo Luis <joao.luis@inktank.com>
Mon, 22 Apr 2013 15:20:37 +0000 (16:20 +0100)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Mon, 22 Apr 2013 16:08:27 +0000 (17:08 +0100)
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/MonmapMonitor.cc
src/mon/MonmapMonitor.h

index f1c6dfa3325266b3a0ed6e361079933bd82c34d4..badac7e09226147f003f7d177eec4111ccbed53d 100644 (file)
@@ -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;
+}
index 2861fbbd34f9b5fea1ceb9856a712a4bad99a1da..0690fb7409f354f739a58aafd58efeea3b66f5cf 100644 (file)
@@ -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.