`
jias_je
  • 浏览: 40565 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

云学习笔记

 
阅读更多
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次或更少,其他的采取事后补全的方式,

这段代码不能保证选取到宣称的数目,没有明显的验证

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics