Skip to content

Commit

Permalink
using rand instead of random fixes discoproject#646
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-siddhu committed Feb 2, 2017
1 parent 007515c commit 4763ac8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion master/src/ddfs/ddfs_rebalance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ weighted_select_items(L, K) ->
weighted_select_items(_, 0, Items, _) ->
Items;
weighted_select_items(L, K, Items, Consumed) ->
P = random:uniform() * (1 - Consumed),
P = rand:uniform() * (1 - Consumed),
{Item, Weight} = weighted_choose(L, P),
Rest = lists:keydelete(Item, 1, L),
weighted_select_items(Rest, K - 1, [Item|Items], Consumed + Weight).
Expand Down
2 changes: 1 addition & 1 deletion master/src/disco_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ groupby(N, [H|_] = List, Groups) ->

-spec choose_random([T,...]) -> T.
choose_random(L) ->
lists:nth(random:uniform(length(L)), L).
lists:nth(rand:uniform(length(L)), L).

-spec choose_random(list(T), non_neg_integer()) -> list(T).
choose_random(L, N) ->
Expand Down
2 changes: 1 addition & 1 deletion master/src/job_coordinator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ retry_task(Host, _Error,
Sleep =
lists:min([FC * ?FAILED_MIN_PAUSE,
?FAILED_MAX_PAUSE])
+ random:uniform(?FAILED_PAUSE_RANDOMIZE),
+ rand:uniform(?FAILED_PAUSE_RANDOMIZE),
M = "Task ~s:~B failed on ~p, ~Bth failures so far."
" Sleeping ~B seconds before retrying.",
MArgs = [Stage, TaskId, Host, FC, round(Sleep / 1000)],
Expand Down

0 comments on commit 4763ac8

Please sign in to comment.