diff options
author | Babu Shanmugam <anbu@enovance.com> | 2013-05-21 10:41:05 +0530 |
---|---|---|
committer | Babu Shanmugam <anbu@enovance.com> | 2013-05-21 10:41:05 +0530 |
commit | 047d32a8fad30dfc9a1b746f74391c41b2a34007 (patch) | |
tree | 4e7b015c5e378c0bdb547352f6142722a28aef77 | |
parent | 947e1331e5924b04323d614afb9b21b7d5993c7f (diff) | |
download | ceph-047d32a8fad30dfc9a1b746f74391c41b2a34007.tar.gz |
Added send_response implementation for MDLOG and BILOG list APIs so that periodic flushing can happend in execute()
Signed-off-by: Babu Shanmugam <anbu@enovance.com>
-rw-r--r-- | src/cls/log/cls_log.cc | 2 | ||||
-rw-r--r-- | src/rgw/rgw_rest_log.cc | 35 | ||||
-rw-r--r-- | src/rgw/rgw_rest_log.h | 16 |
3 files changed, 44 insertions, 9 deletions
diff --git a/src/cls/log/cls_log.cc b/src/cls/log/cls_log.cc index ff134d12001..e8196660bf5 100644 --- a/src/cls/log/cls_log.cc +++ b/src/cls/log/cls_log.cc @@ -117,8 +117,6 @@ static int cls_log_list(cls_method_context_t hctx, bufferlist *in, bufferlist *o #define MAX_ENTRIES 1000 size_t max_entries = op.max_entries; - if (op.from_time == op.to_time) - max_entries = 1; if (!max_entries || max_entries > MAX_ENTRIES) max_entries = MAX_ENTRIES; diff --git a/src/rgw/rgw_rest_log.cc b/src/rgw/rgw_rest_log.cc index c2c954b3c8e..07bd813f1e7 100644 --- a/src/rgw/rgw_rest_log.cc +++ b/src/rgw/rgw_rest_log.cc @@ -12,6 +12,7 @@ * */ #include "common/ceph_json.h" +#include "common/strtol.h" #include "rgw_rest.h" #include "rgw_op.h" #include "rgw_rest_s3.h" @@ -69,14 +70,26 @@ void RGWOp_MDLog_List::execute() { iter != entries.end(); ++iter) { cls_log_entry& entry = *iter; store->meta_mgr->dump_log_entry(entry, s->formatter); + s->formatter->flush(out_stream); } } while (truncated); s->formatter->close_section(); + s->formatter->flush(out_stream); http_ret = 0; } +void RGWOp_MDLog_List::send_response() { + set_req_state_err(s, http_ret); + dump_errno(s); + end_header(s); + std::string outs(out_stream.str()); + if (!outs.empty()) { + s->cio->write(outs.c_str(), outs.size()); + } +} + void RGWOp_MDLog_Delete::execute() { string st = s->args.get("start-time"), et = s->args.get("end-time"); @@ -108,7 +121,7 @@ void RGWOp_BILog_List::execute() { marker = s->args.get("marker"), max_entries_str = s->args.get("max-entries"); RGWBucketInfo bucket_info; - int max_entries = -1; + int max_entries; if (bucket_name.empty()) { dout(5) << "ERROR: bucket not specified" << dendl; @@ -122,15 +135,15 @@ void RGWOp_BILog_List::execute() { return; } - s->formatter->open_array_section("entries"); bool truncated; int count = 0; - istringstream ss(max_entries_str); + string err; - ss >> max_entries; - if (max_entries < 0) + max_entries = strict_strtol(max_entries_str.c_str(), 10, &err); + if (!err.empty()) max_entries = 1000; + s->formatter->open_array_section("entries"); do { list<rgw_bi_log_entry> entries; http_ret = store->list_bi_log_entries(bucket_info.bucket, @@ -148,13 +161,25 @@ void RGWOp_BILog_List::execute() { encode_json("entry", entry, s->formatter); marker = entry.id; + s->formatter->flush(out_stream); } } while (truncated && count < max_entries); s->formatter->close_section(); + s->formatter->flush(out_stream); http_ret = 0; } +void RGWOp_BILog_List::send_response() { + set_req_state_err(s, http_ret); + dump_errno(s); + end_header(s); + std::string outs(out_stream.str()); + if (!outs.empty()) { + s->cio->write(outs.c_str(), outs.size()); + } +} + void RGWOp_BILog_Delete::execute() { string bucket_name = s->args.get("bucket"), start_marker = s->args.get("start-marker"), diff --git a/src/rgw/rgw_rest_log.h b/src/rgw/rgw_rest_log.h index fae8b1095c1..b3ef0690501 100644 --- a/src/rgw/rgw_rest_log.h +++ b/src/rgw/rgw_rest_log.h @@ -14,7 +14,9 @@ #ifndef CEPH_RGW_REST_LOG_H #define CEPH_RGW_REST_LOG_H -class RGWOp_BILog_List : public RGWRESTOp { +class RGWOp_BILog_List : public RGWOp { + int http_ret; + std::ostringstream out_stream; public: RGWOp_BILog_List() {} ~RGWOp_BILog_List() {} @@ -22,6 +24,10 @@ public: int check_caps(RGWUserCaps& caps) { return caps.check_cap("bilog", RGW_CAP_READ); } + int verify_permission() { + return check_caps(s->user.caps); + } + virtual void send_response(); void execute(); virtual const char *name() { return "list bucket index log"; @@ -42,7 +48,9 @@ public: } }; -class RGWOp_MDLog_List : public RGWRESTOp { +class RGWOp_MDLog_List : public RGWOp { + int http_ret; + std::ostringstream out_stream; public: RGWOp_MDLog_List() {} ~RGWOp_MDLog_List() {} @@ -50,7 +58,11 @@ public: int check_caps(RGWUserCaps& caps) { return caps.check_cap("mdlog", RGW_CAP_READ); } + int verify_permission() { + return check_caps(s->user.caps); + } void execute(); + virtual void send_response(); virtual const char *name() { return "list metadata log"; } |