Switch to start_link

Start all processes linked - to collapse the whole tree if one process fails
This commit is contained in:
Martin Sumner 2018-06-28 12:16:43 +01:00
parent 92bd2513c1
commit 082eabb65b
7 changed files with 20 additions and 18 deletions

View file

@ -315,7 +315,7 @@ book_start(RootPath, LedgerCacheSize, JournalSize, SyncStrategy) ->
%% comments on the open_options() type
book_start(Opts) ->
gen_server:start(?MODULE, [set_defaults(Opts)], []).
gen_server:start_link(?MODULE, [set_defaults(Opts)], []).
-spec book_tempput(pid(), any(), any(), any(),

View file

@ -53,7 +53,7 @@
-ifdef(fsm_deprecated).
-compile({nowarn_deprecated_function,
[{gen_fsm, start, 3},
[{gen_fsm, start_link, 3},
{gen_fsm, sync_send_event, 3},
{gen_fsm, sync_send_event, 2},
{gen_fsm, send_event, 2},
@ -162,7 +162,7 @@ cdb_open_writer(Filename) ->
%% hashtree cached in memory (the file will need to be scanned to build the
%% hashtree)
cdb_open_writer(Filename, Opts) ->
{ok, Pid} = gen_fsm:start(?MODULE, [Opts], []),
{ok, Pid} = gen_fsm:start_link(?MODULE, [Opts], []),
ok = gen_fsm:sync_send_event(Pid, {open_writer, Filename}, infinity),
{ok, Pid}.
@ -177,7 +177,9 @@ cdb_open_writer(Filename, Opts) ->
%% determine when scans over a file have completed.
cdb_reopen_reader(Filename, LastKey, CDBopts) ->
{ok, Pid} =
gen_fsm:start(?MODULE, [CDBopts#cdb_options{binary_mode=true}], []),
gen_fsm:start_link(?MODULE,
[CDBopts#cdb_options{binary_mode=true}],
[]),
ok = gen_fsm:sync_send_event(Pid,
{open_reader, Filename, LastKey},
infinity),
@ -198,7 +200,7 @@ cdb_open_reader(Filename) ->
%% to discover the LastKey.
%% Allows non-default cdb_options to be passed
cdb_open_reader(Filename, Opts) ->
{ok, Pid} = gen_fsm:start(?MODULE, [Opts], []),
{ok, Pid} = gen_fsm:start_link(?MODULE, [Opts], []),
ok = gen_fsm:sync_send_event(Pid, {open_reader, Filename}, infinity),
{ok, Pid}.
@ -2459,7 +2461,7 @@ safe_read_test() ->
nonsense_coverage_test() ->
{ok, Pid} = gen_fsm:start(?MODULE, [#cdb_options{}], []),
{ok, Pid} = gen_fsm:start_link(?MODULE, [#cdb_options{}], []),
ok = gen_fsm:send_all_state_event(Pid, nonsense),
?assertMatch({next_state, reader, #state{}}, handle_info(nonsense,
reader,

View file

@ -127,7 +127,7 @@
%% @doc
%% Generate a new clerk
clerk_new(InkerClerkOpts) ->
gen_server:start(?MODULE, [InkerClerkOpts], []).
gen_server:start_link(?MODULE, [InkerClerkOpts], []).
-spec clerk_compact(pid(), pid(),
fun(), fun(), fun(),

View file

@ -169,7 +169,7 @@
%% The inker will need to know what the reload strategy is, to inform the
%% clerk about the rules to enforce during compaction.
ink_start(InkerOpts) ->
gen_server:start(?MODULE, [InkerOpts], []).
gen_server:start_link(?MODULE, [InkerOpts], []).
-spec ink_put(pid(),
leveled_codec:ledger_key(),

View file

@ -59,9 +59,9 @@
clerk_new(Owner, Manifest, CompressionMethod) ->
{ok, Pid} =
gen_server:start(?MODULE,
[{compression_method, CompressionMethod}],
[]),
gen_server:start_link(?MODULE,
[{compression_method, CompressionMethod}],
[]),
ok = gen_server:call(Pid, {load, Owner, Manifest}, infinity),
leveled_log:log("PC001", [Pid, Owner]),
{ok, Pid}.

View file

@ -308,7 +308,7 @@
%% query is run against the level zero space and just the query results are
%5 copied into the clone.
pcl_start(PCLopts) ->
gen_server:start(?MODULE, [PCLopts], []).
gen_server:start_link(?MODULE, [PCLopts], []).
-spec pcl_pushmem(pid(), bookies_memory()) -> ok|returned.
%% @doc

View file

@ -64,7 +64,7 @@
-ifdef(fsm_deprecated).
-compile({nowarn_deprecated_function,
[{gen_fsm, start, 3},
[{gen_fsm, start_link, 3},
{gen_fsm, sync_send_event, 3},
{gen_fsm, send_event, 2},
{gen_fsm, send_all_state_event, 2}]}).
@ -209,7 +209,7 @@
%%
%% The filename should include the file extension.
sst_open(RootPath, Filename) ->
{ok, Pid} = gen_fsm:start(?MODULE, [], []),
{ok, Pid} = gen_fsm:start_link(?MODULE, [], []),
case gen_fsm:sync_send_event(Pid,
{sst_open, RootPath, Filename},
infinity) of
@ -228,7 +228,7 @@ sst_open(RootPath, Filename) ->
%% pairs. This should not be used for basement levels or unexpanded Key/Value
%% lists as merge_lists will not be called.
sst_new(RootPath, Filename, Level, KVList, MaxSQN, PressMethod) ->
{ok, Pid} = gen_fsm:start(?MODULE, [], []),
{ok, Pid} = gen_fsm:start_link(?MODULE, [], []),
PressMethod0 = compress_level(Level, PressMethod),
{[], [], SlotList, FK} = merge_lists(KVList, PressMethod0),
case gen_fsm:sync_send_event(Pid,
@ -276,7 +276,7 @@ sst_new(RootPath, Filename,
[] ->
empty;
_ ->
{ok, Pid} = gen_fsm:start(?MODULE, [], []),
{ok, Pid} = gen_fsm:start_link(?MODULE, [], []),
case gen_fsm:sync_send_event(Pid,
{sst_new,
RootPath,
@ -303,7 +303,7 @@ sst_newlevelzero(RootPath, Filename,
Slots, FetchFun, Penciller,
MaxSQN, PressMethod) ->
PressMethod0 = compress_level(0, PressMethod),
{ok, Pid} = gen_fsm:start(?MODULE, [], []),
{ok, Pid} = gen_fsm:start_link(?MODULE, [], []),
gen_fsm:send_event(Pid,
{sst_newlevelzero,
RootPath,
@ -2802,7 +2802,7 @@ key_dominates_test() ->
key_dominates([KV7|KL2], [KV2], {true, 1})).
nonsense_coverage_test() ->
{ok, Pid} = gen_fsm:start(?MODULE, [], []),
{ok, Pid} = gen_fsm:start_link(?MODULE, [], []),
ok = gen_fsm:send_all_state_event(Pid, nonsense),
?assertMatch({next_state, reader, #state{}}, handle_info(nonsense,
reader,