]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados_test_stub: added aio_watch/aio_unwatch/aio_watch_flush
authorJason Dillaman <dillaman@redhat.com>
Sun, 28 Feb 2016 20:21:36 +0000 (15:21 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 1 Mar 2016 13:36:17 +0000 (08:36 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librados_test_stub/LibradosTestStub.cc
src/test/librados_test_stub/TestIoCtxImpl.cc
src/test/librados_test_stub/TestIoCtxImpl.h
src/test/librados_test_stub/TestRadosClient.cc
src/test/librados_test_stub/TestRadosClient.h
src/test/librados_test_stub/TestWatchNotify.cc
src/test/librados_test_stub/TestWatchNotify.h

index 99a8f444be2ded5ed1b062af1d1b0fcfca5cffbe..caa106b9fecb4287362f2c2c93099ce7b0e3cb60 100644 (file)
@@ -404,6 +404,17 @@ int IoCtx::aio_remove(const std::string& oid, AioCompletion *c) {
   return ctx->aio_remove(oid, c->pc);
 }
 
+int IoCtx::aio_watch(const std::string& o, AioCompletion *c, uint64_t *handle,
+                     librados::WatchCtx2 *watch_ctx) {
+  TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
+  return ctx->aio_watch(o, c->pc, handle, watch_ctx);
+}
+
+int IoCtx::aio_unwatch(uint64_t handle, AioCompletion *c) {
+  TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
+  return ctx->aio_unwatch(handle, c->pc);
+}
+
 config_t IoCtx::cct() {
   TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
   return reinterpret_cast<config_t>(ctx->get_rados_client()->cct());
@@ -811,6 +822,11 @@ AioCompletion *Rados::aio_create_completion(void *cb_arg,
   return new AioCompletion(c);
 }
 
+int Rados::aio_watch_flush(AioCompletion* c) {
+  TestRadosClient *impl = reinterpret_cast<TestRadosClient*>(client);
+  return impl->aio_watch_flush(c->pc);
+}
+
 int Rados::blacklist_add(const std::string& client_address,
                         uint32_t expire_seconds) {
   TestRadosClient *impl = reinterpret_cast<TestRadosClient*>(client);
index 4bde5c94200ae0c9d0c12fd0e6d6411837d1e044..fcca3b345678140ea753beae9c2bbb3f76d321a8 100644 (file)
@@ -125,6 +125,24 @@ int TestIoCtxImpl::aio_operate_read(const std::string& oid,
   return 0;
 }
 
+int TestIoCtxImpl::aio_watch(const std::string& o, AioCompletionImpl *c,
+                             uint64_t *handle, librados::WatchCtx2 *watch_ctx) {
+  m_pending_ops.inc();
+  c->get();
+  C_AioNotify *ctx = new C_AioNotify(this, c);
+  m_client->get_watch_notify().aio_watch(o, get_instance_id(), handle,
+                                         watch_ctx, ctx);
+  return 0;
+}
+
+int TestIoCtxImpl::aio_unwatch(uint64_t handle, AioCompletionImpl *c) {
+  m_pending_ops.inc();
+  c->get();
+  C_AioNotify *ctx = new C_AioNotify(this, c);
+  m_client->get_watch_notify().aio_unwatch(handle, ctx);
+  return 0;
+}
+
 int TestIoCtxImpl::exec(const std::string& oid, TestClassHandler *handler,
                         const char *cls, const char *method,
                         bufferlist& inbl, bufferlist* outbl,
index c38e90edb7e56f98b61eef22c7a3fb98036bdeaf..0db715f34b3820631bd77d7e023bea71ec3f9e72 100644 (file)
@@ -81,7 +81,9 @@ public:
                                AioCompletionImpl *c, int flags,
                                bufferlist *pbl);
   virtual int aio_remove(const std::string& oid, AioCompletionImpl *c) = 0;
-
+  virtual int aio_watch(const std::string& o, AioCompletionImpl *c,
+                        uint64_t *handle, librados::WatchCtx2 *ctx);
+  virtual int aio_unwatch(uint64_t handle, AioCompletionImpl *c);
   virtual int append(const std::string& oid, const bufferlist &bl,
                      const SnapContext &snapc) = 0;
   virtual int assert_exists(const std::string &oid) = 0;
index 789d40b28f15931e2c8994d9054a7639914836eb..e2fe20ba581580de1935dcd3f19cca61d067fb3e 100644 (file)
@@ -222,6 +222,14 @@ void TestRadosClient::flush_aio_operations(AioCompletionImpl *c) {
   }
 }
 
+int TestRadosClient::aio_watch_flush(AioCompletionImpl *c) {
+  c->get();
+  Context *ctx = new FunctionContext(boost::bind(
+    &TestRadosClient::finish_aio_completion, this, c, _1));
+  get_watch_notify().aio_flush(ctx);
+  return 0;
+}
+
 void TestRadosClient::finish_aio_completion(AioCompletionImpl *c, int r) {
   librados::finish_aio_completion(c, r);
 }
index b1aa75d790de2be07c56e144a456a91ad065c7ed..a4fd00d864900099f536dd82e35d4ac8e3e33bea 100644 (file)
@@ -85,6 +85,7 @@ public:
   virtual int64_t pool_lookup(const std::string &name) = 0;
   virtual int pool_reverse_lookup(int64_t id, std::string *name) = 0;
 
+  virtual int aio_watch_flush(AioCompletionImpl *c);
   virtual int watch_flush() = 0;
 
   virtual int blacklist_add(const std::string& client_address,
index e42c301a23dd8b97fc823255e01fedd14dc62add..2aacd4861522556cfdbfacf0789e2af16f107b64 100644 (file)
@@ -58,6 +58,23 @@ int TestWatchNotify::list_watchers(const std::string& o,
   return 0;
 }
 
+void TestWatchNotify::aio_flush(Context *on_finish) {
+  m_finisher->queue(on_finish);
+}
+
+void TestWatchNotify::aio_watch(const std::string& o, uint64_t gid,
+                                uint64_t *handle,
+                                librados::WatchCtx2 *watch_ctx,
+                                Context *on_finish) {
+  int r = watch(o, gid, handle, nullptr, watch_ctx);
+  m_finisher->queue(on_finish, r);
+}
+
+void TestWatchNotify::aio_unwatch(uint64_t handle, Context *on_finish) {
+  unwatch(handle);
+  m_finisher->queue(on_finish);
+}
+
 void TestWatchNotify::aio_notify(const std::string& oid, bufferlist& bl,
                                  uint64_t timeout_ms, bufferlist *pbl,
                                  Context *on_notify) {
index a40f560765b4e95be8a88ea8fc6c983a4256530c..9cd52306c365963b3bdaee292cb375563a5455fb 100644 (file)
@@ -51,11 +51,17 @@ public:
   TestWatchNotify(CephContext *cct, Finisher *finisher);
   ~TestWatchNotify();
 
-  void flush();
   int list_watchers(const std::string& o,
                     std::list<obj_watch_t> *out_watchers);
+
+  void aio_flush(Context *on_finish);
+  void aio_watch(const std::string& o, uint64_t gid, uint64_t *handle,
+                 librados::WatchCtx2 *watch_ctx, Context *on_finish);
+  void aio_unwatch(uint64_t handle, Context *on_finish);
   void aio_notify(const std::string& oid, bufferlist& bl, uint64_t timeout_ms,
                   bufferlist *pbl, Context *on_notify);
+
+  void flush();
   int notify(const std::string& o, bufferlist& bl,
              uint64_t timeout_ms, bufferlist *pbl);
   void notify_ack(const std::string& o, uint64_t notify_id,