From f90c48f271e58837a264b0692468f59e66ca9abf Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 9 Jan 2015 14:02:04 -0800 Subject: [PATCH] Revert "rgw: switch to new watch/notify API" This reverts commit dc67cd69604ec4e4df846b818ec739dc7b09a537. Conflicts: src/rgw/rgw_rados.cc --- src/rgw/rgw_cache.h | 10 ++-------- src/rgw/rgw_rados.cc | 24 +++++++----------------- src/rgw/rgw_rados.h | 5 +---- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index f2baaea52435b..8b1bc93bfb029 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -201,10 +201,7 @@ class RGWCache : public T } int distribute_cache(const string& normal_name, rgw_obj& obj, ObjectCacheInfo& obj_info, int op); - int watch_cb(uint64_t notify_id, - uint64_t cookie, - uint64_t notifier_id, - bufferlist& bl); + int watch_cb(int opcode, uint64_t ver, bufferlist& bl); public: RGWCache() {} @@ -560,10 +557,7 @@ int RGWCache::distribute_cache(const string& normal_name, rgw_obj& obj, Objec } template -int RGWCache::watch_cb(uint64_t notify_id, - uint64_t cookie, - uint64_t notifier_id, - bufferlist& bl) +int RGWCache::watch_cb(int opcode, uint64_t ver, bufferlist& bl) { RGWCacheNotifyInfo info; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index dbc2bc8e5f291..df9191ea15d1c 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1215,23 +1215,13 @@ int RGWPutObjProcessor_Atomic::do_complete(string& etag, time_t *mtime, time_t s return r; } -class RGWWatcher : public librados::WatchCtx2 { +class RGWWatcher : public librados::WatchCtx { RGWRados *rados; public: RGWWatcher(RGWRados *r) : rados(r) {} - 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 + 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); } }; @@ -1482,7 +1472,7 @@ void RGWRados::finalize_watch() if (notify_oid.empty()) continue; uint64_t watch_handle = watch_handles[i]; - control_pool_ctx.unwatch2(watch_handle); + control_pool_ctx.unwatch(notify_oid, watch_handle); RGWWatcher *watcher = watchers[i]; delete watcher; @@ -1617,7 +1607,7 @@ int RGWRados::init_watch() RGWWatcher *watcher = new RGWWatcher(this); watchers[i] = watcher; - r = control_pool_ctx.watch2(notify_oid, &watch_handles[i], watcher); + r = control_pool_ctx.watch(notify_oid, 0, &watch_handles[i], watcher); if (r < 0) return r; } @@ -5890,7 +5880,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.notify2(notify_oid, bl, 0, NULL); + int r = control_pool_ctx.notify(notify_oid, 0, bl); return r; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 838e9422775f4..d397a1f15e662 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1783,10 +1783,7 @@ public: virtual int init_watch(); virtual void finalize_watch(); virtual int distribute(const string& key, bufferlist& bl); - virtual int watch_cb(uint64_t notify_id, - uint64_t cookie, - uint64_t notifier_id, - bufferlist& bl) { return 0; } + virtual int watch_cb(int opcode, uint64_t ver, bufferlist& bl) { return 0; } void pick_control_oid(const string& key, string& notify_oid); void *create_context(void *user_ctx) { -- 2.39.5