]>
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
19 extern void signal_shutdown();
21 void RGWLoadGenProcess::checkpoint()
26 void RGWLoadGenProcess::run()
28 m_tp
.start(); /* start thread pool */
34 conf
->get_val("num_objs", 1000, &num_objs
);
37 conf
->get_val("num_buckets", 1, &num_buckets
);
39 vector
<string
> buckets(num_buckets
);
41 std::atomic
<bool> failed
= { false };
43 for (i
= 0; i
< num_buckets
; i
++) {
44 buckets
[i
] = "/loadgen";
45 string
& bucket
= buckets
[i
];
46 append_rand_alpha(cct
, bucket
, bucket
, 16);
48 /* first create a bucket */
49 gen_request("PUT", bucket
, 0, &failed
);
53 string
*objs
= new string
[num_objs
];
56 derr
<< "ERROR: bucket creation failed" << dendl
;
60 for (i
= 0; i
< num_objs
; i
++) {
62 gen_rand_alphanumeric(cct
, buf
, sizeof(buf
));
64 objs
[i
] = buckets
[i
% num_buckets
] + "/" + buf
;
67 for (i
= 0; i
< num_objs
; i
++) {
68 gen_request("PUT", objs
[i
], 4096, &failed
);
74 derr
<< "ERROR: bucket creation failed" << dendl
;
78 for (i
= 0; i
< num_objs
; i
++) {
79 gen_request("GET", objs
[i
], 4096, NULL
);
84 for (i
= 0; i
< num_objs
; i
++) {
85 gen_request("DELETE", objs
[i
], 0, NULL
);
90 for (i
= 0; i
< num_buckets
; i
++) {
91 gen_request("DELETE", buckets
[i
], 0, NULL
);
102 } /* RGWLoadGenProcess::run() */
104 void RGWLoadGenProcess::gen_request(const string
& method
,
105 const string
& resource
,
106 int content_length
, std::atomic
<bool>* fail_flag
)
108 RGWLoadGenRequest
* req
=
109 new RGWLoadGenRequest(store
->getRados()->get_new_req_id(), method
, resource
,
110 content_length
, fail_flag
);
111 dout(10) << "allocated request req=" << hex
<< req
<< dec
<< dendl
;
114 } /* RGWLoadGenProcess::gen_request */
116 void RGWLoadGenProcess::handle_request(const DoutPrefixProvider
*dpp
, RGWRequest
* r
)
118 RGWLoadGenRequest
* req
= static_cast<RGWLoadGenRequest
*>(r
);
120 RGWLoadGenRequestEnv env
;
122 utime_t tm
= ceph_clock_now();
125 env
.content_length
= req
->content_length
;
126 env
.content_type
= "binary/octet-stream";
127 env
.request_method
= req
->method
;
128 env
.uri
= req
->resource
;
130 env
.sign(dpp
, access_key
);
132 RGWLoadGenIO
real_client_io(&env
);
133 RGWRestfulIO
client_io(cct
, &real_client_io
);
135 int ret
= process_request(store
, rest
, req
, uri_prefix
,
136 *auth_registry
, &client_io
, olog
,
137 null_yield
, nullptr, nullptr, nullptr);
139 /* we don't really care about return code */
140 dout(20) << "process_request() returned " << ret
<< dendl
;
142 if (req
->fail_flag
) {
148 } /* RGWLoadGenProcess::handle_request */