]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Add dump_blacklist to admin socket
authorDavid Zafman <david.zafman@inktank.com>
Wed, 29 May 2013 20:17:01 +0000 (13:17 -0700)
committerDavid Zafman <david.zafman@inktank.com>
Thu, 6 Jun 2013 07:23:18 +0000 (00:23 -0700)
Signed-off-by: David Zafman <david.zafman@inktank.com>
src/osd/OSD.cc
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 7035eca6c9b5176ec81e8db4eaa451fa1c1d7dca..da41bf6bc11222925323c8557251793c2c64920f 100644 (file)
@@ -1007,6 +1007,24 @@ bool OSD::asok_command(string command, string args, ostream& ss)
     op_wq.dump(&f);
     f.close_section();
     f.flush(ss);
+  } else if (command == "dump_blacklist") {
+    list<pair<entity_addr_t,utime_t> > bl;
+    OSDMapRef curmap = service.get_osdmap();
+
+    JSONFormatter f(true);
+    f.open_array_section("blacklist");
+    curmap->get_blacklist(&bl);
+    for (list<pair<entity_addr_t,utime_t> >::iterator it = bl.begin();
+       it != bl.end(); ++it) {
+      f.open_array_section("entry");
+      f.open_object_section("entity_addr_t");
+      it->first.dump(&f);
+      f.close_section(); //entity_addr_t
+      it->second.localtime(f.dump_stream("expire_time"));
+      f.close_section(); //entry
+    }
+    f.close_section(); //blacklist
+    f.flush(ss);
   } else {
     assert(0 == "broken asok registration");
   }
@@ -1157,6 +1175,10 @@ int OSD::init()
   r = admin_socket->register_command("dump_op_pq_state", asok_hook,
                                     "dump op priority queue state");
   assert(r == 0);
+  r = admin_socket->register_command("dump_blacklist", asok_hook,
+                                    "dump_blacklist");
+  assert(r == 0);
+
   test_ops_hook = new TestOpsSocketHook(&(this->service), this->store);
   r = admin_socket->register_command("setomapval", test_ops_hook,
                               "setomapval <pool-id> <obj-name> <key> <val>");
@@ -1354,6 +1376,7 @@ int OSD::shutdown()
   cct->get_admin_socket()->unregister_command("dump_ops_in_flight");
   cct->get_admin_socket()->unregister_command("dump_historic_ops");
   cct->get_admin_socket()->unregister_command("dump_op_pq_state");
+  cct->get_admin_socket()->unregister_command("dump_blacklist");
   delete asok_hook;
   asok_hook = NULL;
 
index 5cf62a05e3f1f3b5befda0c48c450007c2c1f182..cc7646b495bf41d1ea8eb1f6d63f4ea729550f07 100644 (file)
@@ -615,6 +615,14 @@ bool OSDMap::is_blacklisted(const entity_addr_t& a) const
   return blacklist.count(b);
 }
 
+void OSDMap::get_blacklist(list<pair<entity_addr_t,utime_t> > *bl) const
+{
+  for (hash_map<entity_addr_t,utime_t>::const_iterator it = blacklist.begin() ;
+                        it != blacklist.end(); ++it) {
+    bl->push_back(*it);
+  }
+}
+
 void OSDMap::set_max_osd(int m)
 {
   int o = max_osd;
index 42877f10f1b62060126fd5faffa05d99dc861b5e..aadbe3c58be12828c4c42dd7020e19dbc738d107 100644 (file)
@@ -240,6 +240,7 @@ private:
   const utime_t& get_modified() const { return modified; }
 
   bool is_blacklisted(const entity_addr_t& a) const;
+  void get_blacklist(list<pair<entity_addr_t,utime_t > > *bl) const;
 
   string get_cluster_snapshot() const {
     if (cluster_snapshot_epoch == epoch)