Compare commits
2 commits
master
...
ss-repair-
Author | SHA1 | Date | |
---|---|---|---|
|
903e9395c8 | ||
|
7ee8e02b38 |
3 changed files with 18 additions and 19 deletions
|
@ -439,8 +439,9 @@ do_append_midtail2([FLU|RestFLUs]=FLUs, Prefix, File, Offset, Chunk,
|
||||||
%% We know what the chunk ought to be, so jump to the
|
%% We know what the chunk ought to be, so jump to the
|
||||||
%% middle of read-repair.
|
%% middle of read-repair.
|
||||||
Resume = {append, Offset, iolist_size(Chunk), File},
|
Resume = {append, Offset, iolist_size(Chunk), File},
|
||||||
do_repair_chunk(FLUs, Resume, Chunk, [], File, Offset,
|
{Reply, S1} = do_repair_chunk(FLUs, Resume, Chunk, [], File, Offset,
|
||||||
iolist_size(Chunk), Depth, STime, S);
|
iolist_size(Chunk), Depth, STime, S),
|
||||||
|
{reply, Reply, S1};
|
||||||
{error, trimmed} = Err ->
|
{error, trimmed} = Err ->
|
||||||
%% TODO: nothing can be done
|
%% TODO: nothing can be done
|
||||||
{reply, Err, S};
|
{reply, Err, S};
|
||||||
|
|
|
@ -125,6 +125,7 @@ list_files_by_prefix(_FluName, Other) ->
|
||||||
%% gen_server API
|
%% gen_server API
|
||||||
init([FluName, DataDir]) ->
|
init([FluName, DataDir]) ->
|
||||||
Tid = ets:new(make_filename_mgr_name(FluName), [named_table, {read_concurrency, true}]),
|
Tid = ets:new(make_filename_mgr_name(FluName), [named_table, {read_concurrency, true}]),
|
||||||
|
ets:insert(Tid, {counter, 0}), %% In theory, persistent counter over the lifetime of the FLU
|
||||||
{ok, #state{fluname = FluName,
|
{ok, #state{fluname = FluName,
|
||||||
epoch = 0,
|
epoch = 0,
|
||||||
datadir = DataDir,
|
datadir = DataDir,
|
||||||
|
@ -143,6 +144,7 @@ handle_call({find_filename, EpochId, Prefix}, _From, S = #state{ datadir = DataD
|
||||||
tid = Tid}) ->
|
tid = Tid}) ->
|
||||||
%% Our state and the caller's epoch ids are the same. Business as usual.
|
%% Our state and the caller's epoch ids are the same. Business as usual.
|
||||||
File = handle_find_file(Tid, Prefix, DataDir),
|
File = handle_find_file(Tid, Prefix, DataDir),
|
||||||
|
%% io:format(user, "~s:find_filename ~w ~w: ~W ~s -> ~s\n", [?MODULE, ?LINE, S#state.fluname, EpochId, 4, Prefix, File]),
|
||||||
{reply, {file, File}, S};
|
{reply, {file, File}, S};
|
||||||
|
|
||||||
handle_call({find_filename, EpochId, Prefix}, _From, S = #state{ datadir = DataDir, tid = Tid }) ->
|
handle_call({find_filename, EpochId, Prefix}, _From, S = #state{ datadir = DataDir, tid = Tid }) ->
|
||||||
|
@ -151,6 +153,7 @@ handle_call({find_filename, EpochId, Prefix}, _From, S = #state{ datadir = DataD
|
||||||
%% If epoch ids between our state and the caller's are different, we must increment the
|
%% If epoch ids between our state and the caller's are different, we must increment the
|
||||||
%% sequence number, generate a filename and then cache it.
|
%% sequence number, generate a filename and then cache it.
|
||||||
File = increment_and_cache_filename(Tid, DataDir, Prefix),
|
File = increment_and_cache_filename(Tid, DataDir, Prefix),
|
||||||
|
%% io:format(user, "~s:find_filename ~w ~w: ~W ~s -> ~s\n", [?MODULE, ?LINE, S#state.fluname, EpochId, 4, Prefix, File]),
|
||||||
{reply, {file, File}, S#state{epoch = EpochId}};
|
{reply, {file, File}, S#state{epoch = EpochId}};
|
||||||
|
|
||||||
handle_call({increment_sequence, Prefix}, _From, S = #state{ datadir = DataDir }) ->
|
handle_call({increment_sequence, Prefix}, _From, S = #state{ datadir = DataDir }) ->
|
||||||
|
@ -199,25 +202,15 @@ make_filename_mgr_name(FluName) when is_atom(FluName) ->
|
||||||
list_to_atom(atom_to_list(FluName) ++ "_filename_mgr").
|
list_to_atom(atom_to_list(FluName) ++ "_filename_mgr").
|
||||||
|
|
||||||
handle_find_file(Tid, Prefix, DataDir) ->
|
handle_find_file(Tid, Prefix, DataDir) ->
|
||||||
N = machi_util:read_max_filenum(DataDir, Prefix),
|
File = find_or_make_filename(Tid, DataDir, Prefix),
|
||||||
{File, Cleanup} = case find_file(DataDir, Prefix, N) of
|
|
||||||
[] ->
|
|
||||||
{find_or_make_filename(Tid, DataDir, Prefix, N), false};
|
|
||||||
[H] -> {H, true};
|
|
||||||
[Fn | _ ] = L ->
|
|
||||||
lager:debug(
|
|
||||||
"Searching for a matching file to prefix ~p and sequence number ~p gave multiples: ~p",
|
|
||||||
[Prefix, N, L]),
|
|
||||||
{Fn, true}
|
|
||||||
end,
|
|
||||||
maybe_cleanup(Tid, {Prefix, N}, Cleanup),
|
|
||||||
filename:basename(File).
|
filename:basename(File).
|
||||||
|
|
||||||
find_or_make_filename(Tid, DataDir, Prefix, N) ->
|
find_or_make_filename(Tid, DataDir, Prefix) ->
|
||||||
case ets:lookup(Tid, {Prefix, N}) of
|
case ets:lookup(Tid, {Prefix}) of
|
||||||
[] ->
|
[] ->
|
||||||
|
N = ets:update_counter(Tid, counter, 1),
|
||||||
F = generate_filename(DataDir, Prefix, N),
|
F = generate_filename(DataDir, Prefix, N),
|
||||||
true = ets:insert_new(Tid, {{Prefix, N}, F}),
|
true = ets:insert_new(Tid, {{Prefix}, F}),
|
||||||
F;
|
F;
|
||||||
[{_Key, File}] ->
|
[{_Key, File}] ->
|
||||||
File
|
File
|
||||||
|
@ -238,9 +231,9 @@ maybe_cleanup(Tid, Key, true) ->
|
||||||
|
|
||||||
increment_and_cache_filename(Tid, DataDir, Prefix) ->
|
increment_and_cache_filename(Tid, DataDir, Prefix) ->
|
||||||
ok = machi_util:increment_max_filenum(DataDir, Prefix),
|
ok = machi_util:increment_max_filenum(DataDir, Prefix),
|
||||||
N = machi_util:read_max_filenum(DataDir, Prefix),
|
N = ets:update_counter(Tid, counter, 1),
|
||||||
F = generate_filename(DataDir, Prefix, N),
|
F = generate_filename(DataDir, Prefix, N),
|
||||||
true = ets:insert_new(Tid, {{Prefix, N}, F}),
|
ets:insert(Tid, {{Prefix}, F}),
|
||||||
filename:basename(F).
|
filename:basename(F).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -196,6 +196,11 @@ num() ->
|
||||||
choose(2, 5).
|
choose(2, 5).
|
||||||
%% return(3).
|
%% return(3).
|
||||||
|
|
||||||
|
sublist(L) ->
|
||||||
|
?LET(K, nat(),
|
||||||
|
?LET(L2, eqc_gen:vector(K, eqc_gen:oneof(L)),
|
||||||
|
lists:usort(L2))).
|
||||||
|
|
||||||
%% Generator for possibly assymmetric partition information
|
%% Generator for possibly assymmetric partition information
|
||||||
partition(FLUNames) ->
|
partition(FLUNames) ->
|
||||||
frequency([{10, return([])},
|
frequency([{10, return([])},
|
||||||
|
|
Loading…
Reference in a new issue