Rambling 'slf/doc-cluster-terminology' branch #58
3 changed files with 23 additions and 14 deletions
|
@ -129,7 +129,8 @@ main2(FluName, TcpPort, DataDir, Props) ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
{ok, ListenerPid} = start_listen_server(FluName, TcpPort, Witness_p, DataDir,
|
{ok, ListenerPid} = start_listen_server(FluName, TcpPort, Witness_p, DataDir,
|
||||||
ets_table_name(FluName), ProjectionPid),
|
ets_table_name(FluName), ProjectionPid,
|
||||||
|
Props),
|
||||||
%% io:format(user, "Listener started: ~w~n", [{FluName, ListenerPid}]),
|
%% io:format(user, "Listener started: ~w~n", [{FluName, ListenerPid}]),
|
||||||
|
|
||||||
Config_e = machi_util:make_config_filename(DataDir, "unused"),
|
Config_e = machi_util:make_config_filename(DataDir, "unused"),
|
||||||
|
@ -154,9 +155,10 @@ main2(FluName, TcpPort, DataDir, Props) ->
|
||||||
start_append_server(FluName, Witness_p, Wedged_p, EpochId) ->
|
start_append_server(FluName, Witness_p, Wedged_p, EpochId) ->
|
||||||
machi_flu1_subsup:start_append_server(FluName, Witness_p, Wedged_p, EpochId).
|
machi_flu1_subsup:start_append_server(FluName, Witness_p, Wedged_p, EpochId).
|
||||||
|
|
||||||
start_listen_server(FluName, TcpPort, Witness_p, DataDir, EtsTab, ProjectionPid) ->
|
start_listen_server(FluName, TcpPort, Witness_p, DataDir, EtsTab, ProjectionPid,
|
||||||
|
Props) ->
|
||||||
machi_flu1_subsup:start_listener(FluName, TcpPort, Witness_p, DataDir,
|
machi_flu1_subsup:start_listener(FluName, TcpPort, Witness_p, DataDir,
|
||||||
EtsTab, ProjectionPid).
|
EtsTab, ProjectionPid, Props).
|
||||||
|
|
||||||
%% This is the name of the projection store that is spawned by the
|
%% This is the name of the projection store that is spawned by the
|
||||||
%% *flu*, for use primarily in testing scenarios. In normal use, we
|
%% *flu*, for use primarily in testing scenarios. In normal use, we
|
||||||
|
|
|
@ -69,20 +69,22 @@
|
||||||
%% Clustering: cluster map version number
|
%% Clustering: cluster map version number
|
||||||
namespace_version = 0 :: machi_dt:namespace_version(),
|
namespace_version = 0 :: machi_dt:namespace_version(),
|
||||||
%% Clustering: my (and my chain's) assignment to a specific namespace
|
%% Clustering: my (and my chain's) assignment to a specific namespace
|
||||||
namespace = <<"">> :: machi_dt:namespace(),
|
namespace = <<>> :: machi_dt:namespace(),
|
||||||
|
|
||||||
%% High mode only
|
%% High mode only
|
||||||
high_clnt :: pid(),
|
high_clnt :: pid(),
|
||||||
|
|
||||||
%% anything you want
|
%% anything you want
|
||||||
props = [] :: list() % proplist
|
props = [] :: proplists:proplist()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type socket() :: any().
|
-type socket() :: any().
|
||||||
-type state() :: #state{}.
|
-type state() :: #state{}.
|
||||||
|
|
||||||
-spec start_link(ranch:ref(), socket(), module(), [term()]) -> {ok, pid()}.
|
-spec start_link(ranch:ref(), socket(), module(), [term()]) -> {ok, pid()}.
|
||||||
start_link(Ref, Socket, Transport, [FluName, Witness, DataDir, EpochTab, ProjStore]) ->
|
start_link(Ref, Socket, Transport, [FluName, Witness, DataDir, EpochTab, ProjStore, Props]) ->
|
||||||
|
NS = proplists:get_value(namespace, Props, <<>>),
|
||||||
|
true = is_binary(NS),
|
||||||
proc_lib:start_link(?MODULE, init, [#state{ref=Ref,
|
proc_lib:start_link(?MODULE, init, [#state{ref=Ref,
|
||||||
socket=Socket,
|
socket=Socket,
|
||||||
transport=Transport,
|
transport=Transport,
|
||||||
|
@ -90,7 +92,9 @@ start_link(Ref, Socket, Transport, [FluName, Witness, DataDir, EpochTab, ProjSto
|
||||||
witness=Witness,
|
witness=Witness,
|
||||||
data_dir=DataDir,
|
data_dir=DataDir,
|
||||||
epoch_tab=EpochTab,
|
epoch_tab=EpochTab,
|
||||||
proj_store=ProjStore}]).
|
proj_store=ProjStore,
|
||||||
|
namespace=NS,
|
||||||
|
props=Props}]).
|
||||||
|
|
||||||
-spec init(state()) -> no_return().
|
-spec init(state()) -> no_return().
|
||||||
init(#state{ref=Ref, socket=Socket, transport=Transport}=State) ->
|
init(#state{ref=Ref, socket=Socket, transport=Transport}=State) ->
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
-export([start_link/1,
|
-export([start_link/1,
|
||||||
start_append_server/4,
|
start_append_server/4,
|
||||||
stop_append_server/1,
|
stop_append_server/1,
|
||||||
start_listener/6,
|
start_listener/7,
|
||||||
stop_listener/1,
|
stop_listener/1,
|
||||||
subsup_name/1,
|
subsup_name/1,
|
||||||
listener_name/1]).
|
listener_name/1]).
|
||||||
|
@ -67,11 +67,13 @@ stop_append_server(FluName) ->
|
||||||
ok = supervisor:delete_child(SubSup, FluName).
|
ok = supervisor:delete_child(SubSup, FluName).
|
||||||
|
|
||||||
-spec start_listener(pv1_server(), inet:port_number(), boolean(),
|
-spec start_listener(pv1_server(), inet:port_number(), boolean(),
|
||||||
string(), ets:tab(), atom() | pid()) -> {ok, pid()}.
|
string(), ets:tab(), atom() | pid(),
|
||||||
start_listener(FluName, TcpPort, Witness, DataDir, EpochTab, ProjStore) ->
|
proplists:proplist()) -> {ok, pid()}.
|
||||||
|
start_listener(FluName, TcpPort, Witness, DataDir, EpochTab, ProjStore,
|
||||||
|
Props) ->
|
||||||
supervisor:start_child(subsup_name(FluName),
|
supervisor:start_child(subsup_name(FluName),
|
||||||
listener_spec(FluName, TcpPort, Witness, DataDir,
|
listener_spec(FluName, TcpPort, Witness, DataDir,
|
||||||
EpochTab, ProjStore)).
|
EpochTab, ProjStore, Props)).
|
||||||
|
|
||||||
-spec stop_listener(pv1_server()) -> ok.
|
-spec stop_listener(pv1_server()) -> ok.
|
||||||
stop_listener(FluName) ->
|
stop_listener(FluName) ->
|
||||||
|
@ -97,12 +99,13 @@ init([]) ->
|
||||||
%% private
|
%% private
|
||||||
|
|
||||||
-spec listener_spec(pv1_server(), inet:port_number(), boolean(),
|
-spec listener_spec(pv1_server(), inet:port_number(), boolean(),
|
||||||
string(), ets:tab(), atom() | pid()) -> supervisor:child_spec().
|
string(), ets:tab(), atom() | pid(),
|
||||||
listener_spec(FluName, TcpPort, Witness, DataDir, EpochTab, ProjStore) ->
|
proplists:proplist()) -> supervisor:child_spec().
|
||||||
|
listener_spec(FluName, TcpPort, Witness, DataDir, EpochTab, ProjStore, Props) ->
|
||||||
ListenerName = listener_name(FluName),
|
ListenerName = listener_name(FluName),
|
||||||
NbAcceptors = 10,
|
NbAcceptors = 10,
|
||||||
TcpOpts = [{port, TcpPort}, {backlog, ?BACKLOG}],
|
TcpOpts = [{port, TcpPort}, {backlog, ?BACKLOG}],
|
||||||
NetServerOpts = [FluName, Witness, DataDir, EpochTab, ProjStore],
|
NetServerOpts = [FluName, Witness, DataDir, EpochTab, ProjStore, Props],
|
||||||
ranch:child_spec(ListenerName, NbAcceptors,
|
ranch:child_spec(ListenerName, NbAcceptors,
|
||||||
ranch_tcp, TcpOpts,
|
ranch_tcp, TcpOpts,
|
||||||
machi_flu1_net_server, NetServerOpts).
|
machi_flu1_net_server, NetServerOpts).
|
||||||
|
|
Loading…
Reference in a new issue