From 744f3844fa6ae0084824441e08a6de04b669cdbb Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 15 Jan 2016 11:50:39 -0800 Subject: [PATCH] rgw: add a timelog add operation cr Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_cr_rados.cc | 39 ++++++++++++++++++++++++++++++++++++++- src/rgw/rgw_cr_rados.h | 17 +++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index 83b472cd7809e..761acfee5aa37 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -218,7 +218,9 @@ RGWRadosSetOmapKeysCR::RGWRadosSetOmapKeysCR(RGWRados *_store, RGWRadosSetOmapKeysCR::~RGWRadosSetOmapKeysCR() { - cn->put(); + if (cn) { + cn->put(); + } } int RGWRadosSetOmapKeysCR::send_request() @@ -573,3 +575,38 @@ int RGWContinuousLeaseCR::operate() } return 0; } + +RGWRadosTimelogAddCR::RGWRadosTimelogAddCR(RGWRados *_store, const string& _oid, + const cls_log_entry& entry) : RGWSimpleCoroutine(_store->ctx()), + store(_store), + oid(_oid), cn(NULL) +{ + stringstream& s = set_description(); + s << "timelog add entry oid=" << oid << "entry={id=" << entry.id << ", section=" << entry.section << ", name=" << entry.name << "}"; + entries.push_back(entry); +} + +RGWRadosTimelogAddCR::~RGWRadosTimelogAddCR() +{ + if (cn) { + cn->put(); + } +} + +int RGWRadosTimelogAddCR::send_request() +{ + set_status() << "sending request"; + + cn = stack->create_completion_notifier(); + cn->get(); + return store->time_log_add(oid, entries, cn->completion(), true); +} + +int RGWRadosTimelogAddCR::request_complete() +{ + int r = cn->completion()->get_return_value(); + + set_status() << "request complete; ret=" << r; + + return r; +} diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index 6f6c47438a45c..52722578aff31 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -869,5 +869,22 @@ public: } }; +class RGWRadosTimelogAddCR : public RGWSimpleCoroutine { + RGWRados *store; + list entries; + + string oid; + + RGWAioCompletionNotifier *cn; + +public: + RGWRadosTimelogAddCR(RGWRados *_store, const string& _oid, + const cls_log_entry& entry); + ~RGWRadosTimelogAddCR(); + + int send_request(); + int request_complete(); +}; + #endif -- 2.39.5