rgw: new cr for simple object put

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
This commit is contained in:
Yehuda Sadeh 2018-06-29 19:16:37 -07:00
parent 0fb443aa35
commit 3bd6661082
4 changed files with 34 additions and 1 deletions

View File

@ -222,3 +222,22 @@ int RGWBucketCreateLocalCR::Request::_send_request()
return ret;
}
template<>
int RGWObjectSimplePutCR::Request::_send_request()
{
RGWDataAccess::ObjectRef obj;
int ret = params.bucket->get_object(params.key, &obj);
if (ret < 0) {
cerr << "ERROR: failed to get object: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
ret = obj->put(params.data, params.attrs);
if (ret < 0) {
cerr << "ERROR: put object returned error: " << cpp_strerror(-ret) << std::endl;
}
return 0;
}

View File

@ -2,6 +2,7 @@
#define CEPH_RGW_CR_TOOLS_H
#include "rgw_cr_rados.h"
#include "rgw_tools.h"
struct rgw_user_create_params {
@ -50,6 +51,15 @@ struct rgw_bucket_create_local_params {
using RGWBucketCreateLocalCR = RGWSimpleWriteOnlyAsyncCR<rgw_bucket_create_local_params>;
struct rgw_object_simple_put_params {
RGWDataAccess::BucketRef bucket;
rgw_obj_key key;
bufferlist data;
map<string, bufferlist> attrs;
};
using RGWObjectSimplePutCR = RGWSimpleWriteOnlyAsyncCR<rgw_object_simple_put_params>;
#endif

View File

@ -234,6 +234,7 @@ class PSSubscription : public RefCountedObject {
PSSubConfigRef sub_conf;
shared_ptr<rgw_get_bucket_info_result> get_bucket_info_result;
RGWBucketInfo *bucket_info{nullptr};
RGWDataAccessRef data_access;
public:
@ -304,7 +305,8 @@ public:
PSEnvRef _env,
PSSubConfigRef& _sub_conf) : sync_env(_sync_env),
env(_env),
sub_conf(_sub_conf) {}
sub_conf(_sub_conf),
data_access(std::make_shared<RGWDataAccess>(sync_env->store)) {}
RGWCoroutine *init_cr() {
return new InitCR(sync_env, this);

View File

@ -191,4 +191,6 @@ public:
friend class Object;
};
using RGWDataAccessRef = std::shared_ptr<RGWDataAccess>;
#endif