]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: test_workload_gen: Add callback for collection destruction.
authorJoao Eduardo Luis <jecluis@gmail.com>
Fri, 30 Mar 2012 14:32:12 +0000 (15:32 +0100)
committerJoao Eduardo Luis <jecluis@gmail.com>
Fri, 30 Mar 2012 14:32:12 +0000 (15:32 +0100)
When we remove a collection, we must cleanup after the coll_entry_t we
once had on the available collections set. For some reason, we weren't
doing this.

This commit adds a new callback, which inherits from the 'OnReadable'
callback on the WorkloadGenerator class, that will be responsible for
deleting the coll_entry_t once we know the collection transaction
destroying the collection has finished.

src/test/test_workload_gen/workload_generator.cc
src/test/test_workload_gen/workload_generator.h

index 9009f15625a3fc5faf8143d217cc8f44672723cc..a5ffcf909f84fc7988be3f4701b7823e211e4767 100644 (file)
@@ -79,11 +79,6 @@ void WorkloadGenerator::init_args(vector<const char*> args) {
       usage(NULL);
       exit(0);
     }
-
-//    else if (ceph_argparse_binary_flag(args, i, &allow_coll_dest, NULL,
-//        "--allow-coll-destruction", (char*) NULL)) {
-//      m_allow_coll_destruction = (allow_coll_dest ? true : false);
-//    }
   }
 }
 
@@ -286,8 +281,10 @@ void WorkloadGenerator::run() {
     bool destroy_collection = should_destroy_collection();
     coll_entry_t *entry = get_rnd_coll_entry(destroy_collection);
 
+    Context *c;
     if (destroy_collection) {
       do_destroy_collection(t, entry);
+      c = new C_WorkloadGeneratorOnDestroyed(this, t, entry);
     } else {
       int obj_nr = get_random_object_nr(entry->id);
       hobject_t obj = get_object_by_nr(obj_nr);
@@ -296,10 +293,10 @@ void WorkloadGenerator::run() {
       do_setattr_object(t, entry->coll, obj);
       do_setattr_collection(t, entry->coll);
       do_append_log(t, entry->coll);
+      c = new C_WorkloadGeneratorOnReadable(this, t);
     }
 
-    m_store->queue_transaction(&(entry->osr), t,
-        new C_WorkloadGeneratorOnReadable(this, t));
+    m_store->queue_transaction(&(entry->osr), t, c);
 
     m_in_flight++;
 
index 21696e32f347002f8c9119e4efdad1cb0a58fde7..d88e3094367fb3fa2d024d288dc39652c84bdc6a 100644 (file)
@@ -132,7 +132,7 @@ public:
     }
 
     void finish(int r) {
-      dout(0) << "Got one back!" << dendl;
+//      dout(0) << "Got one back!" << dendl;
       Mutex::Locker locker(m_state->m_lock);
       m_state->m_in_flight--;
       m_state->m_nr_runs++;
@@ -142,6 +142,23 @@ public:
     }
   };
 
+  class C_WorkloadGeneratorOnDestroyed: public C_WorkloadGeneratorOnReadable {
+//    WorkloadGenerator *m_state;
+//    ObjectStore::Transaction *m_tx;
+    coll_entry_t *m_entry;
+
+  public:
+    C_WorkloadGeneratorOnDestroyed(WorkloadGenerator *state,
+        ObjectStore::Transaction *t, coll_entry_t *entry) :
+          C_WorkloadGeneratorOnReadable(state, t), m_entry(entry) {}
+
+    void finish(int r) {
+      C_WorkloadGeneratorOnReadable::finish(r);
+      dout(0) << "Destroyed collection " << m_entry->coll.to_str() << dendl;
+      delete m_entry;
+    }
+  };
+
   void run(void);
   void print_results(void);
 };