]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: switch to new watch/notify API
authorSage Weil <sage@redhat.com>
Sat, 6 Dec 2014 02:00:04 +0000 (18:00 -0800)
committerSage Weil <sage@redhat.com>
Sat, 6 Dec 2014 02:00:04 +0000 (18:00 -0800)
Note that we don't use it properly, yet!

Signed-off-by: Sage Weil <sage@redhat.com>
src/rgw/rgw_cache.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index c0a0e243af76d9ffe73e55bc55d0833829efaf2c..f5d1b20ee4bdbbdc7aa29a8607093a0da4512817 100644 (file)
@@ -201,7 +201,10 @@ class RGWCache  : public T
   }
 
   int distribute_cache(const string& normal_name, rgw_obj& obj, ObjectCacheInfo& obj_info, int op);
-  int watch_cb(int opcode, uint64_t ver, bufferlist& bl);
+  int watch_cb(uint64_t notify_id,
+              uint64_t cookie,
+              uint64_t notifier_id,
+              bufferlist& bl);
 public:
   RGWCache() {}
 
@@ -554,7 +557,10 @@ int RGWCache<T>::distribute_cache(const string& normal_name, rgw_obj& obj, Objec
 }
 
 template <class T>
-int RGWCache<T>::watch_cb(int opcode, uint64_t ver, bufferlist& bl)
+int RGWCache<T>::watch_cb(uint64_t notify_id,
+                         uint64_t cookie,
+                         uint64_t notifier_id,
+                         bufferlist& bl)
 {
   RGWCacheNotifyInfo info;
 
index 2c53454389be01178e5b1783eef493fd4757bfe6..dd251b82c6959e23cc2ba2b5d7bbf52930164c63 100644 (file)
@@ -1206,13 +1206,23 @@ int RGWPutObjProcessor_Atomic::do_complete(string& etag, time_t *mtime, time_t s
   return r;
 }
 
-class RGWWatcher : public librados::WatchCtx {
+class RGWWatcher : public librados::WatchCtx2 {
   RGWRados *rados;
 public:
   RGWWatcher(RGWRados *r) : rados(r) {}
-  void notify(uint8_t opcode, uint64_t ver, bufferlist& bl) {
-    ldout(rados->ctx(), 10) << "RGWWatcher::notify() opcode=" << (int)opcode << " ver=" << ver << " bl.length()=" << bl.length() << dendl;
-    rados->watch_cb(opcode, ver, bl);
+  void handle_notify(uint64_t notify_id,
+                    uint64_t cookie,
+                    uint64_t notifier_id,
+                    bufferlist& bl) {
+    ldout(rados->ctx(), 10) << "RGWWatcher::handle_notify() "
+                           << " notify_id " << notify_id
+                           << " cookie " << cookie
+                           << " notifier " << notifier_id
+                           << " bl.length()=" << bl.length() << dendl;
+    rados->watch_cb(notify_id, cookie, notifier_id, bl);
+  }
+  void handle_error(uint64_t cookie, int err) {
+    // FIXME
   }
 };
 
@@ -1463,7 +1473,7 @@ void RGWRados::finalize_watch()
     if (notify_oid.empty())
       continue;
     uint64_t watch_handle = watch_handles[i];
-    control_pool_ctx.unwatch(notify_oid, watch_handle);
+    control_pool_ctx.unwatch(watch_handle);
 
     RGWWatcher *watcher = watchers[i];
     delete watcher;
@@ -1598,7 +1608,7 @@ int RGWRados::init_watch()
     RGWWatcher *watcher = new RGWWatcher(this);
     watchers[i] = watcher;
 
-    r = control_pool_ctx.watch(notify_oid, 0, &watch_handles[i], watcher);
+    r = control_pool_ctx.watch(notify_oid, &watch_handles[i], watcher);
     if (r < 0)
       return r;
   }
@@ -5804,7 +5814,7 @@ int RGWRados::distribute(const string& key, bufferlist& bl)
   pick_control_oid(key, notify_oid);
 
   ldout(cct, 10) << "distributing notification oid=" << notify_oid << " bl.length()=" << bl.length() << dendl;
-  int r = control_pool_ctx.notify(notify_oid, 0, bl);
+  int r = control_pool_ctx.notify(notify_oid, bl, 0, NULL);
   return r;
 }
 
index f38b3ac3df347b54ef2d60ecce220d05e207cb8e..b15827d3dbd818d0426a7d197b2df3732b36d5d1 100644 (file)
@@ -1766,7 +1766,10 @@ public:
   virtual int init_watch();
   virtual void finalize_watch();
   virtual int distribute(const string& key, bufferlist& bl);
-  virtual int watch_cb(int opcode, uint64_t ver, bufferlist& bl) { return 0; }
+  virtual int watch_cb(uint64_t notify_id,
+                      uint64_t cookie,
+                      uint64_t notifier_id,
+                      bufferlist& bl) { return 0; }
   void pick_control_oid(const string& key, string& notify_oid);
 
   void *create_context(void *user_ctx) {