riak_test/intercepts/riak_kv_get_fsm_intercepts.erl
Nick Marino f785ee78be Fix riak_kv_get_fsm intercept used by overload
The get FSM normally uses `start/4` instead of `start_link/4` now, which
caused the overload test to break. Fixed the intercept name and all is
working again now.
2016-09-07 16:57:24 -04:00

39 lines
1.4 KiB
Erlang

%% -------------------------------------------------------------------
%%
%% Copyright (c) 2015 Basho Technologies, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
%%-------------------------------------------------------------------
-module(riak_kv_get_fsm_intercepts).
-compile(export_all).
-include("intercept.hrl").
-define(M, riak_kv_get_fsm_orig).
count_start_4(From, Bucket, Key, GetOptions) ->
?I_INFO("sending start/4 through proxy"),
case ?M:start_orig(From, Bucket, Key, GetOptions) of
{error, overload} ->
?I_INFO("riak_kv_get_fsm not started due to overload.");
{ok, _} ->
gen_server:cast({global, overload_proxy}, increment_count)
end.
%% @doc simulate slow puts by adding delay to the prepare state.
slow_prepare(Atom, State) ->
timer:sleep(1000),
?M:prepare_orig(Atom, State).