Change C210's sleep time to be proportional/ranked to member's rank

This commit is contained in:
Scott Lystig Fritchie 2014-11-04 18:02:10 +09:00
parent c0ef199c6f
commit a2f087181e

View file

@ -745,10 +745,10 @@ react_to_env_C200(Retries, P_latest, S) ->
end,
react_to_env_C210(Retries, S).
react_to_env_C210(Retries, S) ->
react_to_env_C210(Retries, #ch_mgr{myflu=MyFLU, proj=Proj} = S) ->
put(react, [c210|get(react)]),
%% TODO: implement the ranked sleep thingie?
timer:sleep(100),
sleep_ranked_order(10, 100, MyFLU, Proj#projection.all_members),
react_to_env_C220(Retries, S).
react_to_env_C220(Retries, S) ->
@ -926,6 +926,14 @@ find_common_prefix([H|L1], [H|L2]) ->
find_common_prefix(_, _) ->
[].
sleep_ranked_order(MinSleep, MaxSleep, FLU, FLU_list) ->
Front = lists:takewhile(fun(X) -> X /=FLU end, FLU_list),
Index = length(Front) + 1,
NumNodes = length(FLU_list),
SleepIndex = NumNodes - Index,
SleepChunk = MaxSleep div NumNodes,
timer:sleep(MinSleep + (SleepChunk * SleepIndex)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
perhaps_call_t(S, Partitions, FLU, DoIt) ->