if (ret < 0)
return ret;
- RGWBucketInfo src_bucket_info, dest_bucket_info;
-
/* get buckets info (source and dest) */
ret = store->get_bucket_info(s->obj_ctx, src_bucket_name, src_bucket_info, NULL);
src_obj.init(src_bucket, src_object);
dst_obj.init(dest_bucket, dest_object);
store->set_atomic(s->obj_ctx, src_obj);
+#if 0
+
+ if ((dest_bucket_info.region.empty() && !store->region.is_master) ||
+ (dest_bucket_info.region != store->region.name)) {
+
+ map<string, bufferlist> src_attrs;
+
+ int ret = get_obj_attrs(store, s, src_obj, src_attrs
+ uint64_t *obj_size, RGWObjVersionTracker *objv_tracker)
+
+ int ret = store->rest_conn->put_obj(s->user.user_id, dst_obj,
+ if (ret < 0)
+ return ret;
+ }
+#endif
store->set_atomic(s->obj_ctx, dst_obj);
ret = store->copy_obj(s->obj_ctx,
+ s->user.user_id,
dst_obj,
src_obj,
+ dest_bucket_info,
&mtime,
mod_ptr,
unmod_ptr,
string dest_object;
time_t mtime;
bool replace_attrs;
+ RGWBucketInfo src_bucket_info;
+ RGWBucketInfo dest_bucket_info;
+
int init_common();
* Returns: 0 on success, -ERR# otherwise.
*/
int RGWRados::copy_obj(void *ctx,
+ const string& user_id,
rgw_obj& dest_obj,
rgw_obj& src_obj,
+ RGWBucketInfo& dest_bucket_info,
time_t *mtime,
const time_t *mod_ptr,
const time_t *unmod_ptr,
}
}
+
+ if ((dest_bucket_info.region.empty() && !region.is_master) ||
+ (dest_bucket_info.region != region.name)) {
+ /* dest is in a different region, copy it there */
+
+ map<string, bufferlist> src_attrs;
+
+ int ret = rest_conn->put_obj(user_id, dest_obj, astate->size, NULL);
+ if (ret < 0)
+ return ret;
+ }
+
if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */
return copy_obj_data(ctx, handle, end, dest_obj, src_obj, mtime, attrset, category, ptag, err);
}
* err: stores any errors resulting from the get of the original object
* Returns: 0 on success, -ERR# otherwise.
*/
- virtual int copy_obj(void *ctx, rgw_obj& dest_obj,
+ virtual int copy_obj(void *ctx,
+ const string& user_id,
+ rgw_obj& dest_obj,
rgw_obj& src_obj,
+ RGWBucketInfo& dest_bucket_info,
time_t *mtime,
const time_t *mod_ptr,
const time_t *unmod_ptr,
return rgw_http_error_to_errno(status);
}
+
+int RGWRESTClient::put_obj(RGWAccessKey& key, rgw_obj& obj, uint64_t obj_size, void (*get_data)(uint64_t ofs, uint64_t len, bufferlist& bl, void *))
+{
+ string resource = obj.bucket.name + "/" + obj.object;
+ string new_url = url + "/" + resource;
+ string date_str;
+ get_new_date_str(cct, date_str);
+
+ RGWEnv new_env;
+ req_info new_info(cct, &new_env);
+
+ new_env.set("HTTP_DATE", date_str.c_str());
+
+ new_info.script_uri = resource;
+ new_info.request_uri = resource;
+
+ int r = process("PUT", new_url.c_str());
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
int execute(RGWAccessKey& key, const char *method, const char *resource);
int forward_request(RGWAccessKey& key, req_info& info, size_t max_response, bufferlist *inbl, bufferlist *outbl);
+
+ int put_obj(RGWAccessKey& key, rgw_obj& obj, uint64_t obj_size, void (*get_data)(uint64_t ofs, uint64_t len, bufferlist& bl, void *));
};
return client.forward_request(key, info, max_response, inbl, outbl);
}
+int RGWRegionConnection::put_obj(const string& uid, rgw_obj& obj, uint64_t obj_size, void (*get_data)(uint64_t ofs, uint64_t len, bufferlist& bl, void *))
+{
+ string url;
+ int ret = get_url(url);
+ if (ret < 0)
+ return ret;
+
+ list<pair<string, string> > params;
+ params.push_back(make_pair<string, string>(RGW_SYS_PARAM_PREFIX "uid", uid));
+ params.push_back(make_pair<string, string>(RGW_SYS_PARAM_PREFIX "region", region));
+ RGWRESTClient client(cct, url, NULL, ¶ms);
+ return client.put_obj(key, obj, obj_size, get_data);
+}
+
int get_url(string& endpoint);
int forward(const string& uid, req_info& info, size_t max_response, bufferlist *inbl, bufferlist *outbl);
+ int put_obj(const string& uid, rgw_obj& obj, uint64_t obj_size, void (*get_data)(uint64_t ofs, uint64_t len, bufferlist& bl, void *));
};
#endif