雲學習筆記

do_choose_write_nodes(Nodes, K, Exclude, BlackList) ->
    % Node selection algorithm:
    % 1. try to choose K nodes randomly from all the nodes which have
    %    more than ?MIN_FREE_SPACE bytes free space available and which
    %    are not excluded or blacklisted.
    % 2. if K nodes cannot be found this way, choose the K emptiest
    %    nodes which are not excluded or blacklisted.
    Primary = ([N || {N, {Free, _Total}} <- Nodes, Free > ?MIN_FREE_SPACE / 1024]
               -- (Exclude ++ BlackList)),
    if length(Primary) >= K ->
            {ok, ddfs_util:choose_random(Primary, K)};
       true ->
            Preferred = [N || {N, _} <- lists:reverse(lists:keysort(2, Nodes))],
            Secondary = lists:sublist(Preferred -- (Exclude ++ BlackList), K),
            {ok, Secondary}
    end.
 

對於這種選取方式,存在一些疑問,如一次性選取滿足條件的k個複製節點,代碼的實際執行和註釋的原理有不符的情況,且

在雲存儲中要考慮fault tolerence,如果要求複製3次兒此時條件有限的話可以先複製2次或更少,其他的採取事後補全的方式,

這段代碼不能保證選取到宣稱的數目,沒有明顯的驗證

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章