}
virtual int complete_request() = 0; /* XXX signature likely changing */
+}; /* RGWClient IO */
+
+
+class RGWClientIOAccounter {
+public:
+ virtual ~RGWClientIOAccounter() {}
+
+ virtual void set_account(bool enabled) = 0;
virtual uint64_t get_bytes_sent() const = 0;
virtual uint64_t get_bytes_received() const = 0;
-}; /* RGWClient IO */
+};
class RGWStreamIOEngine : public RGWClientIO {
int read(char *buf, int max, int *actual);
};
+
/* HTTP IO: compatibility layer */
-class RGWStreamIO : public RGWStreamIOEngine {
+class RGWStreamIO : public RGWStreamIOEngine,
+ public RGWClientIOAccounter {
bool _account;
size_t bytes_sent;
size_t bytes_received;
std::string grab_aws4_sha256_hash();
- void set_account(bool _accnt) {
+ void set_account(bool _accnt) override {
_account = _accnt;
}
/* request interface */
- class RGWLibIO : public RGWClientIO
+ class RGWLibIO : public RGWClientIO,
+ public RGWClientIOAccounter
{
RGWUserInfo user_info;
public:
return 0;
};
+ void set_account(bool) override {
+ return;
+ }
+
uint64_t get_bytes_sent() const override {
return 0;
}
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 */
string p = payer.to_str();
rgw_usage_log_entry entry(u, p, bucket_name);
- uint64_t bytes_sent = s->cio->get_bytes_sent();
- uint64_t bytes_received = s->cio->get_bytes_received();
+ uint64_t bytes_sent = ACCOUNTING_IO(s)->get_bytes_sent();
+ uint64_t bytes_received = ACCOUNTING_IO(s)->get_bytes_received();
rgw_usage_data data(bytes_sent, bytes_received);
entry.object_owner = s->object_acl->get_owner().get_id();
entry.bucket_owner = s->bucket_owner.get_id();
- uint64_t bytes_sent = s->cio->get_bytes_sent();
- uint64_t bytes_received = s->cio->get_bytes_received();
+ uint64_t bytes_sent = ACCOUNTING_IO(s)->get_bytes_sent();
+ uint64_t bytes_received = ACCOUNTING_IO(s)->get_bytes_received();
entry.time = s->time;
entry.total_time = ceph_clock_now(s->cct) - s->time;