3131 http_host ,
3232 http_port ,
3333 bucket ,
34- max_key
34+ max_key ,
35+ pb_timeout ,
36+ http_timeout
3537 }).
3638
3739
@@ -55,6 +57,8 @@ new(Id) ->
5557
5658 Bucket = basho_bench_config :get (riakc_pb_bucket , <<" mybucket" >>),
5759 MaxKey = basho_bench_config :get (enforce_keyrange , undefined ),
60+ PBTimeout = basho_bench_config :get (pb_timeout_general , 30 * 1000 ),
61+ HTTPTimeout = basho_bench_config :get (http_timeout_general , 30 * 1000 ),
5862
5963 % % Choose the target node using our ID as a modulus
6064 HTTPTargets = basho_bench_config :normalize_ips (HTTPIPs , HTTPPort ),
@@ -73,7 +77,9 @@ new(Id) ->
7377 http_host = HTTPTargetIp ,
7478 http_port = HTTPTargetPort ,
7579 bucket = Bucket ,
76- max_key = MaxKey }};
80+ max_key = MaxKey ,
81+ pb_timeout = PBTimeout ,
82+ http_timeout = HTTPTimeout }};
7783 {error , Reason2 } ->
7884 ? FAIL_MSG (" Failed to connect riakc_pb_socket to ~p port ~p : ~p \n " ,
7985 [PBTargetIp , PBTargetPort , Reason2 ])
@@ -84,7 +90,7 @@ run(get_pb, KeyGen, _ValueGen, State) ->
8490 Pid = State # state .pb_pid ,
8591 Bucket = State # state .bucket ,
8692 Key = to_binary (KeyGen ()),
87- case riakc_pb_socket :get (Pid , Bucket , Key ) of
93+ case riakc_pb_socket :get (Pid , Bucket , Key , State # state . pb_timeout ) of
8894 {ok , _Obj } ->
8995 {ok , State };
9096 {error , notfound } ->
@@ -108,7 +114,7 @@ run({put_pb, N}, KeyGen, ValueGen, State) ->
108114 Robj2 = riakc_obj :update_metadata (Robj1 , MetaData ),
109115
110116 % % Write the object...
111- case riakc_pb_socket :put (Pid , Robj2 ) of
117+ case riakc_pb_socket :put (Pid , Robj2 , State # state . pb_timeout ) of
112118 ok ->
113119 {ok , State };
114120 {error , Reason } ->
@@ -124,7 +130,7 @@ run({query_http, MaxN}, KeyGen, _ValueGen, State) ->
124130 URL = io_lib :format (" http://~s :~p /buckets/~s /index/field1_int/~p /~p " ,
125131 [Host , Port , Bucket , StartKey , EndKey ]),
126132
127- case json_get (URL ) of
133+ case json_get (URL , State ) of
128134 {ok , {struct , Proplist }} ->
129135 case {proplists :get_value (<<" keys" >>, Proplist ), MaxKey } of
130136 {Results , _ } when length (Results ) == N ->
@@ -170,7 +176,7 @@ run({query_mr, 1}, KeyGen, _ValueGen, State) ->
170176 ]
171177 }
172178 " ],
173- case json_post (URL , Body ) of
179+ case json_post (URL , Body , State ) of
174180 {ok , Results } when length (Results ) == 1 ->
175181 {ok , State };
176182 {ok , Results } ->
@@ -206,7 +212,7 @@ run({query_mr, MaxN}, KeyGen, _ValueGen, State) ->
206212 ]
207213 }
208214 " ],
209- case {json_post (URL , Body ), MaxKey } of
215+ case {json_post (URL , Body , State ), MaxKey } of
210216 {{ok , Results }, _ } when length (Results ) == N ->
211217 {ok , State };
212218 {{ok , Results }, undefined } ->
@@ -238,7 +244,7 @@ run({query_mr2, 1}, KeyGen, _ValueGen, State) ->
238244 \" query\" :[]
239245 }
240246 " ],
241- case json_post (URL , Body ) of
247+ case json_post (URL , Body , State ) of
242248 {ok , Results } when length (Results ) == 1 ->
243249 {ok , State };
244250 {ok , Results } ->
@@ -265,7 +271,7 @@ run({query_mr2, MaxN}, KeyGen, _ValueGen, State) ->
265271 \" query\" :[]
266272 }
267273 " ],
268- case {json_post (URL , Body ), MaxKey } of
274+ case {json_post (URL , Body , State ), MaxKey } of
269275 {{ok , Results }, _ } when length (Results ) == N ->
270276 {ok , State };
271277 {{ok , Results }, undefined } ->
@@ -286,7 +292,8 @@ run({query_pb, 1}, KeyGen, _ValueGen, State) ->
286292 Pid = State # state .pb_pid ,
287293 Bucket = State # state .bucket ,
288294 Key = to_integer (KeyGen ()),
289- case riakc_pb_socket :get_index (Pid , Bucket , <<" field1_int" >>, to_binary (Key )) of
295+ case riakc_pb_socket :get_index (Pid , Bucket , <<" field1_int" >>,
296+ to_binary (Key ), State # state .pb_timeout ) of
290297 {ok , Results } when length (Results ) == 1 ->
291298 {ok , State };
292299 {ok , Results } ->
@@ -301,7 +308,8 @@ run({query_pb, MaxN}, KeyGen, _ValueGen, State) ->
301308 Bucket = State # state .bucket ,
302309 {StartKey , EndKey , MaxKey , N } = expected_n (to_integer (KeyGen ()), State # state .max_key , MaxN ),
303310 case {riakc_pb_socket :get_index (Pid , Bucket , <<" field1_int" >>,
304- to_binary (StartKey ), to_binary (EndKey )), MaxKey } of
311+ to_binary (StartKey ), to_binary (EndKey ),
312+ State # state .pb_timeout ), MaxKey } of
305313 {{ok , Results }, _ } when length (Results ) == N ->
306314 {ok , State };
307315 {{ok , Results }, undefined } ->
@@ -354,19 +362,21 @@ to_list(I) when is_integer(I) ->
354362choose (N , L ) ->
355363 lists :nth ((N rem length (L ) + 1 ), L ).
356364
357- json_get (Url ) ->
358- Response = ibrowse :send_req (lists :flatten (Url ), [], get ),
365+ json_get (Url , State ) ->
366+ Response = ibrowse :send_req (lists :flatten (Url ), [], get ,
367+ [], [], State # state .pb_timeout ),
359368 case Response of
360369 {ok , " 200" , _ , Body } ->
361370 {ok , mochijson2 :decode (Body )};
362371 Other ->
363372 {error , Other }
364373 end .
365374
366- json_post (Url , Payload ) ->
375+ json_post (Url , Payload , State ) ->
367376 Headers = [{" Content-Type" , " application/json" }],
368377 Response = ibrowse :send_req (lists :flatten (Url ), Headers ,
369- post , lists :flatten (Payload )),
378+ post , lists :flatten (Payload ),
379+ [], State # state .pb_timeout ),
370380 case Response of
371381 {ok , " 200" , _ , Body } ->
372382 {ok , mochijson2 :decode (Body )};
0 commit comments