rgw: rename and split STREAM_IO into RESTFUL_IO and ACCOUNTING_IO.

Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
This commit is contained in:
Radoslaw Zarzynski 2016-08-17 18:48:34 +02:00
parent 6db8699f26
commit e524c586fd
5 changed files with 25 additions and 25 deletions

View File

@ -275,7 +275,7 @@ void rgw_create_s3_v4_canonical_request(struct req_state *s, const string& canon
request_payload_hash = "UNSIGNED-PAYLOAD";
} else {
if (s->aws4_auth_needs_complete) {
request_payload_hash = STREAM_IO(s)->grab_aws4_sha256_hash();
request_payload_hash = RESTFUL_IO(s)->grab_aws4_sha256_hash();
} else {
if (s->aws4_auth_streaming_mode) {
request_payload_hash = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD";

View File

@ -213,6 +213,17 @@ public:
}; /* RGWRestfulIO */
/* Type conversions to work around lack of req_state type hierarchy matching
* (e.g.) REST backends (may be replaced w/dynamic typed req_state). */
static inline RGWRestfulIO* RESTFUL_IO(struct req_state* s) {
return static_cast<RGWRestfulIO*>(s->cio);
}
static inline RGWClientIOAccounter* ACCOUNTING_IO(struct req_state* s) {
return dynamic_cast<RGWClientIOAccounter*>(s->cio);
}
class RGWClientIOStreamBuf : public std::streambuf {
protected:
RGWRestfulIO &rio;

View File

@ -179,10 +179,6 @@ void rgw_log_usage_finalize()
usage_logger = NULL;
}
static inline RGWClientIOAccounter* ACCOUNTING_IO(struct req_state* s) {
return dynamic_cast<RGWClientIOAccounter*>(s->cio);
}
static void log_usage(struct req_state *s, const string& op_name)
{
if (s->system_request) /* don't log system user operations */

View File

@ -280,7 +280,7 @@ static void dump_status(struct req_state *s, int status,
{
s->formatter->set_status(status, status_name);
try {
STREAM_IO(s)->send_status(status, status_name);
RESTFUL_IO(s)->send_status(status, status_name);
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: s->cio->send_status() returned err="
<< e.value() << dendl;
@ -375,7 +375,7 @@ void dump_header(struct req_state* const s,
const boost::string_ref& val)
{
try {
STREAM_IO(s)->send_header(name, val);
RESTFUL_IO(s)->send_header(name, val);
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: s->cio->send_header() returned err="
<< e.value() << dendl;
@ -414,7 +414,7 @@ void dump_header(struct req_state* const s,
void dump_content_length(struct req_state* const s, const uint64_t len)
{
try {
STREAM_IO(s)->send_content_length(len);
RESTFUL_IO(s)->send_content_length(len);
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: s->cio->send_content_length() returned err="
<< e.value() << dendl;
@ -425,9 +425,9 @@ void dump_content_length(struct req_state* const s, const uint64_t len)
static void dump_chunked_encoding(struct req_state* const s)
{
try {
STREAM_IO(s)->send_chunked_transfer_encoding();
RESTFUL_IO(s)->send_chunked_transfer_encoding();
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: STREAM_IO(s)->send_chunked_transfer_encoding()"
ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->send_chunked_transfer_encoding()"
<< " returned err=" << e.what() << dendl;
}
}
@ -707,13 +707,13 @@ void end_header(struct req_state* s, RGWOp* op, const char *content_type,
}
try {
STREAM_IO(s)->complete_header();
RESTFUL_IO(s)->complete_header();
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: STREAM_IO(s)->complete_header() returned err="
ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->complete_header() returned err="
<< e.value() << dendl;
}
STREAM_IO(s)->set_account(true);
ACCOUNTING_IO(s)->set_account(true);
rgw_flush_formatter_and_reset(s, s->formatter);
}
@ -785,7 +785,7 @@ void abort_early(struct req_state *s, RGWOp *op, int err_no,
* x-amz-error-detail-Key: foo
*/
end_header(s, op, NULL, error_content.size(), false, true);
STREAM_IO(s)->send_body(error_content.c_str(), error_content.size());
RESTFUL_IO(s)->send_body(error_content.c_str(), error_content.size());
} else {
end_header(s, op);
}
@ -797,9 +797,9 @@ void abort_early(struct req_state *s, RGWOp *op, int err_no,
void dump_continue(struct req_state * const s)
{
try {
STREAM_IO(s)->send_100_continue();
RESTFUL_IO(s)->send_100_continue();
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: STREAM_IO(s)->send_100_continue() returned err="
ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->send_100_continue() returned err="
<< e.value() << dendl;
}
}
@ -833,7 +833,7 @@ int dump_body(struct req_state* const s,
const std::size_t len)
{
try {
return STREAM_IO(s)->send_body(buf, len);
return RESTFUL_IO(s)->send_body(buf, len);
} catch (RGWRestfulIOEngine::Exception& e) {
return e.value();
}
@ -854,7 +854,7 @@ int recv_body(struct req_state* const s,
const std::size_t max)
{
try {
return STREAM_IO(s)->recv_body(buf, max, s->aws4_auth_needs_complete);
return RESTFUL_IO(s)->recv_body(buf, max, s->aws4_auth_needs_complete);
} catch (RGWRestfulIOEngine::Exception& e) {
return e.value();
}

View File

@ -30,13 +30,6 @@ extern void rgw_flush_formatter(struct req_state *s,
extern int rgw_rest_read_all_input(struct req_state *s, char **data, int *plen,
int max_len);
/* type conversions to work around lack of req_state type
* hierarchy matching (e.g.) REST backends (may be replaced w/dynamic
* typed req_state) */
static inline RGWRestfulIO* STREAM_IO(struct req_state* s) {
return static_cast<RGWRestfulIO*>(s->cio);
}
template <class T>
int rgw_rest_get_json_input(CephContext *cct, req_state *s, T& out,
int max_len, bool *empty)