]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: read remote meta coroutine
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 19 Aug 2015 00:14:05 +0000 (17:14 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 9 Feb 2016 21:40:55 +0000 (13:40 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rest_client.h
src/rgw/rgw_rest_conn.h
src/rgw/rgw_sync.cc

index 5a6c4198fddd1bee9d4e792e12c8a986bb142843..e607dbacde0a5285c683ecb131fe8801efac1a8c 100644 (file)
@@ -61,6 +61,7 @@ public:
   map<string, string>& get_out_headers() { return out_headers; }
 
   int get_http_status() { return http_status; }
+  int get_status() { return status; }
 };
 
 
index c8b88b9667f6791439208a4c62df0c52016c9bb8..0d7735a4041b5834c54af784db78ee257efea11d 100644 (file)
@@ -166,6 +166,14 @@ public:
     return req.get_http_status();
   }
 
+  int wait_bl(bufferlist *pbl) {
+    if (req.get_status() < 0) {
+      return req.get_status();
+    }
+    *pbl = bl;
+    return 0;
+  }
+
   template <class T>
   int wait(T *dest);
 
@@ -177,7 +185,11 @@ public:
 template <class T>
 int RGWRESTReadResource::decode_resource(T *dest)
 {
-  int ret = parse_decode_json(cct, *dest, bl);
+  int ret = req.get_status();
+  if (ret < 0) {
+    return ret;
+  }
+  ret = parse_decode_json(cct, *dest, bl);
   if (ret < 0) {
     return ret;
   }
index 6be3865924f372cfe353669225a86cf922f0f68a..bf4587a7ef859e3d1a64ff2b4c32ebb8d98facc5 100644 (file)
@@ -1059,6 +1059,66 @@ static string full_sync_index_shard_oid(int shard_id)
   return string(buf);
 }
 
+template <class T>
+class RGWReadRemoteMetadataCR : public RGWCoroutine {
+  RGWRados *store;
+  RGWHTTPManager *http_manager;
+  RGWAsyncRadosProcessor *async_rados;
+
+  RGWRESTReadResource *http_op;
+
+  string section;
+  string key;
+
+  bufferlist *pbl;
+
+public:
+  RGWReadRemoteMetadataCR(RGWRados *_store, RGWHTTPManager *_mgr, RGWAsyncRadosProcessor *_async_rados,
+                                                      const string& _section, const string& _key, bufferlist *_pbl) : RGWCoroutine(_store->ctx()), store(_store),
+                                                      http_manager(_mgr),
+                                                     async_rados(_async_rados),
+                                                      http_op(NULL),
+                                                      section(_section),
+                                                      key(_key),
+                                                     pbl(_pbl) {
+  }
+
+  int operate() {
+    RGWRESTConn *conn = store->rest_master_conn;
+    reenter(this) {
+      yield {
+        rgw_http_param_pair pairs[] = { { NULL, NULL } };
+
+        string p = string("/metadata") + section + "/" + key;
+
+        http_op = new RGWRESTReadResource(conn, p, pairs, NULL, http_manager);
+
+        http_op->set_user_info((void *)stack);
+
+        int ret = http_op->aio_read();
+        if (ret < 0) {
+          ldout(store->ctx(), 0) << "ERROR: failed to fetch mdlog data" << dendl;
+          log_error() << "failed to send http operation: " << http_op->to_str() << " ret=" << ret << std::endl;
+          http_op->put();
+          return set_state(RGWCoroutine_Error, ret);
+        }
+
+        return io_block(0);
+      }
+      yield {
+        int ret = http_op->wait_bl(pbl);
+        if (ret < 0) {
+          return set_state(RGWCoroutine_Error, ret);
+        }
+        return set_state(RGWCoroutine_Done, 0);
+      }
+    }
+    return 0;
+  }
+};
+
+
+
 class RGWMetaSyncShardCR : public RGWCoroutine {
   RGWRados *store;
   RGWHTTPManager *http_manager;
@@ -1108,7 +1168,7 @@ public:
               // update shard marker
             }
           }
-        } while (entries.size() == max_entries);
+        } while ((int)entries.size() == max_entries);
         // update shard state
         return set_state(RGWCoroutine_Done, 0);
       } else if (sync_marker.state == rgw_meta_sync_marker::IncrementalSync) {