]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_loadgen_process.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
4 #include "common/errno.h"
5 #include "common/Throttle.h"
6 #include "common/WorkQueue.h"
9 #include "rgw_frontend.h"
10 #include "rgw_request.h"
11 #include "rgw_process.h"
12 #include "rgw_loadgen.h"
13 #include "rgw_client_io.h"
17 #define dout_subsys ceph_subsys_rgw
21 extern void signal_shutdown();
23 void RGWLoadGenProcess::checkpoint()
28 void RGWLoadGenProcess::run()
30 m_tp
.start(); /* start thread pool */
36 conf
->get_val("num_objs", 1000, &num_objs
);
39 conf
->get_val("num_buckets", 1, &num_buckets
);
41 vector
<string
> buckets(num_buckets
);
43 std::atomic
<bool> failed
= { false };
45 for (i
= 0; i
< num_buckets
; i
++) {
46 buckets
[i
] = "/loadgen";
47 string
& bucket
= buckets
[i
];
48 append_rand_alpha(cct
, bucket
, bucket
, 16);
50 /* first create a bucket */
51 gen_request("PUT", bucket
, 0, &failed
);
55 string
*objs
= new string
[num_objs
];
58 derr
<< "ERROR: bucket creation failed" << dendl
;
62 for (i
= 0; i
< num_objs
; i
++) {
64 gen_rand_alphanumeric(cct
, buf
, sizeof(buf
));
66 objs
[i
] = buckets
[i
% num_buckets
] + "/" + buf
;
69 for (i
= 0; i
< num_objs
; i
++) {
70 gen_request("PUT", objs
[i
], 4096, &failed
);
76 derr
<< "ERROR: bucket creation failed" << dendl
;
80 for (i
= 0; i
< num_objs
; i
++) {
81 gen_request("GET", objs
[i
], 4096, NULL
);
86 for (i
= 0; i
< num_objs
; i
++) {
87 gen_request("DELETE", objs
[i
], 0, NULL
);
92 for (i
= 0; i
< num_buckets
; i
++) {
93 gen_request("DELETE", buckets
[i
], 0, NULL
);
104 } /* RGWLoadGenProcess::run() */
106 void RGWLoadGenProcess::gen_request(const string
& method
,
107 const string
& resource
,
108 int content_length
, std::atomic
<bool>* fail_flag
)
110 RGWLoadGenRequest
* req
=
111 new RGWLoadGenRequest(store
->get_new_req_id(), method
, resource
,
112 content_length
, fail_flag
);
113 dout(10) << "allocated request req=" << hex
<< req
<< dec
<< dendl
;
116 } /* RGWLoadGenProcess::gen_request */
118 void RGWLoadGenProcess::handle_request(const DoutPrefixProvider
*dpp
, RGWRequest
* r
)
120 RGWLoadGenRequest
* req
= static_cast<RGWLoadGenRequest
*>(r
);
122 RGWLoadGenRequestEnv env
;
124 utime_t tm
= ceph_clock_now();
127 env
.content_length
= req
->content_length
;
128 env
.content_type
= "binary/octet-stream";
129 env
.request_method
= req
->method
;
130 env
.uri
= req
->resource
;
132 env
.sign(dpp
, access_key
);
134 RGWLoadGenIO
real_client_io(&env
);
135 RGWRestfulIO
client_io(cct
, &real_client_io
);
136 ActiveRateLimiter
ratelimit(cct
);
137 int ret
= process_request(store
, rest
, req
, uri_prefix
,
138 *auth_registry
, &client_io
, olog
,
139 null_yield
, nullptr, nullptr, nullptr,
140 ratelimit
.get_active());
142 /* we don't really care about return code */
143 dout(20) << "process_request() returned " << ret
<< dendl
;
145 if (req
->fail_flag
) {
151 } /* RGWLoadGenProcess::handle_request */