summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Eduardo Luis <jecluis@gmail.com>2012-03-30 15:32:12 +0100
committerJoao Eduardo Luis <jecluis@gmail.com>2012-03-30 15:32:12 +0100
commiteebc9ec2dd841946b7dad10b1aae721b97316d4d (patch)
tree787222a5cdd08d1d71a8d4942ddc72bcabb91fce
parentc39ed568612d1f2b642f0867efa720557e4b96d0 (diff)
downloadceph-eebc9ec2dd841946b7dad10b1aae721b97316d4d.tar.gz
test: test_workload_gen: Add callback for collection destruction.
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.
-rw-r--r--src/test/test_workload_gen/workload_generator.cc11
-rw-r--r--src/test/test_workload_gen/workload_generator.h19
2 files changed, 22 insertions, 8 deletions
diff --git a/src/test/test_workload_gen/workload_generator.cc b/src/test/test_workload_gen/workload_generator.cc
index 9009f15625a..a5ffcf909f8 100644
--- a/src/test/test_workload_gen/workload_generator.cc
+++ b/src/test/test_workload_gen/workload_generator.cc
@@ -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++;
diff --git a/src/test/test_workload_gen/workload_generator.h b/src/test/test_workload_gen/workload_generator.h
index 21696e32f34..d88e3094367 100644
--- a/src/test/test_workload_gen/workload_generator.h
+++ b/src/test/test_workload_gen/workload_generator.h
@@ -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);
};