Redundant clauses
Remove some redundant clauses, and fix up some logging
This commit is contained in:
parent
12fe1d01bd
commit
7319b8f415
4 changed files with 15 additions and 47 deletions
|
@ -33,7 +33,6 @@
|
|||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
-export([strip_to_keyonly/1,
|
||||
strip_to_keyseqonly/1,
|
||||
strip_to_seqonly/1,
|
||||
strip_to_statusonly/1,
|
||||
strip_to_keyseqstatusonly/1,
|
||||
|
@ -65,8 +64,6 @@ generate_uuid() ->
|
|||
strip_to_keyonly({keyonly, K}) -> K;
|
||||
strip_to_keyonly({K, _V}) -> K.
|
||||
|
||||
strip_to_keyseqonly({K, {SeqN, _, _ }}) -> {K, SeqN}.
|
||||
|
||||
strip_to_keyseqstatusonly({K, {SeqN, St, _MD}}) -> {K, SeqN, St}.
|
||||
|
||||
strip_to_statusonly({_, {_, St, _}}) -> St.
|
||||
|
|
|
@ -129,9 +129,7 @@ handle_call({manifest_change, confirm, Closing}, From, State) ->
|
|||
|
||||
handle_cast(prompt, State) ->
|
||||
io:format("Clerk reducing timeout due to prompt~n"),
|
||||
{noreply, State, ?QUICK_TIMEOUT};
|
||||
handle_cast(_Msg, State) ->
|
||||
{noreply, State}.
|
||||
{noreply, State, ?QUICK_TIMEOUT}.
|
||||
|
||||
handle_info(timeout, State=#state{change_pending=Pnd}) when Pnd == false ->
|
||||
case requestandhandle_work(State) of
|
||||
|
@ -142,9 +140,7 @@ handle_info(timeout, State=#state{change_pending=Pnd}) when Pnd == false ->
|
|||
% change
|
||||
{noreply,
|
||||
State#state{change_pending=true, work_item=WI}}
|
||||
end;
|
||||
handle_info(_Info, State) ->
|
||||
{noreply, State}.
|
||||
end.
|
||||
|
||||
terminate(_Reason, _State) ->
|
||||
ok.
|
||||
|
@ -373,17 +369,9 @@ find_randomkeys(FList, Count, Source) ->
|
|||
K1 = leveled_codec:strip_to_keyonly(KV1),
|
||||
P1 = choose_pid_toquery(FList, K1),
|
||||
FoundKV = leveled_sft:sft_get(P1, K1),
|
||||
Check = case FoundKV of
|
||||
not_present ->
|
||||
io:format("Failed to find ~w in ~w~n", [K1, P1]),
|
||||
error;
|
||||
_ ->
|
||||
Found = leveled_codec:strip_to_keyonly(FoundKV),
|
||||
io:format("success finding ~w in ~w~n", [K1, P1]),
|
||||
?assertMatch(K1, Found),
|
||||
ok
|
||||
end,
|
||||
?assertMatch(Check, ok),
|
||||
Found = leveled_codec:strip_to_keyonly(FoundKV),
|
||||
io:format("success finding ~w in ~w~n", [K1, P1]),
|
||||
?assertMatch(K1, Found),
|
||||
find_randomkeys(FList, Count - 1, Source).
|
||||
|
||||
|
||||
|
|
|
@ -751,8 +751,7 @@ start_from_file(PCLopts) ->
|
|||
checkready_pushtomem(State) ->
|
||||
{TableSize, UpdState} = case State#state.levelzero_pending of
|
||||
{true, Pid, _TS} ->
|
||||
%% Need to handle error scenarios?
|
||||
%% N.B. Sync call - so will be ready
|
||||
% N.B. Sync call - so will be ready
|
||||
{ok, SrcFN, StartKey, EndKey} = leveled_sft:sft_checkready(Pid),
|
||||
true = ets:delete_all_objects(State#state.memtable),
|
||||
ManifestEntry = #manifest_entry{start_key=StartKey,
|
||||
|
@ -898,23 +897,12 @@ return_work(State, From) ->
|
|||
io:format("Work at Level ~w to be scheduled for ~w with ~w " ++
|
||||
"queue items outstanding~n",
|
||||
[SrcLevel, From, length(OtherWork)]),
|
||||
case {element(1, State#state.levelzero_pending),
|
||||
State#state.ongoing_work} of
|
||||
{true, _} ->
|
||||
case element(1, State#state.levelzero_pending) of
|
||||
true ->
|
||||
% Once the L0 file is completed there will be more work
|
||||
% - so don't be busy doing other work now
|
||||
io:format("Allocation of work blocked as L0 pending~n"),
|
||||
{State, none};
|
||||
{_, [OutstandingWork]} ->
|
||||
% Still awaiting a response
|
||||
io:format("Ongoing work requested by ~w " ++
|
||||
"but work outstanding from Level ~w " ++
|
||||
"and Clerk ~w at sequence number ~w~n",
|
||||
[From,
|
||||
OutstandingWork#penciller_work.src_level,
|
||||
OutstandingWork#penciller_work.clerk,
|
||||
OutstandingWork#penciller_work.next_sqn]),
|
||||
{State, none};
|
||||
_ ->
|
||||
%% No work currently outstanding
|
||||
%% Can allocate work
|
||||
|
@ -1526,17 +1514,7 @@ simple_server_test() ->
|
|||
ok = pcl_close(PCL),
|
||||
{ok, PCLr} = pcl_start(#penciller_options{root_path=RootPath,
|
||||
max_inmemory_tablesize=1000}),
|
||||
TopSQN = pcl_getstartupsequencenumber(PCLr),
|
||||
Check = case TopSQN of
|
||||
2002 ->
|
||||
%% everything got persisted
|
||||
ok;
|
||||
_ ->
|
||||
io:format("Unexpected sequence number on restart ~w~n",
|
||||
[TopSQN]),
|
||||
error
|
||||
end,
|
||||
?assertMatch(ok, Check),
|
||||
?assertMatch(2002, pcl_getstartupsequencenumber(PCLr)),
|
||||
?assertMatch(Key1, pcl_fetch(PCLr, {o,"Bucket0001", "Key0001", null})),
|
||||
?assertMatch(Key2, pcl_fetch(PCLr, {o,"Bucket0002", "Key0002", null})),
|
||||
?assertMatch(Key3, pcl_fetch(PCLr, {o,"Bucket0003", "Key0003", null})),
|
||||
|
|
|
@ -41,7 +41,11 @@ simple_load_with2i(_Config) ->
|
|||
simple_querycount(_Config) ->
|
||||
RootPath = testutil:reset_filestructure(),
|
||||
{ok, Book1} = leveled_bookie:book_start(RootPath, 4000, 50000000),
|
||||
{TestObject, TestSpec} = testutil:generate_testobject(),
|
||||
{TestObject, TestSpec} = testutil:generate_testobject("Bucket",
|
||||
"Key1",
|
||||
"Value1",
|
||||
[],
|
||||
{"MDK1", "MDV1"}),
|
||||
ok = leveled_bookie:book_riakput(Book1, TestObject, TestSpec),
|
||||
testutil:check_forobject(Book1, TestObject),
|
||||
testutil:check_formissingobject(Book1, "Bucket1", "Key2"),
|
||||
|
@ -237,6 +241,7 @@ simple_querycount(_Config) ->
|
|||
end
|
||||
end,
|
||||
R9),
|
||||
testutil:check_forobject(Book4, TestObject),
|
||||
ok = leveled_bookie:book_close(Book4),
|
||||
testutil:reset_filestructure().
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue