]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: loadgen, configurable num of objs, buckets 1092/head
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 20 Dec 2013 20:58:15 +0000 (12:58 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 17 Jan 2014 18:16:09 +0000 (10:16 -0800)
also fix request draining

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_main.cc

index 1a890f5e38ce46f4b76257af6332c8d0cdbad832..348de5bd87cf380cd2ec56b8541a3d382e4a2b94 100644 (file)
@@ -319,7 +319,7 @@ void RGWFCGXProcess::run()
     req_wq.queue(req);
   }
 
-  m_tp.drain();
+  m_tp.drain(&req_wq);
   m_tp.stop();
 }
 
@@ -349,7 +349,7 @@ public:
 
 void RGWLoadGenProcess::checkpoint()
 {
-  m_tp.drain();
+  m_tp.drain(&req_wq);
 }
 
 void RGWLoadGenProcess::run()
@@ -358,19 +358,28 @@ void RGWLoadGenProcess::run()
 
   int i;
 
-  int num_objs = 1000;
+  int num_objs;
 
-  string bucket = "mybucket";
+  conf->get_val("num_objs", 1000, &num_objs);
 
-  string bucket_resource = string("/") + bucket;
+  int num_buckets;
+  conf->get_val("num_buckets", 1, &num_buckets);
+
+  string buckets[num_buckets];
 
   atomic_t failed;
-  string *objs = new string[num_objs];
 
-  /* first create a bucket */
-  gen_request("PUT", bucket_resource, 0, &failed);
+  for (i = 0; i < num_buckets; i++) {
+    buckets[i] = "/loadgen";
+    string& bucket = buckets[i];
+    append_rand_alpha(NULL, bucket, bucket, 16);
 
-  checkpoint();
+    /* first create a bucket */
+    gen_request("PUT", bucket, 0, &failed);
+    checkpoint();
+  }
+
+  string *objs = new string[num_objs];
 
   if (failed.read()) {
     derr << "ERROR: bucket creation failed" << dendl;
@@ -378,9 +387,10 @@ void RGWLoadGenProcess::run()
   }
 
   for (i = 0; i < num_objs; i++) {
-    char buf[32];
-    snprintf(buf, sizeof(buf), "obj-%d", i);
-    objs[i] = bucket_resource + "/" + buf;
+    char buf[16 + 1];
+    gen_rand_alphanumeric(NULL, buf, sizeof(buf));
+    buf[16] = '\0';
+    objs[i] = buckets[i % num_buckets] + "/" + buf;
   }
 
   for (i = 0; i < num_objs; i++) {
@@ -404,13 +414,17 @@ void RGWLoadGenProcess::run()
     gen_request("DELETE", objs[i], 0, NULL);
   }
 
-  gen_request("DELETE", bucket_resource, 0, NULL);
+  checkpoint();
+
+  for (i = 0; i < num_buckets; i++) {
+    gen_request("DELETE", buckets[i], 0, NULL);
+  }
 
+done:
   checkpoint();
 
   m_tp.stop();
 
-done:
   delete[] objs;
 
   signal_shutdown();
@@ -861,7 +875,9 @@ public:
   RGWLoadGenFrontend(RGWProcessEnv& pe, RGWFrontendConfig *_conf) : RGWProcessFrontend(pe, _conf) {}
 
   int init() {
-    RGWLoadGenProcess *pp = new RGWLoadGenProcess(g_ceph_context, &env, g_conf->rgw_thread_pool_size, conf);
+    int num_threads;
+    conf->get_val("num_threads", g_conf->rgw_thread_pool_size, &num_threads);
+    RGWLoadGenProcess *pp = new RGWLoadGenProcess(g_ceph_context, &env, num_threads, conf);
 
     pprocess = pp;