Skip to content

Commit d854c56

Browse files
author
Alex Valiushko
committed
use uid for identity
1 parent 27a533b commit d854c56

File tree

10 files changed

+200
-214
lines changed

10 files changed

+200
-214
lines changed

src/ra.erl

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
overview/1,
7272
%% helpers
7373
new_uid/1,
74-
new_nvid/0,
7574
%% rebalancing
7675
transfer_leadership/2,
7776
%% auxiliary commands
@@ -484,7 +483,7 @@ start_server(System, ClusterName, #{id := {_, _}} = Conf0, Machine, ServerIds)
484483
initial_members => ServerIds,
485484
log_init_args => #{uid => UId},
486485
machine => Machine},
487-
start_server(System, maps:merge(Conf0, Conf)).
486+
start_server(System, maps:merge(Conf, Conf0)).
488487

489488
%% @doc Starts a ra server in the default system
490489
%% @param Conf a ra_server_config() configuration map.
@@ -719,14 +718,6 @@ new_uid(Source) when is_binary(Source) ->
719718
Prefix = ra_lib:derive_safe_string(Source, 6),
720719
ra_lib:make_uid(string:uppercase(Prefix)).
721720

722-
%% @doc generates a random uid using timestamp for the first
723-
%% 6 characters.
724-
%% @end
725-
new_nvid() ->
726-
Millis = erlang:system_time(millisecond),
727-
Prefix = base64:encode(<<Millis:32/little>>),
728-
new_uid(Prefix).
729-
730721
%% @doc Returns a map of overview data of the default Ra system on the current Erlang
731722
%% node.
732723
%% DEPRECATED: user overview/1
@@ -1143,15 +1134,15 @@ key_metrics({Name, N} = ServerId) when N == node() ->
11431134
case whereis(Name) of
11441135
undefined ->
11451136
Counters#{state => noproc,
1146-
voter_status => noproc};
1137+
non_voter => noproc};
11471138
_ ->
11481139
case ets:lookup(ra_state, Name) of
11491140
[] ->
11501141
Counters#{state => unknown,
1151-
voter_status => unknown};
1152-
[{_, State, Voter}] ->
1142+
non_voter => unknown};
1143+
[{_, State, NonVoter}] ->
11531144
Counters#{state => State,
1154-
voter_status => Voter}
1145+
non_voter => NonVoter}
11551146
end
11561147
end;
11571148
key_metrics({_, N} = ServerId) ->

src/ra.hrl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,30 @@
3333
%% used for on disk resources and local name to pid mapping
3434
-type ra_uid() :: binary().
3535

36-
%% Transient ID that uniquely identifies any new non-voter.
37-
-type ra_nvid() :: binary().
38-
3936
%% Identifies a Ra server (node) in a Ra cluster.
4037
%%
4138
%% Ra servers need to be registered stable names (names that are reachable
4239
%% after node restart). Pids are not stable in this sense.
4340
-type ra_server_id() :: {Name :: atom(), Node :: node()}.
4441

4542
%% Specifies server configuration for a new cluster member.
46-
%% Both `ra:add_member` and `ra:start_server` must be called with the same value.
43+
%% Subset of ra_server:ra_server_config().
44+
%% Both `ra:add_member` and `ra:start_server` must be called with the same values.
4745
-type ra_new_server() :: #{id := ra_server_id(),
4846

4947
%% If set, server will start as non-voter until later promoted by the
5048
%% leader.
51-
non_voter_id => ra_nvid()}.
49+
non_voter => boolean(),
50+
uid => ra_uid()}.
5251

5352
-type ra_peer_status() :: normal |
5453
{sending_snapshot, pid()} |
5554
suspended |
5655
disconnected.
5756

58-
-type ra_voter_status() :: {voter, ra_voter_state()} |
59-
{nonvoter, ra_voter_state()}.
60-
61-
-type ra_voter_state() :: #{nvid => ra_nvid(),
62-
target => ra_index()}.
57+
-type ra_voter_status() :: #{non_voter => boolean(),
58+
uid => ra_uid(),
59+
target => ra_index()}.
6360

6461
-type ra_peer_state() :: #{next_index := non_neg_integer(),
6562
match_index := non_neg_integer(),

src/ra_directory.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ overview(System) when is_atom(System) ->
188188
pid => Pid,
189189
parent => Parent,
190190
state => S,
191-
voter_status => V,
191+
non_voter => V,
192192
cluster_name => ClusterName,
193193
snapshot_state => maps:get(UId, Snaps,
194194
undefined)}}

0 commit comments

Comments
 (0)