]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cleanup: removing globals from common/obj_bencher
authorRoald van Loon <roaldvanloon@gmail.com>
Wed, 28 Aug 2013 14:56:23 +0000 (16:56 +0200)
committerRoald J. van Loon <roaldvanloon@gmail.com>
Thu, 5 Sep 2013 19:02:47 +0000 (21:02 +0200)
This file is in common/ but cant be included in libcommon.la because of
this reference. Removing it, making the binary calling it to pass the
correct cephcontext (rados, rest-bench).

Signed-off-by: Roald J. van Loon <roaldvanloon@gmail.com>
src/common/obj_bencher.cc
src/common/obj_bencher.h
src/rados.cc
src/tools/rest_bench.cc

index 6490b4f5932157be88efb62c61a49aecfe24ffc5..599cbbc62fb20c0014d0c2cf70dda4e8ba5a6f28 100644 (file)
@@ -79,7 +79,7 @@ ostream& ObjBencher::out(ostream& os, utime_t& t)
 
 ostream& ObjBencher::out(ostream& os)
 {
-  utime_t cur_time = ceph_clock_now(g_ceph_context);
+  utime_t cur_time = ceph_clock_now(cct);
   return out(os, cur_time);
 }
 
@@ -95,7 +95,7 @@ void *ObjBencher::status_printer(void *_bencher) {
   ONE_SECOND.set_from_double(1.0);
   bencher->lock.Lock();
   while(!data.done) {
-    utime_t cur_time = ceph_clock_now(g_ceph_context);
+    utime_t cur_time = ceph_clock_now(bencher->cct);
 
     if (i % 20 == 0) {
       if (i > 0)
@@ -158,7 +158,7 @@ void *ObjBencher::status_printer(void *_bencher) {
     }
     ++i;
     ++cycleSinceChange;
-    cond.WaitInterval(g_ceph_context, bencher->lock, ONE_SECOND);
+    cond.WaitInterval(bencher->cct, bencher->lock, ONE_SECOND);
   }
   bencher->lock.Unlock();
   return NULL;
@@ -339,10 +339,10 @@ int ObjBencher::write_bench(int secondsToRun, int maxObjectsToCreate,
 
   pthread_create(&print_thread, NULL, ObjBencher::status_printer, (void *)this);
   lock.Lock();
-  data.start_time = ceph_clock_now(g_ceph_context);
+  data.start_time = ceph_clock_now(cct);
   lock.Unlock();
   for (int i = 0; i<concurrentios; ++i) {
-    start_times[i] = ceph_clock_now(g_ceph_context);
+    start_times[i] = ceph_clock_now(cct);
     r = create_completion(i, _aio_cb, (void *)&lc);
     if (r < 0)
       goto ERR;
@@ -365,7 +365,7 @@ int ObjBencher::write_bench(int secondsToRun, int maxObjectsToCreate,
   stopTime = data.start_time + runtime;
   slot = 0;
   lock.Lock();
-  while( ceph_clock_now(g_ceph_context) < stopTime &&
+  while( ceph_clock_now(cct) < stopTime &&
         (!maxObjectsToCreate || data.started < maxObjectsToCreate)) {
     bool found = false;
     while (1) {
@@ -397,7 +397,7 @@ int ObjBencher::write_bench(int secondsToRun, int maxObjectsToCreate,
       lock.Unlock();
       goto ERR;
     }
-    data.cur_latency = ceph_clock_now(g_ceph_context) - start_times[slot];
+    data.cur_latency = ceph_clock_now(cct) - start_times[slot];
     data.history.latency.push_back(data.cur_latency);
     total_latency += data.cur_latency;
     if( data.cur_latency > data.max_latency) data.max_latency = data.cur_latency;
@@ -407,11 +407,11 @@ int ObjBencher::write_bench(int secondsToRun, int maxObjectsToCreate,
     --data.in_flight;
     lock.Unlock();
     release_completion(slot);
-    timePassed = ceph_clock_now(g_ceph_context) - data.start_time;
+    timePassed = ceph_clock_now(cct) - data.start_time;
 
     //write new stuff to backend, then delete old stuff
     //and save locations of new stuff for later deletion
-    start_times[slot] = ceph_clock_now(g_ceph_context);
+    start_times[slot] = ceph_clock_now(cct);
     r = create_completion(slot, _aio_cb, &lc);
     if (r < 0)
       goto ERR;
@@ -438,7 +438,7 @@ int ObjBencher::write_bench(int secondsToRun, int maxObjectsToCreate,
       lock.Unlock();
       goto ERR;
     }
-    data.cur_latency = ceph_clock_now(g_ceph_context) - start_times[slot];
+    data.cur_latency = ceph_clock_now(cct) - start_times[slot];
     data.history.latency.push_back(data.cur_latency);
     total_latency += data.cur_latency;
     if (data.cur_latency > data.max_latency) data.max_latency = data.cur_latency;
@@ -451,7 +451,7 @@ int ObjBencher::write_bench(int secondsToRun, int maxObjectsToCreate,
     delete contents[slot];
   }
 
-  timePassed = ceph_clock_now(g_ceph_context) - data.start_time;
+  timePassed = ceph_clock_now(cct) - data.start_time;
   lock.Lock();
   data.done = true;
   lock.Unlock();
@@ -529,7 +529,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
 
   lock.Lock();
   data.finished = 0;
-  data.start_time = ceph_clock_now(g_ceph_context);
+  data.start_time = ceph_clock_now(cct);
   lock.Unlock();
 
   pthread_t print_thread;
@@ -539,7 +539,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
   //start initial reads
   for (int i = 0; i < concurrentios; ++i) {
     index[i] = i;
-    start_times[i] = ceph_clock_now(g_ceph_context);
+    start_times[i] = ceph_clock_now(cct);
     create_completion(i, _aio_cb, (void *)&lc);
     r = aio_read(name[i], i, contents[i], data.object_size);
     if (r < 0) { //naughty, doesn't clean up heap -- oh, or handle the print thread!
@@ -557,7 +557,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
   bufferlist *cur_contents;
 
   slot = 0;
-  while (seconds_to_run && (ceph_clock_now(g_ceph_context) < finish_time) &&
+  while (seconds_to_run && (ceph_clock_now(cct) < finish_time) &&
       num_objects > data.started) {
     lock.Lock();
     int old_slot = slot;
@@ -590,7 +590,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
       lock.Unlock();
       goto ERR;
     }
-    data.cur_latency = ceph_clock_now(g_ceph_context) - start_times[slot];
+    data.cur_latency = ceph_clock_now(cct) - start_times[slot];
     total_latency += data.cur_latency;
     if( data.cur_latency > data.max_latency) data.max_latency = data.cur_latency;
     if (data.cur_latency < data.min_latency) data.min_latency = data.cur_latency;
@@ -602,7 +602,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
     cur_contents = contents[slot];
 
     //start new read and check data if requested
-    start_times[slot] = ceph_clock_now(g_ceph_context);
+    start_times[slot] = ceph_clock_now(cct);
     contents[slot] = new bufferlist();
     create_completion(slot, _aio_cb, (void *)&lc);
     r = aio_read(newName, slot, contents[slot], data.object_size);
@@ -633,7 +633,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
       lock.Unlock();
       goto ERR;
     }
-    data.cur_latency = ceph_clock_now(g_ceph_context) - start_times[slot];
+    data.cur_latency = ceph_clock_now(cct) - start_times[slot];
     total_latency += data.cur_latency;
     if (data.cur_latency > data.max_latency) data.max_latency = data.cur_latency;
     if (data.cur_latency < data.min_latency) data.min_latency = data.cur_latency;
@@ -650,7 +650,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
     delete contents[slot];
   }
 
-  runtime = ceph_clock_now(g_ceph_context) - data.start_time;
+  runtime = ceph_clock_now(cct) - data.start_time;
   lock.Lock();
   data.done = true;
   lock.Unlock();
index d626eda376da53d3a42200127ef8949e8a93c04f..c8f671f8c90841e9ca5e0939be4ed1cc8cc99dc9 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "common/config.h"
 #include "common/Cond.h"
+#include "common/ceph_context.h"
 
 struct bench_interval_data {
   double min_bandwidth;
@@ -51,6 +52,8 @@ const int OP_RAND_READ = 3;
 
 class ObjBencher {
   bool show_time;
+public:
+  CephContext *cct;
 protected:
   Mutex lock;
 
@@ -89,7 +92,7 @@ protected:
   ostream& out(ostream& os);
   ostream& out(ostream& os, utime_t& t);
 public:
-  ObjBencher() : show_time(false), lock("ObjBencher::lock") {}
+  ObjBencher(CephContext *cct_) : show_time(false), cct(cct_), lock("ObjBencher::lock") {}
   virtual ~ObjBencher() {}
   int aio_bench(
     int operation, int secondsToRun, int maxObjectsToCreate,
index dd9b4de179473fd06b8ba8b5296b7ef56557296f..0b7cc2b9cb757295cdb99a5dc43e604ab0996717 100644 (file)
@@ -879,7 +879,8 @@ protected:
   }
 
 public:
-  RadosBencher(librados::Rados& _r, librados::IoCtx& _i) : completions(NULL), rados(_r), io_ctx(_i), iterator_valid(false) {}
+  RadosBencher(CephContext *cct_, librados::Rados& _r, librados::IoCtx& _i)
+    : ObjBencher(cct), completions(NULL), rados(_r), io_ctx(_i), iterator_valid(false) {}
   ~RadosBencher() { }
 };
 
@@ -1987,7 +1988,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
       operation = OP_RAND_READ;
     else
       usage_exit();
-    RadosBencher bencher(rados, io_ctx);
+    RadosBencher bencher(g_ceph_context, rados, io_ctx);
     bencher.set_show_time(show_time);
     ret = bencher.aio_bench(operation, seconds, num_objs,
                            concurrent_ios, op_size, cleanup);
@@ -1998,7 +1999,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
     if (!pool_name || nargs.size() < 2)
       usage_exit();
     const char *prefix = nargs[1];
-    RadosBencher bencher(rados, io_ctx);
+    RadosBencher bencher(g_ceph_context, rados, io_ctx);
     ret = bencher.clean_up(prefix, concurrent_ios);
     if (ret != 0)
       cerr << "error during cleanup: " << ret << std::endl;
index 99fd16b5a344cecf023b01b44bcbc2f9a4cc9c95..feea4de49321f67e84f7138e1059769c28e38f16 100644 (file)
@@ -261,10 +261,12 @@ class RESTDispatcher {
   } req_wq;
 
 public:
-  RESTDispatcher(CephContext *cct, int num_threads)
-    : m_tp(cct, "RESTDispatcher::m_tp", num_threads),
-      req_wq(this, g_conf->rgw_op_thread_timeout,
-            g_conf->rgw_op_thread_suicide_timeout, &m_tp) {
+  CephContext *cct;
+  RESTDispatcher(CephContext *cct_, int num_threads)
+    : m_tp(cct_, "RESTDispatcher::m_tp", num_threads),
+      req_wq(this, cct_->_conf->rgw_op_thread_timeout,
+        cct_->_conf->rgw_op_thread_suicide_timeout, &m_tp),
+      cct(cct_) {
 
 
     response_handler.propertiesCallback = properties_callback;
@@ -588,6 +590,7 @@ protected:
 
 public:
   RESTBencher(RESTDispatcher *_dispatcher) :
+      ObjBencher(_dispatcher->cct),
       dispatcher(_dispatcher),
       completions(NULL),
       list_start(NULL),