]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: cleanup in the LoadGen frontend.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 4 Aug 2016 15:48:11 +0000 (17:48 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Fri, 21 Oct 2016 20:57:19 +0000 (22:57 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_loadgen.cc
src/rgw/rgw_loadgen.h

index 14f63a195832979919f733c2daf7e79dc54f7da6..634afafda7dd7e19e3a6ff7f051414330671926e 100644 (file)
@@ -1,6 +1,8 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
+#include <algorithm>
+#include <sstream>
 #include <string.h>
 
 #include "rgw_loadgen.h"
@@ -25,7 +27,7 @@ int RGWLoadGenRequestEnv::sign(RGWAccessKey& access_key)
   string digest;
 
   rgw_create_s3_canonical_header(request_method.c_str(),
-                                 NULL, /* const char *content_md5 */
+                                 nullptr, /* const char *content_md5 */
                                  content_type.c_str(),
                                  date_str.c_str(),
                                  meta_map,
@@ -44,16 +46,16 @@ int RGWLoadGenRequestEnv::sign(RGWAccessKey& access_key)
   return 0;
 }
 
-int RGWLoadGenIO::write_data(const char *buf, int len)
+int RGWLoadGenIO::write_data(const char* const buf, const int len)
 {
   return len;
 }
 
-int RGWLoadGenIO::read_data(char *buf, int len)
+int RGWLoadGenIO::read_data(char* const buf, const int len)
 {
-  int read_len = MIN(left_to_read, (uint64_t)len);
+  const int read_len = std::min(left_to_read, static_cast<uint64_t>(len));
   left_to_read -= read_len;
-  return read_len;
+  return static_cast<int>(read_len);
 }
 
 void RGWLoadGenIO::flush()
@@ -92,7 +94,7 @@ void RGWLoadGenIO::init_env(CephContext *cct)
   env.set("SERVER_PORT", port_buf);
 }
 
-int RGWLoadGenIO::send_status(int status, const char *status_name)
+int RGWLoadGenIO::send_status(const int status, const char* const status_name)
 {
   return 0;
 }
@@ -107,7 +109,7 @@ int RGWLoadGenIO::complete_header()
   return 0;
 }
 
-int RGWLoadGenIO::send_content_length(uint64_t len)
+int RGWLoadGenIO::send_content_length(const uint64_t len)
 {
   return 0;
 }
index 134c222357423f10dd1ad648b025f5fe970619df..1dec5c86a5016283fafb3129ec547a1b8eb434e6 100644 (file)
@@ -4,21 +4,27 @@
 #ifndef CEPH_RGW_LOADGEN_H
 #define CEPH_RGW_LOADGEN_H
 
+#include <map>
+#include <string>
+
 #include "rgw_client_io.h"
 
 
 struct RGWLoadGenRequestEnv {
   int port;
   uint64_t content_length;
-  string content_type;
-  string request_method;
-  string uri;
-  string query_string;
-  string date_str;
+  std::string content_type;
+  std::string request_method;
+  std::string uri;
+  std::string query_string;
+  std::string date_str;
 
-  map<string, string> headers;
+  std::map<std::string, std::string> headers;
 
-  RGWLoadGenRequestEnv() : port(0), content_length(0) {}
+  RGWLoadGenRequestEnv()
+    : port(0),
+      content_length(0) {
+  }
 
   void set_date(utime_t& tm);
   int sign(RGWAccessKey& access_key);
@@ -29,26 +35,31 @@ struct RGWLoadGenRequestEnv {
 class RGWLoadGenIO : public RGWStreamIOEngine
 {
   uint64_t left_to_read;
-  RGWLoadGenRequestEnv *req;
+  RGWLoadGenRequestEnvreq;
   RGWEnv env;
+
 public:
-  void init_env(CephContext *cct);
+  explicit RGWLoadGenIO(RGWLoadGenRequestEnv* const req)
+    : left_to_read(0),
+      req(req) {
+  }
 
-  int write_data(const char *buf, int len);
+  void init_env(CephContext *cct);
   int read_data(char *buf, int len);
+  int write_data(const char *buf, int len);
 
   int send_status(int status, const char *status_name);
   int send_100_continue();
   int complete_header();
-  int complete_request();
   int send_content_length(uint64_t len);
 
-  explicit RGWLoadGenIO(RGWLoadGenRequestEnv *_re) : left_to_read(0), req(_re) {}
   void flush();
 
   RGWEnv& get_env() override {
     return env;
   }
+
+  int complete_request();
 };
 
 #endif