WIP: aside, fix FLU wedge status @ init()
This commit is contained in:
parent
4ae0f94649
commit
eec029b08f
7 changed files with 60 additions and 35 deletions
|
@ -77,7 +77,6 @@
|
|||
-define(D(X), io:format(user, "~s ~p\n", [??X, X])).
|
||||
-define(Dw(X), io:format(user, "~s ~w\n", [??X, X])).
|
||||
|
||||
-define(FLU_C, machi_flu1_client).
|
||||
-define(FLU_PC, machi_proxy_flu1_client).
|
||||
-define(TO, (2*1000)). % default timeout
|
||||
|
||||
|
@ -1946,7 +1945,7 @@ perhaps_start_repair(S) ->
|
|||
do_repair(
|
||||
#ch_mgr{name=MyName,
|
||||
proj=#projection_v1{upi=UPI,
|
||||
repairing=[Dst|_]=Repairing,
|
||||
repairing=[_|_]=Repairing,
|
||||
members_dict=MembersDict}}=_S_copy,
|
||||
Opts, ap_mode=_RepairMode) ->
|
||||
T1 = os:timestamp(),
|
||||
|
@ -1976,15 +1975,9 @@ do_repair(
|
|||
ets:delete(ETS),
|
||||
exit({todo, Res}).
|
||||
|
||||
sanitize_repair_state(#ch_mgr{name=MyName,
|
||||
repair_start=Start,
|
||||
repair_final_status=Res,
|
||||
proj=#projection_v1{upi=[_|_]=UPI}}=S)
|
||||
sanitize_repair_state(#ch_mgr{repair_final_status=Res,
|
||||
proj=#projection_v1{upi=[_|_]}}=S)
|
||||
when Res /= undefined ->
|
||||
Elapsed = (timer:now_diff(os:timestamp(), Start) div 1000) / 1000,
|
||||
error_logger:info_msg("Chain tail ~p of ~p: "
|
||||
"repair finished in ~p seconds: ~p\n",
|
||||
[MyName, UPI, Elapsed, Res]),
|
||||
S#ch_mgr{repair_worker=undefined, repair_start=undefined,
|
||||
repair_final_status=undefined};
|
||||
sanitize_repair_state(S) ->
|
||||
|
|
|
@ -87,7 +87,7 @@ repair_ap(Src, Repairing, UPI, MembersDict, ETS, Opts) ->
|
|||
[What, Why, Stack]),
|
||||
{error, {What, Why, Stack}}
|
||||
after
|
||||
[(catch machi_proxy_flu1_client:quit(Pid)) ||
|
||||
[(catch machi_proxy_flu1_client:quit(Pid, ?SHORT_TIMEOUT)) ||
|
||||
Pid <- orddict:to_list(get(proxies_dict))]
|
||||
end,
|
||||
Res.
|
||||
|
@ -107,7 +107,8 @@ make_missing_file_summary(Dict, AllFLUs) ->
|
|||
MissingFileSummary.
|
||||
|
||||
append_file_dict(Proxy, FLU_name, D) ->
|
||||
{ok, Res} = machi_proxy_flu1_client:list_files(Proxy, ?DUMMY_PV1_EPOCH),
|
||||
{ok, Res} = machi_proxy_flu1_client:list_files(Proxy, ?DUMMY_PV1_EPOCH,
|
||||
?SHORT_TIMEOUT),
|
||||
lists:foldl(fun({Size, File}, Dict) ->
|
||||
dict:append(File, {FLU_name, Size}, Dict)
|
||||
end, D, Res).
|
||||
|
@ -171,14 +172,16 @@ copy_file(File, SrcProxy, MissingProxiesDict, Verb, ETS) ->
|
|||
end,
|
||||
_T1 = os:timestamp(),
|
||||
{ok, Chunk} = machi_proxy_flu1_client:read_chunk(
|
||||
SrcProxy, EpochID, File, Offset, Size),
|
||||
SrcProxy, EpochID, File, Offset, Size,
|
||||
?SHORT_TIMEOUT),
|
||||
_T2 = os:timestamp(),
|
||||
case machi_util:checksum_chunk(Chunk) of
|
||||
CSum_now when CSum_now == CSum ->
|
||||
[begin
|
||||
_T3 = os:timestamp(),
|
||||
ok = machi_proxy_flu1_client:write_chunk(
|
||||
DstProxy, EpochID, File, Offset, Chunk),
|
||||
DstProxy, EpochID, File, Offset, Chunk,
|
||||
?SHORT_TIMEOUT),
|
||||
_T4 = os:timestamp()
|
||||
end || {_FLU, DstProxy} <- MissingProxiesDict],
|
||||
ets:update_counter(ETS, in_chunks, 1),
|
||||
|
|
|
@ -114,30 +114,50 @@ main2(FluName, TcpPort, DataDir, Rest) ->
|
|||
DPs ->
|
||||
{lists:keydelete(dbg, 1, Rest), DPs}
|
||||
end,
|
||||
{SendAppendPidToProj_p, ProjectionPid} =
|
||||
case proplists:get_value(projection_store_registered_name, Rest) of
|
||||
undefined ->
|
||||
RN = make_projection_server_regname(FluName),
|
||||
{ok, PP} =
|
||||
machi_projection_store:start_link(RN, DataDir, undefined),
|
||||
{true, PP};
|
||||
RN ->
|
||||
{false, whereis(RN)}
|
||||
end,
|
||||
InitialWedged_p = proplists:get_value(initial_wedged, DbgProps),
|
||||
ProjRes = machi_projection_store:read_latest_projection(ProjectionPid,
|
||||
private),
|
||||
{Wedged_p, EpochId} =
|
||||
if InitialWedged_p == undefined,
|
||||
is_tuple(ProjRes), element(1, ProjRes) == ok ->
|
||||
{ok, Proj} = ProjRes,
|
||||
{false, {Proj#projection_v1.epoch_number,
|
||||
Proj#projection_v1.epoch_csum}};
|
||||
InitialWedged_p == false ->
|
||||
{false, ?DUMMY_PV1_EPOCH};
|
||||
true ->
|
||||
{true, undefined}
|
||||
end,
|
||||
S0 = #state{flu_name=FluName,
|
||||
proj_store=ProjectionPid,
|
||||
tcp_port=TcpPort,
|
||||
data_dir=DataDir,
|
||||
wedged=proplists:get_value(initial_wedged, DbgProps, true),
|
||||
wedged=Wedged_p,
|
||||
etstab=ets_table_name(FluName),
|
||||
epoch_id=undefined,
|
||||
epoch_id=EpochId,
|
||||
dbg_props=DbgProps,
|
||||
props=Props},
|
||||
AppendPid = start_append_server(S0, self()),
|
||||
receive
|
||||
append_server_ack -> ok
|
||||
end,
|
||||
{_ProjRegName, ProjectionPid} =
|
||||
case proplists:get_value(projection_store_registered_name, Rest) of
|
||||
undefined ->
|
||||
RN = make_projection_server_regname(FluName),
|
||||
{ok, PP} =
|
||||
machi_projection_store:start_link(RN, DataDir, AppendPid),
|
||||
{RN, PP};
|
||||
RN ->
|
||||
{RN, whereis(RN)}
|
||||
end,
|
||||
S1 = S0#state{append_pid=AppendPid,
|
||||
proj_store=ProjectionPid},
|
||||
if SendAppendPidToProj_p ->
|
||||
machi_projection_store:set_wedge_notify_pid(ProjectionPid,
|
||||
AppendPid);
|
||||
true ->
|
||||
ok
|
||||
end,
|
||||
S1 = S0#state{append_pid=AppendPid},
|
||||
ListenPid = start_listen_server(S1),
|
||||
|
||||
Config_e = machi_util:make_config_filename(DataDir, "unused"),
|
||||
|
@ -174,13 +194,15 @@ run_listen_server(#state{flu_name=FluName, tcp_port=TcpPort}=S) ->
|
|||
{ok, LSock} = gen_tcp:listen(TcpPort, SockOpts),
|
||||
listen_server_loop(LSock, S).
|
||||
|
||||
run_append_server(FluPid, AckPid, #state{flu_name=Name,dbg_props=DbgProps}=S) ->
|
||||
run_append_server(FluPid, AckPid, #state{flu_name=Name,dbg_props=DbgProps,
|
||||
wedged=Wedged_p,epoch_id=EpochId}=S) ->
|
||||
%% Reminder: Name is the "main" name of the FLU, i.e., no suffix
|
||||
register(Name, self()),
|
||||
TID = ets:new(ets_table_name(Name),
|
||||
[set, protected, named_table, {read_concurrency, true}]),
|
||||
InitialWedged = proplists:get_value(initial_wedged, DbgProps, true),
|
||||
ets:insert(TID, {epoch, {InitialWedged, {-65, <<"bogus epoch, yo">>}}}),
|
||||
%% InitialWedged = proplists:get_value(initial_wedged, DbgProps, true),
|
||||
%% ets:insert(TID, {epoch, {InitialWedged, {-65, <<"bogus epoch, yo">>}}}),
|
||||
ets:insert(TID, {epoch, {Wedged_p, EpochId}}),
|
||||
AckPid ! append_server_ack,
|
||||
append_server_loop(FluPid, S#state{etstab=TID}).
|
||||
|
||||
|
|
|
@ -50,12 +50,13 @@
|
|||
get_all_projections/2, get_all_projections/3,
|
||||
list_all_projections/2, list_all_projections/3
|
||||
]).
|
||||
-export([set_wedge_notify_pid/2]).
|
||||
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
terminate/2, code_change/3]).
|
||||
|
||||
-define(NO_EPOCH, {-1,<<0:(20*8)/big>>}).
|
||||
-define(NO_EPOCH, ?DUMMY_PV1_EPOCH).
|
||||
|
||||
-record(state, {
|
||||
public_dir = "" :: string(),
|
||||
|
@ -148,6 +149,9 @@ list_all_projections(PidSpec, ProjType, Timeout)
|
|||
when ProjType == 'public' orelse ProjType == 'private' ->
|
||||
g_call(PidSpec, {list_all_projections, ProjType}, Timeout).
|
||||
|
||||
set_wedge_notify_pid(PidSpec, NotifyWedgeStateChanges) ->
|
||||
gen_server:call(PidSpec, {set_wedge_notify_pid, NotifyWedgeStateChanges}).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
g_call(PidSpec, Arg, Timeout) ->
|
||||
|
@ -207,6 +211,8 @@ handle_call({{list_all_projections, ProjType}, LC1}, _From, S) ->
|
|||
LC2 = lclock_update(LC1),
|
||||
Dir = pick_path(ProjType, S),
|
||||
{reply, {{ok, find_all(Dir)}, LC2}, S};
|
||||
handle_call({set_wedge_notify_pid, NotifyWedgeStateChanges}, _From, S) ->
|
||||
{reply, ok, S#state{wedge_notify_pid=NotifyWedgeStateChanges}};
|
||||
handle_call(_Request, _From, S) ->
|
||||
Reply = whaaaaaaaaaaaaa,
|
||||
{reply, Reply, S}.
|
||||
|
|
|
@ -132,7 +132,7 @@ flu_projection_smoke_test() ->
|
|||
FLU1 = setup_test_flu(projection_test_flu, TcpPort, DataDir),
|
||||
try
|
||||
[begin
|
||||
{ok, {-1,_}} = ?FLU_C:get_latest_epoch(Host, TcpPort, T),
|
||||
{ok, {0,_}} = ?FLU_C:get_latest_epoch(Host, TcpPort, T),
|
||||
{error, not_written} =
|
||||
?FLU_C:read_latest_projection(Host, TcpPort, T),
|
||||
{ok, []} = ?FLU_C:list_all_projections(Host, TcpPort, T),
|
||||
|
|
|
@ -74,10 +74,11 @@ partial_stop_restart2() ->
|
|||
Dict = orddict:from_list(Ps),
|
||||
[os:cmd("rm -rf " ++ P#p_srvr.props) || {_,P} <- Ps],
|
||||
{ok, SupPid} = machi_flu_sup:start_link(),
|
||||
DbgProps = [{dbg, [{initial_wedged, true}]}],
|
||||
Start = fun({_,P}) ->
|
||||
#p_srvr{name=Name, port=Port, props=Dir} = P,
|
||||
{ok, _} = machi_flu_psup:start_flu_package(
|
||||
Name, Port, Dir, [{active_mode,false}])
|
||||
Name, Port, Dir, [{active_mode,false}|DbgProps])
|
||||
end,
|
||||
WedgeStatus = fun({_,#p_srvr{address=Addr, port=TcpPort}}) ->
|
||||
machi_flu1_client:wedge_status(Addr, TcpPort)
|
||||
|
|
|
@ -42,7 +42,7 @@ api_smoke_test() ->
|
|||
I = #p_srvr{name=RegName, proto=ipv4, address=Host, port=TcpPort},
|
||||
{ok, Prox1} = ?MUT:start_link(I),
|
||||
try
|
||||
FakeEpoch = {-1, <<0:(20*8)/big>>},
|
||||
FakeEpoch = ?DUMMY_PV1_EPOCH,
|
||||
[{ok, {_,_,_}} = ?MUT:append_chunk(Prox1,
|
||||
FakeEpoch, <<"prefix">>, <<"data">>,
|
||||
infinity) || _ <- lists:seq(1,5)],
|
||||
|
|
Loading…
Reference in a new issue