]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rados: Output client address in rados listwatchers request
authorDavid Zafman <david.zafman@inktank.com>
Thu, 30 May 2013 20:21:09 +0000 (13:21 -0700)
committerDavid Zafman <david.zafman@inktank.com>
Thu, 6 Jun 2013 07:23:19 +0000 (00:23 -0700)
Add client entity_addr_t string to list of watchers rados interface

Signed-off-by: David Zafman <david.zafman@inktank.com>
src/include/rados/rados_types.h
src/osd/ReplicatedPG.cc
src/osd/osd_types.h
src/osdc/Objecter.h
src/rados.cc

index 1907f74fb710724c22ff0dc421aa5a509c33492c..fa60bd266c7758311e48fe41c46d6875334f49aa 100644 (file)
@@ -8,6 +8,7 @@
  * One item from list_watchers
  */
 struct obj_watch_t {
+  char addr[256];
   int64_t watcher_id;
   uint64_t cookie;
   uint32_t timeout_seconds;
index 18ccc1394a183aab3ccdee3f8f949d649e2fecda..81e99e6e51c40ad20bb33a63621443df60ec08fb 100644 (file)
@@ -2322,7 +2322,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
           assert(oi_iter->first.second.is_client());
 
           watch_item_t wi(oi_iter->first.second, oi_iter->second.cookie,
-                 oi_iter->second.timeout_seconds);
+                oi_iter->second.timeout_seconds, oi_iter->second.addr);
           resp.entries.push_back(wi);
         }
 
index cb752112b31cfda84a2ff859b5ccff6c0d78d70f..ab9f034475bc682f29668f64a1f986242243d44a 100644 (file)
@@ -2083,23 +2083,30 @@ struct watch_item_t {
   entity_name_t name;
   uint64_t cookie;
   uint32_t timeout_seconds;
+  entity_addr_t addr;
 
   watch_item_t() : cookie(0), timeout_seconds(0) { }
-  watch_item_t(entity_name_t name, uint64_t cookie, uint32_t timeout)
-    : name(name), cookie(cookie), timeout_seconds(timeout) { }
+  watch_item_t(entity_name_t name, uint64_t cookie, uint32_t timeout,
+     entity_addr_t addr)
+    : name(name), cookie(cookie), timeout_seconds(timeout),
+    addr(addr) { }
 
   void encode(bufferlist &bl) const {
-    ENCODE_START(1, 1, bl);
+    ENCODE_START(2, 1, bl);
     ::encode(name, bl);
     ::encode(cookie, bl);
     ::encode(timeout_seconds, bl);
+    ::encode(addr, bl);
     ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    DECODE_START(1, bl);
+    DECODE_START(2, bl);
     ::decode(name, bl);
     ::decode(cookie, bl);
     ::decode(timeout_seconds, bl);
+    if (struct_v >= 2) {
+      ::decode(addr, bl);
+    }
     DECODE_FINISH(bl);
   }
 };
@@ -2129,15 +2136,29 @@ struct obj_list_watch_response_t {
       f->dump_stream("watcher") << p->name;
       f->dump_int("cookie", p->cookie);
       f->dump_int("timeout", p->timeout_seconds);
+      f->open_object_section("addr");
+      p->addr.dump(f);
+      f->close_section();
       f->close_section();
     }
     f->close_section();
   }
   static void generate_test_instances(list<obj_list_watch_response_t*>& o) {
+    entity_addr_t ea;
     o.push_back(new obj_list_watch_response_t);
     o.push_back(new obj_list_watch_response_t);
-    o.back()->entries.push_back(watch_item_t(entity_name_t(entity_name_t::TYPE_CLIENT, 1), 10, 30));
-    o.back()->entries.push_back(watch_item_t(entity_name_t(entity_name_t::TYPE_CLIENT, 2), 20, 60));
+    ea.set_nonce(1000);
+    ea.set_family(AF_INET);
+    ea.set_in4_quad(0, 127);
+    ea.set_in4_quad(1, 0);
+    ea.set_in4_quad(2, 0);
+    ea.set_in4_quad(3, 1);
+    ea.set_port(1024);
+    o.back()->entries.push_back(watch_item_t(entity_name_t(entity_name_t::TYPE_CLIENT, 1), 10, 30, ea));
+    ea.set_nonce(1001);
+    ea.set_in4_quad(3, 2);
+    ea.set_port(1025);
+    o.back()->entries.push_back(watch_item_t(entity_name_t(entity_name_t::TYPE_CLIENT, 2), 20, 60, ea));
   }
 };
 
index e17e36a12986c6a401bdea87a89d13dcaaa44f86..52841236f1fc543aa2310cb385f37e92584468b6 100644 (file)
@@ -30,6 +30,7 @@
 #include <list>
 #include <map>
 #include <memory>
+#include <sstream>
 using namespace std;
 using namespace __gnu_cxx;
 
@@ -368,6 +369,9 @@ struct ObjectOperation {
             for (list<watch_item_t>::iterator i = resp.entries.begin() ;
                     i != resp.entries.end() ; ++i) {
               obj_watch_t ow;
+             ostringstream sa;
+             sa << i->addr;
+             strncpy(ow.addr, sa.str().c_str(), 256);
               ow.watcher_id = i->name.num();
               ow.cookie = i->cookie;
               ow.timeout_seconds = i->timeout_seconds;
index 778a9a6c53f8aeb55c296882979da039e902a42e..230379894542dafadcd3881b88cef2a4c75a8df2 100644 (file)
@@ -2095,7 +2095,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
       ret = 0;
     
     for (std::list<obj_watch_t>::iterator i = lw.begin(); i != lw.end(); ++i) {
-      cout << "watcher=client." << i->watcher_id << " cookie=" << i->cookie << std::endl;
+      cout << "watcher=" << i->addr << " client." << i->watcher_id << " cookie=" << i->cookie << std::endl;
     }
   } else if (strcmp(nargs[0], "listsnaps") == 0) {
     if (!pool_name || nargs.size() < 2)