]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
RadosModel: allow TestOps to pass data to their finish methods
authorJosh Durgin <josh.durgin@dreamhost.com>
Fri, 30 Dec 2011 02:30:57 +0000 (18:30 -0800)
committerJosh Durgin <josh.durgin@dreamhost.com>
Tue, 3 Jan 2012 21:10:37 +0000 (13:10 -0800)
This will allow nested writes to keep track of which write actually
completed.  Also remove finish() and _finish() from TestOp subclasses
that had the same implementation as the superclass.

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
src/test/osd/RadosModel.cc
src/test/osd/RadosModel.h

index 664d336c60c25793221f8ec1dd178d64d4654238..4665a352ce9a437451b4a4fad6ae45455be673ab 100644 (file)
@@ -15,13 +15,13 @@ void TestOp::begin()
   _begin();
 }
 
-void TestOp::finish()
+void TestOp::finish(TestOp::CallbackInfo *info)
 {
-  _finish();
+  _finish(info);
   //if (stat && finished()) stat->end(this);
 }
 
 void callback(librados::completion_t cb, void *arg) {
   TestOp *op = static_cast<TestOp*>(arg);
-  op->finish();
+  op->finish(NULL);
 }
index 3eba3dbd06df967b68e350635d6bfcf2fbfb2fd3..0be27250fe00eeb98b3c99a54b6e1422d30b7a92 100644 (file)
@@ -50,8 +50,29 @@ public:
 
   virtual ~TestOp();
 
+  /**
+   * This struct holds data to be passed by a callback
+   * to a TestOp::finish method.
+   */
+  struct CallbackInfo {
+    uint64_t id;
+    CallbackInfo(uint64_t id) : id(id) {}
+    virtual ~CallbackInfo() {};
+  };
+
   virtual void _begin() = 0;
-  virtual void _finish() = 0;
+
+  /**
+   * Called when the operation completes.
+   * This should be overridden by asynchronous operations.
+   *
+   * @param info information stored by a callback, or NULL -
+   *             useful for multi-operation TestOps
+   */
+  virtual void _finish(CallbackInfo *info)
+  {
+    return;
+  }
   virtual string getType() = 0;
   virtual bool finished()
   {
@@ -59,7 +80,7 @@ public:
   }
 
   void begin();
-  void finish();
+  void finish(CallbackInfo *info);
 };
 
 class TestOpGenerator {
@@ -322,7 +343,7 @@ public:
     }
   }
 
-  void _finish()
+  void _finish(CallbackInfo *info)
   {
     context->state_lock.Lock();
     assert(!done);
@@ -415,17 +436,6 @@ public:
     context->oid_in_use.erase(oid);
     context->oid_not_in_use.insert(oid);
     context->state_lock.Unlock();
-    finish();
-  }
-
-  void _finish()
-  {
-    return;
-  }
-
-  bool finished()
-  {
-    return true;
   }
 
   string getType()
@@ -476,7 +486,7 @@ public:
     }
   }
 
-  void _finish()
+  void _finish(CallbackInfo *info)
   {
     context->state_lock.Lock();
     assert(!done);
@@ -537,13 +547,6 @@ public:
     context->state_lock.Lock();
     context->add_snap(snap);
     context->state_lock.Unlock();
-
-    finish();
-  }
-
-  void _finish()
-  {
-    return;
   }
 
   string getType()
@@ -570,12 +573,6 @@ public:
     context->state_lock.Unlock();
 
     assert(!context->io_ctx.selfmanaged_snap_remove(snap));
-    finish();
-  }
-
-  void _finish()
-  {
-    return;
   }
 
   string getType()
@@ -621,14 +618,7 @@ public:
       cerr << "r is " << r << std::endl;
       assert(0);
     }
-    finish();
-  }
-
-  void _finish()
-  {
-    return;
   }
-    
 
   string getType()
   {