From e9c4e2f98da25e43c435bf12874161022155bff6 Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Thu, 6 Aug 2015 15:22:04 +0900 Subject: [PATCH] WIP: rearrange CP mode projection calc --- src/machi_chain_manager1.erl | 16 ++++++++++------ test/machi_cr_client_test.erl | 2 -- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/machi_chain_manager1.erl b/src/machi_chain_manager1.erl index 0ab531f..4cd34fa 100644 --- a/src/machi_chain_manager1.erl +++ b/src/machi_chain_manager1.erl @@ -587,11 +587,11 @@ calc_projection(_OldThreshold, _NoPartitionThreshold, LastProj, RelativeToServer, AllHosed, Dbg, #ch_mgr{name=MyName, proj=CurrentProj, + consistency_mode=CMode, runenv=RunEnv1, repair_final_status=RepairFS}=S) -> #projection_v1{epoch_number=OldEpochNum, members_dict=MembersDict, - all_members=OldAll_list, witnesses=OldWitness_list, upi=OldUPI_list, repairing=OldRepairing_list @@ -606,8 +606,6 @@ calc_projection(_OldThreshold, _NoPartitionThreshold, LastProj, Down = AllMembers -- Up, NewUPI_list = - [W || W <- Up, lists:member(W, OldWitness_list)] - ++ [X || X <- OldUPI_list, lists:member(X, Up) andalso not lists:member(X, OldWitness_list)], #projection_v1{upi=CurrentUPI_list} = CurrentProj, @@ -681,9 +679,15 @@ calc_projection(_OldThreshold, _NoPartitionThreshold, LastProj, MyName, MembersDict, Down, NewUPI, NewRepairing, D_foo ++ Dbg ++ [{ps, Partitions},{nodes_up, Up}]), - P2 = machi_projection:update_checksum( - P#projection_v1{witnesses=OldWitness_list}), - {P2, S#ch_mgr{runenv=RunEnv3}}. + P2 = if CMode == cp_mode -> + UpWitnesses = [W || W <- Up, lists:member(W, OldWitness_list)], + P; + CMode == ap_mode -> + P + end, + P3 = machi_projection:update_checksum( + P2#projection_v1{witnesses=OldWitness_list}), + {P3, S#ch_mgr{runenv=RunEnv3}}. check_latest_private_projections_same_epoch(FLUs, MyProj, Partitions, S) -> %% NOTE: The caller must provide us with the FLUs list for all diff --git a/test/machi_cr_client_test.erl b/test/machi_cr_client_test.erl index 17abdcc..d815d48 100644 --- a/test/machi_cr_client_test.erl +++ b/test/machi_cr_client_test.erl @@ -31,7 +31,6 @@ smoke_test_() -> {timeout, 1*60, fun() -> smoke_test2() end}. setup_smoke_test(Host, PortBase, Os, Witness_list) -> -io:format(user, "setup_smoke_test(", []), os:cmd("rm -rf ./data.a ./data.b ./data.c"), F = fun(X) -> case lists:member(X, Witness_list) of @@ -70,7 +69,6 @@ io:format(user, "setup_smoke_test(", []), {ok, EpochID} = machi_flu1_client:get_latest_epochid(Host, PortBase+2, private), -io:format(user, ")\n", []), {D, EpochID}. run_ticks(MgrList) ->