Hey, I think this is finally working, hooray!
This commit is contained in:
parent
258bce84d1
commit
c0ef199c6f
2 changed files with 18 additions and 27 deletions
|
@ -105,8 +105,7 @@ init({MyName, All_list, MyFLUPid}) ->
|
||||||
RunEnv = [%% {seed, Seed},
|
RunEnv = [%% {seed, Seed},
|
||||||
{seed, now()},
|
{seed, now()},
|
||||||
{network_partitions, []},
|
{network_partitions, []},
|
||||||
%% {old_threshold, OldThreshold},
|
{network_islands, []},
|
||||||
%% {no_partition_threshold, NoPartitionThreshold},
|
|
||||||
{up_nodes, not_init_yet}],
|
{up_nodes, not_init_yet}],
|
||||||
BestProj = make_initial_projection(MyName, All_list, All_list,
|
BestProj = make_initial_projection(MyName, All_list, All_list,
|
||||||
[], [{author_proc, init_best}]),
|
[], [{author_proc, init_best}]),
|
||||||
|
@ -458,28 +457,15 @@ calc_up_nodes(#ch_mgr{name=MyName, proj=Proj, runenv=RunEnv1}=S) ->
|
||||||
|
|
||||||
calc_up_nodes(MyName, AllMembers, RunEnv1) ->
|
calc_up_nodes(MyName, AllMembers, RunEnv1) ->
|
||||||
%% Seed1 = proplists:get_value(seed, RunEnv1),
|
%% Seed1 = proplists:get_value(seed, RunEnv1),
|
||||||
{Partitions2, _Islands} = machi_partition_simulator:get(AllMembers),
|
{Partitions2, Islands2} = machi_partition_simulator:get(AllMembers),
|
||||||
catch put(react, [{partitions,Partitions2},{islands,_Islands}|get(react)]),
|
catch put(react, [{partitions,Partitions2},{islands,Islands2}|get(react)]),
|
||||||
UpNodes = lists:sort(
|
UpNodes = lists:sort(
|
||||||
[Node || Node <- AllMembers,
|
[Node || Node <- AllMembers,
|
||||||
not lists:member({MyName, Node}, Partitions2),
|
not lists:member({MyName, Node}, Partitions2),
|
||||||
not lists:member({Node, MyName}, Partitions2)]),
|
not lists:member({Node, MyName}, Partitions2)]),
|
||||||
%% UpViaIslands = lists:sort(lists:flatten([Island ||
|
|
||||||
%% Island <- _Islands,
|
|
||||||
%% lists:member(MyName, Island)])),
|
|
||||||
%% try
|
|
||||||
%% case get(hack_island) of
|
|
||||||
%% undefined ->
|
|
||||||
%% ok;
|
|
||||||
%% _ ->
|
|
||||||
%% UpNodes = UpViaIslands
|
|
||||||
%% end
|
|
||||||
%% catch _:_ ->
|
|
||||||
%% exit({damn, MyName, UpNodes, Partitions2, _Islands})
|
|
||||||
%% end,
|
|
||||||
RunEnv2 = replace(RunEnv1,
|
RunEnv2 = replace(RunEnv1,
|
||||||
[%% {seed, Seed2},
|
[{network_partitions, Partitions2},
|
||||||
{network_partitions, Partitions2},
|
{network_islands, Islands2},
|
||||||
{up_nodes, UpNodes}]),
|
{up_nodes, UpNodes}]),
|
||||||
{UpNodes, Partitions2, RunEnv2}.
|
{UpNodes, Partitions2, RunEnv2}.
|
||||||
|
|
||||||
|
@ -736,10 +722,10 @@ react_to_env_C110(P_latest, #ch_mgr{myflu=MyFLU} = S) ->
|
||||||
%% in the dbg2 list?
|
%% in the dbg2 list?
|
||||||
Extra_todo = [],
|
Extra_todo = [],
|
||||||
RunEnv = S#ch_mgr.runenv,
|
RunEnv = S#ch_mgr.runenv,
|
||||||
UpNodes = proplists:get_value(up_nodes, RunEnv),
|
Islands = proplists:get_value(network_islands, RunEnv),
|
||||||
P_latest2 = update_projection_dbg2(
|
P_latest2 = update_projection_dbg2(
|
||||||
P_latest,
|
P_latest,
|
||||||
[{up_nodz, UpNodes},{hooray, {v2, date(), time()}}|Extra_todo]),
|
[{network_islands, Islands},{hooray, {v2, date(), time()}}|Extra_todo]),
|
||||||
Epoch = P_latest2#projection.epoch_number,
|
Epoch = P_latest2#projection.epoch_number,
|
||||||
ok = machi_flu0:proj_write(MyFLU, Epoch, private, P_latest2),
|
ok = machi_flu0:proj_write(MyFLU, Epoch, private, P_latest2),
|
||||||
react_to_env_C120(P_latest, S).
|
react_to_env_C120(P_latest, S).
|
||||||
|
@ -1070,7 +1056,7 @@ nonunanimous_setup_and_fix_test() ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
zoof_test() ->
|
zoof_test() ->
|
||||||
machi_partition_simulator:start_link({111,222,333}, 50, 10),
|
machi_partition_simulator:start_link({111,222,333}, 0, 100),
|
||||||
_ = machi_partition_simulator:get([a,b,c]),
|
_ = machi_partition_simulator:get([a,b,c]),
|
||||||
|
|
||||||
{ok, FLUa} = machi_flu0:start_link(a),
|
{ok, FLUa} = machi_flu0:start_link(a),
|
||||||
|
@ -1089,12 +1075,17 @@ zoof_test() ->
|
||||||
|
|
||||||
{now_using, XX1} = test_react_to_env(Ma),
|
{now_using, XX1} = test_react_to_env(Ma),
|
||||||
?D(XX1),
|
?D(XX1),
|
||||||
|
{now_using, _} = test_react_to_env(Mb),
|
||||||
|
{now_using, _} = test_react_to_env(Mc),
|
||||||
{QQ,QQP2,QQE2} = test_read_latest_public_projection(Ma, false),
|
{QQ,QQP2,QQE2} = test_read_latest_public_projection(Ma, false),
|
||||||
?D(QQ),
|
?D(QQ),
|
||||||
?Dw(make_projection_summary(QQP2)),
|
?Dw(make_projection_summary(QQP2)),
|
||||||
?D(QQE2),
|
?D(QQE2),
|
||||||
%% {unanimous,P2,E2} = test_read_latest_public_projection(Ma, false),
|
%% {unanimous,P2,E2} = test_read_latest_public_projection(Ma, false),
|
||||||
|
|
||||||
|
machi_partition_simulator:reset_thresholds(10, 50),
|
||||||
|
_ = machi_partition_simulator:get([a,b,c]),
|
||||||
|
|
||||||
Parent = self(),
|
Parent = self(),
|
||||||
DoIt = fun() ->
|
DoIt = fun() ->
|
||||||
Pids = [spawn(fun() ->
|
Pids = [spawn(fun() ->
|
||||||
|
@ -1102,7 +1093,7 @@ zoof_test() ->
|
||||||
erlang:yield(),
|
erlang:yield(),
|
||||||
Res = test_react_to_env(MMM),
|
Res = test_react_to_env(MMM),
|
||||||
Res=Res %% ?D({self(), Res})
|
Res=Res %% ?D({self(), Res})
|
||||||
end || _ <- lists:seq(1,10)],
|
end || _ <- lists:seq(1,20)],
|
||||||
Parent ! done
|
Parent ! done
|
||||||
end) || MMM <- [Ma, Mb, Mc] ],
|
end) || MMM <- [Ma, Mb, Mc] ],
|
||||||
[receive
|
[receive
|
||||||
|
|
|
@ -105,7 +105,7 @@ calc_network_partitions(Nodes, Seed1, OldPartition,
|
||||||
true ->
|
true ->
|
||||||
{Cutoff3, Seed3} = random:uniform_s(100, Seed1),
|
{Cutoff3, Seed3} = random:uniform_s(100, Seed1),
|
||||||
if Cutoff3 < NoPartitionThreshold ->
|
if Cutoff3 < NoPartitionThreshold ->
|
||||||
{Seed3, []};
|
{Seed3, {[], [Nodes]}};
|
||||||
true ->
|
true ->
|
||||||
make_network_partition_locations(Nodes, Seed3)
|
make_network_partition_locations(Nodes, Seed3)
|
||||||
end
|
end
|
||||||
|
@ -129,10 +129,10 @@ make_network_partition_locations(Nodes, Seed1) ->
|
||||||
end, {Seed1, []}, Nodes),
|
end, {Seed1, []}, Nodes),
|
||||||
IslandSep = 100 div Num,
|
IslandSep = 100 div Num,
|
||||||
Islands = [
|
Islands = [
|
||||||
[Nd || {Weight, Nd} <- WeightsNodes,
|
lists:sort([Nd || {Weight, Nd} <- WeightsNodes,
|
||||||
(Max - IslandSep) =< Weight, Weight < Max]
|
(Max - IslandSep) =< Weight, Weight < Max])
|
||||||
|| Max <- lists:seq(IslandSep + 1, 105, IslandSep)],
|
|| Max <- lists:seq(IslandSep + 1, 105, IslandSep)],
|
||||||
{Seed2, {lists:usort(islands2partitions(Islands)), Islands}}.
|
{Seed2, {lists:usort(islands2partitions(Islands)), lists:sort(Islands)}}.
|
||||||
|
|
||||||
islands2partitions([]) ->
|
islands2partitions([]) ->
|
||||||
[];
|
[];
|
||||||
|
|
Loading…
Reference in a new issue