rgw/rgw_replica_log.cc \
rgw/rgw_keystone.cc \
rgw/rgw_quota.cc \
+ rgw/rgw_sync.cc \
rgw/rgw_dencoder.cc \
rgw/rgw_object_expirer_core.cc \
rgw/rgw_website.cc
return ret;
}
+bool RGWRados::is_meta_master()
+{
+ if (!region.is_master) {
+ return false;
+ }
+
+ return (region.master_zone == zone_public_config.name);
+}
+
/**
* Check to see if the bucket metadata could be synced
* bucket: the bucket to check
*/
virtual int delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_tracker);
+ bool is_meta_master();
+
/**
* Check to see if the bucket metadata is synced
*/
url_encode(obj.bucket.name, urlsafe_bucket);
url_encode(obj.get_object(), urlsafe_object);
string resource = urlsafe_bucket + "/" + urlsafe_object;
+
+ return get_resource(key, extra_headers, resource);
+}
+
+int RGWRESTStreamReadRequest::get_resource(RGWAccessKey& key, map<string, string>& extra_headers, const string& resource)
+{
string new_url = url;
if (new_url[new_url.size() - 1] != '/')
new_url.append("/");
map<string, string>& args = new_info.args.get_params();
get_params_str(args, params_str);
- new_url.append(resource + params_str);
+ string new_resource;
+ if (resource[0] == '/') {
+ new_resource = resource.substr(1);
+ } else {
+ new_resource = resource;
+ }
+
+ new_url.append(new_resource + params_str);
new_env.set("HTTP_DATE", date_str.c_str());
new_info.method = "GET";
new_info.script_uri = "/";
- new_info.script_uri.append(resource);
+ new_info.script_uri.append(new_resource);
new_info.request_uri = new_info.script_uri;
new_info.init_meta_info(NULL);
chunk_ofs(0), ofs(0) {}
~RGWRESTStreamReadRequest() {}
int get_obj(RGWAccessKey& key, map<string, string>& extra_headers, rgw_obj& obj);
+ int get_resource(RGWAccessKey& key, map<string, string>& extra_headers, const string& resource);
int complete(string& etag, time_t *mtime, map<string, string>& attrs);
void set_in_cb(RGWGetDataCB *_cb) { cb = _cb; }
return ret;
}
+class StreamIntoBufferlist : public RGWGetDataCB {
+ bufferlist& bl;
+public:
+ StreamIntoBufferlist(bufferlist& _bl) : bl(_bl) {}
+ int handle_data(bufferlist& inbl, off_t bl_ofs, off_t bl_len) {
+ bl.claim_append(inbl);
+ return bl_len;
+ }
+};
+
+int RGWRESTConn::get_resource(const string& resource,
+ list<pair<string, string> > *extra_params,
+ map<string, string> *extra_headers,
+ bufferlist& bl)
+{
+ string url;
+ int ret = get_url(url);
+ if (ret < 0)
+ return ret;
+
+ list<pair<string, string> > params;
+
+ if (extra_params) {
+ list<pair<string, string> >::iterator iter = extra_params->begin();
+ for (; iter != extra_params->end(); ++iter) {
+ params.push_back(*iter);
+ }
+ }
+
+ params.push_back(pair<string, string>(RGW_SYS_PARAM_PREFIX "region", region));
+
+ StreamIntoBufferlist cb(bl);
+
+ RGWRESTStreamReadRequest req(cct, url, &cb, NULL, ¶ms);
+
+ map<string, string> headers;
+ if (extra_headers) {
+ for (map<string, string>::iterator iter = extra_headers->begin();
+ iter != extra_headers->end(); ++iter) {
+ headers[iter->first] = iter->second;
+ }
+ }
+
+ ret = req.get_resource(key, headers, resource);
+ if (ret < 0) {
+ ldout(cct, 0) << __func__ << ": get_resource() resource=" << resource << " returned ret=" << ret << dendl;
+ return ret;
+ }
+
+ string etag;
+ map<string, string> attrs;
+ return req.complete(etag, NULL, attrs);
+}
+
int get_obj(const rgw_user& uid, req_info *info /* optional */, rgw_obj& obj, bool prepend_metadata, RGWGetDataCB *cb, RGWRESTStreamReadRequest **req);
int complete_request(RGWRESTStreamReadRequest *req, string& etag, time_t *mtime, map<string, string>& attrs);
+
+ int get_resource(const string& resource,
+ list<pair<string, string> > *extra_params,
+ map<string, string>* extra_headers,
+ bufferlist& bl);
};
#endif
--- /dev/null
+#include "rgw_common.h"
+#include "rgw_rados.h"
+
+
+#define dout_subsys ceph_subsys_rgw
+
+
+class RGWRemoteMetaLog {
+
+ RGWRados *store;
+
+ int num_shards;
+
+ vector<string> markers;
+
+public:
+ RGWRemoteMetaLog(RGWRados *_store) : store(_store), num_shards(0) {}
+ int init();
+};
+
+int RGWRemoteMetaLog::init()
+{
+ list<pair<string, string> > params;
+ params.push_back(make_pair("type", "metadata"));
+
+ bufferlist bl;
+ int ret = store->rest_master_conn->get_resource("/admin/log", ¶ms, NULL, bl);
+ if (ret < 0) {
+ lderr(store->ctx()) << "ERROR: failed to fetch log info from master, ret=" << ret << dendl;
+ return ret;
+ }
+
+ return 0;
+}
+
+
+
+class RGWMetadataSync {
+ RGWRados *store;
+
+ RGWRemoteMetaLog master_log;
+public:
+ RGWMetadataSync(RGWRados *_store) : store(_store), master_log(_store) {}
+
+ int init();
+
+};
+
+
+int RGWMetadataSync::init()
+{
+ if (store->is_meta_master()) {
+ return 0;
+ }
+
+ if (!store->rest_master_conn) {
+ lderr(store->ctx()) << "no REST connection to master zone" << dendl;
+ return -EIO;
+ }
+
+ int ret = master_log.init();
+ if (ret < 0) {
+ return ret;
+ }
+
+ return 0;
+}
+
+
+