]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: amend http client manager interface
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 30 Aug 2017 11:40:02 +0000 (04:40 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:05:37 +0000 (08:05 -0700)
s/set_threaded/start
s/is_threaded/is_started

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_data_sync.cc
src/rgw/rgw_http_client.cc
src/rgw/rgw_http_client.h
src/rgw/rgw_period_pusher.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_sync.cc
src/test/rgw/test_http_manager.cc

index 35e9cb0a14f40321ca96460afa2c35f5de55831a..7b97e77a18a017ff73a13672bfd1f35db8766aab 100644 (file)
@@ -6458,7 +6458,7 @@ next:
 
     RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry());
     RGWHTTPManager http(store->ctx(), crs.get_completion_mgr());
-    int ret = http.set_threaded();
+    int ret = http.start();
     if (ret < 0) {
       cerr << "failed to initialize http client with " << cpp_strerror(ret) << std::endl;
       return -ret;
@@ -6979,7 +6979,7 @@ next:
   if (opt_cmd == OPT_BILOG_AUTOTRIM) {
     RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry());
     RGWHTTPManager http(store->ctx(), crs.get_completion_mgr());
-    int ret = http.set_threaded();
+    int ret = http.start();
     if (ret < 0) {
       cerr << "failed to initialize http client with " << cpp_strerror(ret) << std::endl;
       return -ret;
index 21b5bdb01ad1c1dcd8fde41e586bf9f0ef4a74e5..9a97526a463e3f5f5de3dd520cf067bac906c439 100644 (file)
@@ -667,9 +667,9 @@ int RGWRemoteDataLog::init(const string& _source_zone, RGWRESTConn *_conn, RGWSy
     return 0;
   }
 
-  int ret = http_manager.set_threaded();
+  int ret = http_manager.start();
   if (ret < 0) {
-    ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl;
+    ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl;
     return ret;
   }
 
@@ -694,9 +694,9 @@ int RGWRemoteDataLog::read_sync_status(rgw_data_sync_status *sync_status)
   // cannot run concurrently with run_sync(), so run in a separate manager
   RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry());
   RGWHTTPManager http_manager(store->ctx(), crs.get_completion_mgr());
-  int ret = http_manager.set_threaded();
+  int ret = http_manager.start();
   if (ret < 0) {
-    ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl;
+    ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl;
     return ret;
   }
   RGWDataSyncEnv sync_env_local = sync_env;
@@ -741,9 +741,9 @@ int RGWRemoteDataLog::init_sync_status(int num_shards)
 
   RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry());
   RGWHTTPManager http_manager(store->ctx(), crs.get_completion_mgr());
-  int ret = http_manager.set_threaded();
+  int ret = http_manager.start();
   if (ret < 0) {
-    ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl;
+    ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl;
     return ret;
   }
   RGWDataSyncEnv sync_env_local = sync_env;
@@ -3074,9 +3074,9 @@ int RGWBucketSyncStatusManager::init()
     return -EINVAL;
   }
 
-  int ret = http_manager.set_threaded();
+  int ret = http_manager.start();
   if (ret < 0) {
-    ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl;
+    ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl;
     return ret;
   }
 
index 7535633d2ec1704b983841e48f3b78c9e5f837a5..ccea463d2ec7ad17cc810914f03ccdc2cf155877 100644 (file)
@@ -766,7 +766,7 @@ void *RGWHTTPManager::ReqsThread::entry()
  * RGWHTTPManager has two modes of operation: threaded and non-threaded.
  */
 RGWHTTPManager::RGWHTTPManager(CephContext *_cct, RGWCompletionManager *_cm) : cct(_cct),
-                                                    completion_mgr(_cm), is_threaded(false),
+                                                    completion_mgr(_cm), is_started(false),
                                                     reqs_lock("RGWHTTPManager::reqs_lock"), num_reqs(0), max_threaded_req(0),
                                                     reqs_thread(NULL)
 {
@@ -942,7 +942,7 @@ int RGWHTTPManager::add_request(RGWHTTPClient *client, bool send_data_hint)
 
   register_request(req_data);
 
-  if (!is_threaded) {
+  if (!is_started) {
     ret = link_request(req_data);
     if (ret < 0) {
       req_data->put();
@@ -962,7 +962,7 @@ int RGWHTTPManager::remove_request(RGWHTTPClient *client)
 {
   rgw_http_req_data *req_data = client->get_req_data();
 
-  if (!is_threaded) {
+  if (!is_started) {
     unlink_request(req_data);
     return 0;
   }
@@ -982,7 +982,7 @@ int RGWHTTPManager::set_request_state(RGWHTTPClient *client, RGWHTTPRequestSetSt
   assert(req_data->lock.is_locked());
 
   /* can only do that if threaded */
-  if (!is_threaded) {
+  if (!is_started) {
     return -EINVAL;
   }
 
@@ -1013,7 +1013,7 @@ int RGWHTTPManager::set_request_state(RGWHTTPClient *client, RGWHTTPRequestSetSt
   return 0;
 }
 
-int RGWHTTPManager::set_threaded()
+int RGWHTTPManager::start()
 {
   int r = pipe(thread_pipe);
   if (r < 0) {
@@ -1040,7 +1040,7 @@ int RGWHTTPManager::set_threaded()
                  thread_pipe[1], thread_pipe[0]);
 #endif
 
-  is_threaded = true;
+  is_started = true;
   reqs_thread = new ReqsThread(this);
   reqs_thread->create("http_manager");
   return 0;
@@ -1054,7 +1054,7 @@ void RGWHTTPManager::stop()
 
   is_stopped = true;
 
-  if (is_threaded) {
+  if (is_started) {
     going_down = true;
     signal_thread();
     reqs_thread->join();
@@ -1157,7 +1157,7 @@ void rgw_http_client_init(CephContext *cct)
 {
   curl_global_init(CURL_GLOBAL_ALL);
   rgw_http_manager = new RGWHTTPManager(cct);
-  rgw_http_manager->set_threaded();
+  rgw_http_manager->start();
 }
 
 void rgw_http_client_cleanup()
index ac230bfb2a6ae29d4e38a42f4c662e587d2053e8..dcc78d19904a6296088ab2058241383e91a1aa7b 100644 (file)
@@ -263,7 +263,7 @@ class RGWHTTPManager {
   CephContext *cct;
   RGWCompletionManager *completion_mgr;
   void *multi_handle;
-  bool is_threaded;
+  bool is_started;
   std::atomic<unsigned> going_down { 0 };
   std::atomic<unsigned> is_stopped { 0 };
 
@@ -307,7 +307,7 @@ public:
   RGWHTTPManager(CephContext *_cct, RGWCompletionManager *completion_mgr = NULL);
   ~RGWHTTPManager();
 
-  int set_threaded();
+  int start();
   void stop();
 
   int add_request(RGWHTTPClient *client, bool send_data_hint = false);
index 7072c541368e240de5da7a497da9e5503957fe90..ec676c239437624b2c4f8b18a66996a7a26f6e3f 100644 (file)
@@ -136,8 +136,8 @@ class RGWPeriodPusher::CRThread {
       http(cct, coroutines.get_completion_mgr()),
       push_all(new PushAllCR(cct, &http, std::move(period), std::move(conns)))
   {
-    http.set_threaded();
-    // must spawn the CR thread after set_threaded
+    http.start();
+    // must spawn the CR thread after start
     thread = std::thread([this] { coroutines.run(push_all.get()); });
   }
   ~CRThread()
index fa334ef906a0b98466fbb17b8ee3e30f18b1caae..5ed3d0ec3cdcb955984c3786504d8b80fd0149cb 100644 (file)
@@ -2978,7 +2978,7 @@ class RGWMetaNotifierManager : public RGWCoroutinesManager {
 public:
   RGWMetaNotifierManager(RGWRados *_store) : RGWCoroutinesManager(_store->ctx(), _store->get_cr_registry()), store(_store),
                                              http_manager(store->ctx(), completion_mgr) {
-    http_manager.set_threaded();
+    http_manager.start();
   }
 
   int notify_all(map<string, RGWRESTConn *>& conn_map, set<int>& shards) {
@@ -3005,7 +3005,7 @@ class RGWDataNotifierManager : public RGWCoroutinesManager {
 public:
   RGWDataNotifierManager(RGWRados *_store) : RGWCoroutinesManager(_store->ctx(), _store->get_cr_registry()), store(_store),
                                              http_manager(store->ctx(), completion_mgr) {
-    http_manager.set_threaded();
+    http_manager.start();
   }
 
   int notify_all(map<string, RGWRESTConn *>& conn_map, map<int, set<string> >& shards) {
@@ -3272,7 +3272,7 @@ public:
   {}
 
   int init() override {
-    return http.set_threaded();
+    return http.start();
   }
   int process() override {
     list<RGWCoroutinesStack*> stacks;
index 3a1230ec1447f13b5ab27aa4c29fe764f05f6e81..f5bcfc988716fbc994a4d20f19dc5c5b48a6c04a 100644 (file)
@@ -277,9 +277,9 @@ int RGWRemoteMetaLog::init()
 {
   conn = store->rest_master_conn;
 
-  int ret = http_manager.set_threaded();
+  int ret = http_manager.start();
   if (ret < 0) {
-    ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl;
+    ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl;
     return ret;
   }
 
@@ -1999,9 +1999,9 @@ int RGWRemoteMetaLog::read_sync_status(rgw_meta_sync_status *sync_status)
   // cannot run concurrently with run_sync(), so run in a separate manager
   RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry());
   RGWHTTPManager http_manager(store->ctx(), crs.get_completion_mgr());
-  int ret = http_manager.set_threaded();
+  int ret = http_manager.start();
   if (ret < 0) {
-    ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl;
+    ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl;
     return ret;
   }
   RGWMetaSyncEnv sync_env_local = sync_env;
index 73626a7d9cf711c5117638af120e4a3848bf736b..3240dc8bfc86466da02e80de282c63ba63e422a8 100644 (file)
@@ -23,7 +23,7 @@ TEST(HTTPManager, SignalThread)
   auto cct = g_ceph_context;
   RGWHTTPManager http(cct);
 
-  ASSERT_EQ(0, http.set_threaded());
+  ASSERT_EQ(0, http.start());
 
   // default pipe buffer size according to man pipe
   constexpr size_t max_pipe_buffer_size = 65536;