]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add a MgrClient
authorSage Weil <sage@redhat.com>
Sun, 26 Feb 2017 19:15:17 +0000 (14:15 -0500)
committerSage Weil <sage@redhat.com>
Wed, 29 Mar 2017 15:39:25 +0000 (11:39 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph_mon.cc
src/mon/Monitor.cc
src/mon/Monitor.h

index 0ee2b170bfb462d987098629fca0ac8ec672fbc8..6e8fd1d5749e54bb32d7958695c0d7055b68b11e 100644 (file)
@@ -421,7 +421,7 @@ int main(int argc, const char **argv)
     }
     assert(r == 0);
 
-    Monitor mon(g_ceph_context, g_conf->name.get_id(), &store, 0, &monmap);
+    Monitor mon(g_ceph_context, g_conf->name.get_id(), &store, 0, 0, &monmap);
     r = mon.mkfs(osdmapbl);
     if (r < 0) {
       cerr << argv[0] << ": error creating monfs: " << cpp_strerror(r) << std::endl;
@@ -703,6 +703,14 @@ int main(int argc, const char **argv)
     prefork.exit(1);
   }
 
+  Messenger *mgr_msgr = Messenger::create(g_ceph_context, public_msgr_type,
+                                         entity_name_t::MON(rank), "mon-mgrc",
+                                         getpid(), 0);
+  if (!mgr_msgr) {
+    derr << "unable to create mgr_msgr" << dendl;
+    prefork.exit(1);
+  }
+
   cout << "starting " << g_conf->name << " rank " << rank
        << " at " << ipaddr
        << " mon_data " << g_conf->mon_data
@@ -711,7 +719,7 @@ int main(int argc, const char **argv)
 
   // start monitor
   mon = new Monitor(g_ceph_context, g_conf->name.get_id(), store,
-                   msgr, &monmap);
+                   msgr, mgr_msgr, &monmap);
 
   if (force_sync) {
     derr << "flagging a forced sync ..." << dendl;
@@ -736,6 +744,7 @@ int main(int argc, const char **argv)
   }
 
   msgr->start();
+  mgr_msgr->start();
 
   mon->init();
 
@@ -749,6 +758,7 @@ int main(int argc, const char **argv)
     kill(getpid(), SIGTERM);
 
   msgr->wait();
+  mgr_msgr->wait();
 
   store->close();
 
@@ -760,6 +770,7 @@ int main(int argc, const char **argv)
   delete mon;
   delete store;
   delete msgr;
+  delete mgr_msgr;
   delete client_throttler;
   delete daemon_throttler;
 
index c79bfc5a4a7406cc1bc00c341c0f88faf140c97e..2da72ba2b62366baabc955dfed5e83d185952167 100644 (file)
@@ -148,7 +148,7 @@ long parse_pos_long(const char *s, ostream *pss)
 }
 
 Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s,
-                Messenger *m, MonMap *map) :
+                Messenger *m, Messenger *mgr_m, MonMap *map) :
   Dispatcher(cct_),
   name(nm),
   rank(-1), 
@@ -170,6 +170,8 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s,
                        cct->_conf->auth_service_required : cct->_conf->auth_supported ),
   leader_supported_mon_commands(NULL),
   leader_supported_mon_commands_size(0),
+  mgr_messenger(mgr_m),
+  mgr_client(cct_, mgr_m),
   store(s),
   
   state(STATE_PROBING),
@@ -843,6 +845,10 @@ int Monitor::init()
   // i'm ready!
   messenger->add_dispatcher_tail(this);
 
+  mgr_client.init();
+  mgr_messenger->add_dispatcher_tail(&mgr_client);
+  mgr_messenger->add_dispatcher_tail(this);  // for auth ms_* calls
+
   bootstrap();
 
   // encode command sets
@@ -926,6 +932,7 @@ void Monitor::shutdown()
   dout(1) << "shutdown" << dendl;
 
   lock.Lock();
+
   wait_for_paxos_write();
 
   state = STATE_SHUTDOWN;
@@ -953,6 +960,8 @@ void Monitor::shutdown()
 
   elector.shutdown();
 
+  mgr_client.shutdown();
+
   // clean up
   paxos->shutdown();
   for (vector<PaxosService*>::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p)
@@ -986,6 +995,7 @@ void Monitor::shutdown()
   lock.Unlock();
 
   messenger->shutdown();  // last thing!  ceph_mon.cc will delete mon.
+  mgr_messenger->shutdown();
 }
 
 void Monitor::wait_for_paxos_write()
@@ -2771,7 +2781,7 @@ void Monitor::handle_command(MonOpRequestRef op)
 
   // check return value. If no prefix parameter provided,
   // return value will be false, then return error info.
-  if(!cmd_getval(g_ceph_context, cmdmap, "prefix", prefix)) {
+  if (!cmd_getval(g_ceph_context, cmdmap, "prefix", prefix)) {
     reply_command(op, -EINVAL, "command prefix not found", 0);
     return;
   }
index 39eff4bd30405d0af1c64912eed898cd72b41c44..ea019652c08259cc10307f5ac350f07c3145b702 100644 (file)
@@ -23,6 +23,9 @@
 #ifndef CEPH_MONITOR_H
 #define CEPH_MONITOR_H
 
+#include <errno.h>
+#include <cmath>
+
 #include "include/types.h"
 #include "msg/Messenger.h"
 
@@ -40,8 +43,7 @@
 #include "messages/MMonCommand.h"
 #include "mon/MonitorDBStore.h"
 #include "include/memory.h"
-#include <errno.h>
-#include <cmath>
+#include "mgr/MgrClient.h"
 
 #include "mon/MonOpRequest.h"
 #include "common/WorkQueue.h"
@@ -154,6 +156,8 @@ public:
   const MonCommand *leader_supported_mon_commands;
   int leader_supported_mon_commands_size;
 
+  Messenger *mgr_messenger;
+  MgrClient mgr_client;
 private:
   void new_tick();
   friend class C_Mon_Tick;
@@ -899,7 +903,7 @@ public:
 
  public:
   Monitor(CephContext *cct_, string nm, MonitorDBStore *s,
-         Messenger *m, MonMap *map);
+         Messenger *m, Messenger *mgr_m, MonMap *map);
   ~Monitor() override;
 
   static int check_features(MonitorDBStore *store);