Skip to content

Commit

Permalink
More superficial cleanup: consistency, typos, fix module comments tha…
Browse files Browse the repository at this point in the history
…t were unintentionally attributed to the first function
  • Loading branch information
macintux committed Aug 19, 2014
1 parent 9d575dd commit 7d0a3d2
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/riak_core_cluster_mgr.erl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ register_restore_cluster_targets_fun(ReadClusterFun) ->
register_save_cluster_members_fun(WriteClusterFun) ->
gen_server:cast(?SERVER, {register_save_cluster_members_fun, WriteClusterFun}).

%% @doc Specify how to reach a remote cluster, it's name is
%% @doc Specify how to reach a remote cluster, its name is
%% retrieved by asking it via the control channel.
-spec(add_remote_cluster(ip_addr()) -> ok).
add_remote_cluster({IP,Port}) ->
Expand Down
14 changes: 7 additions & 7 deletions src/riak_core_connection_mgr.erl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ start_link() ->

%% @doc Begins or resumes accepting and establishing new connections, in
%% order to maintain the protocols that have been (or continue to be) registered
%% and unregistered. pause() will not kill any existing connections, but will
%% and unregistered. `pause()' will not kill any existing connections, but will
%% cease accepting new requests or retrying lost connections.
-spec(resume() -> ok).
resume() ->
Expand Down Expand Up @@ -169,19 +169,19 @@ register_locator(Type, Fun) ->
apply_locator(Name, Strategy) ->
gen_server:call(?SERVER, {apply_locator, Name, Strategy}, infinity).

%% @doc Establish a connection to the remote destination. be persistent about it,
%% @doc Establish a connection to the remote destination. Be persistent about it,
%% but not too annoying to the remote end. Connect by name of cluster or
%% IP address. Use default strategy to find "best" peer for connection.
%%
%% Targets are found by applying a registered locator for it.
%% The identity locator is pre-installed, so if you want to connect to a list
%% of IP and Port addresses, supply a Target like this: {identity, [{IP, Port},...]},
%% where IP::string() and Port::integer(). You can also pass {identity, {IP, Port}}
%% of IP and Port addresses, supply a Target like this: `{identity, [{IP, Port},...]}',
%% where `IP::string()' and `Port::integer()'. You can also pass `{identity, {IP, Port}}'
%% and the locator will use just that one IP. With a list, it will rotate
%% trying them all until a connection is established.
%%
%% Other locator types must be registered with this connection manager
%% before calling connect().
%% before calling `connect()'.
%%
%% Supervision must be done by the calling process if desired. No supervision
%% is done here.
Expand All @@ -196,11 +196,11 @@ connect(Target, ClientSpec) ->
disconnect(Target) ->
gen_server:cast(?SERVER, {disconnect, Target}).

%% @doc Get the #req.target and #req.state for all connections
%% @doc Get the `#req.target' and `#req.state' for all connections
get_request_states() ->
gen_server:call(?SERVER, get_request_states).

%% @doc Return the #ep.addr and #ep.failures for all connections
%% @doc Return the `#ep.addr' and `#ep.failures' for all connections
get_connection_errors(Addr) ->
gen_server:call(?SERVER, {get_connection_errors, Addr}).

Expand Down
2 changes: 1 addition & 1 deletion src/riak_core_connection_mgr_stats.erl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ register_stats() ->
%% @doc Return all stats from the cached value. This will refresh
%% the cache if it's been over 5 seconds since the last query.
%% When the cache needs to get the latest values, it will call our
%% produce_stats() function.
%% `produce_stats()' function.
get_stats() ->
case riak_core_stat_cache:get_stats(?APP) of
{ok, Stats, _TS} ->
Expand Down
18 changes: 9 additions & 9 deletions src/riak_core_service_mgr.erl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
%% common, the connection fails. Minor versions do not need to match. On a
%% success, the server sends the Major version, Client minor version, and
%% Host minor version to the client. After that, the registered
%% module:function/5 is called and control of the socket passed to it.
%% `module:function/5' is called and control of the socket passed to it.


-module(riak_core_service_mgr).
Expand Down Expand Up @@ -115,26 +115,26 @@ start_link({IP,Port}) when is_integer(Port), Port >= 0 ->
%% @doc Once a protocol specification is registered, it will be kept
%% available by the Service Manager. Note that the callee is responsible
%% for taking ownership of the socket via
%% Transport:controlling_process(Socket, Pid). Only the strategy of
%% `round_robin' is supported; it's arg is ignored.
%% `Transport:controlling_process(Socket, Pid)'. Only the strategy of
%% `round_robin' is supported; its arg is ignored.
register_service(HostProtocol, Strategy) ->
%% only one strategy is supported as yet
{round_robin, _NB} = Strategy,
gen_server:cast(?SERVER, {register_service, HostProtocol, Strategy}).

%% @doc Blocking version of register_service.
%% @doc Blocking version of `register_service'.
sync_register_service(HostProtocol, Strategy) ->
%% only one strategy is supported as yet
{round_robin, _NB} = Strategy,
gen_server:call(?SERVER, {register_service, HostProtocol, Strategy}).

%% @doc Unregister the given protocol-id. Existing connections for this
%% @doc Unregister the given protocol id. Existing connections for this
%% protocol are not killed. New connections for this protocol will not be
%% accepted until re-registered.
unregister_service(ProtocolId) ->
gen_server:cast(?SERVER, {unregister_service, ProtocolId}).

%% @doc Blocking version of unregister_service.
%% @doc Blocking version of `unregister_service'.
sync_unregister_service(ProtocolId) ->
gen_server:call(?SERVER, {unregister_service, ProtocolId}).

Expand All @@ -144,7 +144,7 @@ is_registered(ProtocolId) ->

%% @doc Register a callback function that will get called periodically or
%% when the connection status of services changes. The function will
%% receive a list of tuples: {<protocol-id>, <stats>} where stats
%% receive a list of tuples: `{<protocol-id>, <stats>}' where stats
%% holds the number of open connections that have been accepted for that
%% protocol type. This can be used to report load, in the form of
%% connected-ness, for each protocol type, to remote clusters, e.g.,
Expand Down Expand Up @@ -503,8 +503,8 @@ normalize_ip(IP) when is_tuple(IP) ->
%% @doc Start the connection dispatcher with a limit of MaxListeners
%% listener connections and supported sub-protocols. When a connection
%% request arrives, it is mapped via the associated Protocol atom to an
%% acceptor function called as Module:Function(Listener, Socket, Transport, Args),
%% which must create it's own process and return {ok, pid()}
%% acceptor function called as `Module:Function(Listener, Socket, Transport, Args)',
%% which must create its own process and return {ok, pid()}

This comment has been minimized.

Copy link
@reiddraper

reiddraper Aug 21, 2014

Contributor

minor nitpick, maybe {ok, pid()} should be {ok, pid()}?

This comment has been minimized.

Copy link
@macintux

macintux Aug 21, 2014

Author Contributor

Yeah, I noticed that one after submitting, but decided this probably wasn't the last set of changes we'd make.

I'll go ahead and tweak it.


-spec(start_dispatcher(ip_addr(), non_neg_integer(), [hostspec()]) -> {ok, pid()}).
start_dispatcher({IP,Port}, MaxListeners, SubProtocols) ->
Expand Down
35 changes: 20 additions & 15 deletions src/riak_repl2_fscoordinator.erl
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
%% @doc Coordinates full sync replication parallelism. Uses 3 riak_repl
%% application env's: fullsync_on_connect, max_fssource_cluster, and
%% max_fssource_node.
%% @doc Coordinates full sync replication parallelism. Uses 3
%% `riak_repl' application environment values: `fullsync_on_connect',
%% `max_fssource_cluster', and `max_fssource_node'.
%%
%% ## `{fullsync_on_connect, boolean()}'
%%
%% If true, as soon as a connection to the remote cluster is established,
%% fullsync starts. If false, then an explicit start must be sent.
%% <dl>
%% <dt>`{fullsync_on_connect, boolean()}'</dt>
%% <dd>
%% If `true', as soon as a connection to the remote cluster is established,
%% fullsync starts. If `false', then an explicit start must be sent.
%% Defaults to true.
%% </dd>
%%
%% ## `{max_fssource_cluster, pos_integer()}'
%%
%% <dt>`{max_fssource_cluster, pos_integer()}'</dt>
%% <dd>
%% How many sources can be started across all nodes in the local cluster.
%% Defaults to 5.
%% </dd>
%%
%% ## `{max_fssource_node, pos_integer()}'
%%
%% <dt>`{max_fssource_node, pos_integer()}'</dt>
%% <dd>
%% How many sources can be started on a single node, provided starting one
%% wouldn't exceede the max_fssource_cluster setting. Defaults to 1.
%% wouldn't exceed the `max_fssource_cluster' setting. Defaults to 1.
%% </dd>
%% </dl>

-module(riak_repl2_fscoordinator).
-include("riak_repl.hrl").
Expand Down Expand Up @@ -107,7 +112,7 @@
%% API Function Definitions
%% ------------------------------------------------------------------

%% @doc Start a fullsync coordinator for managing a sycn to the remote `Cluster'.
%% @doc Start a fullsync coordinator for managing a sync to the remote Cluster.
-spec start_link(Cluster :: string()) -> {'ok', pid()}.
start_link(Cluster) ->
gen_server:start_link(?MODULE, Cluster, []).
Expand Down Expand Up @@ -142,7 +147,7 @@ status() ->
end.

%% @doc Get the status proplist for the given fullsync process. Same as
%% `status(Pid, infinity'.
%% `status(Pid, infinity)'.
%% @see status/2
-spec status(Pid :: pid()) -> [tuple()].
status(Pid) ->
Expand All @@ -159,7 +164,7 @@ status(Pid, Timeout) ->
[]
end.

%% @doc Return true if the given fullsync coordiniator is in the middle of
%% @doc Return true if the given fullsync coordinator is in the middle of
%% syncing, otherwise false.
-spec is_running(Pid :: pid()) -> boolean().
is_running(Pid) when is_pid(Pid) ->
Expand Down
2 changes: 1 addition & 1 deletion src/riak_repl2_ip.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
-include_lib("eunit/include/eunit.hrl").
-endif.

%% @doc Given the result of inet:getifaddrs() and an IP a client has
%% @doc Given the result of `inet:getifaddrs()' and an IP a client has
%% connected to, attempt to determine the appropriate subnet mask. If
%% the IP the client connected to cannot be found, undefined is returned.
determine_netmask(Ifaddrs, SeekIP) when is_list(SeekIP) ->
Expand Down
24 changes: 12 additions & 12 deletions src/riak_repl2_rtq.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ start_link() ->
-type start_option() :: overload_threshold_option() | overload_recover_option().
-type start_options() :: [start_option()].
%% @doc Start linked, registers to module name, with given options. This makes
%% testing some options a bit easier as it removes a dependance on app_helper.
%% testing some options a bit easier as it removes a dependence on `app_helper'.
-spec start_link(Options :: start_options()) -> {'ok', pid()}.
start_link(Options) ->
case ets:info(?overload_ets) of
Expand Down Expand Up @@ -152,7 +152,7 @@ set_max_bytes(MaxBytes) ->

%% @doc Push an item onto the queue. Bin should be the list of objects to push
%% run through term_to_binary, while NumItems is the length of that list
%% before being turned to a binary. Meta is an orddict() of data about the
%% before being turned to a binary. Meta is an orddict of data about the
%% queued item. The key `routed_clusters' is a list of the clusters the item
%% has received and ack for. The key `local_forwards' is added automatically.
%% It is a list of the remotes this cluster forwards to. It is intended to be
Expand All @@ -172,7 +172,7 @@ should_drop() ->
[{overloaded, Val}] = ets:lookup(?overload_ets, overloaded),
Val.

%% @doc Like push/3, only Meta is orddict:new/0.
%% @doc Like `push/3', only Meta is `orddict:new/0'.
-spec push(NumItems :: pos_integer(), Bin :: binary()) -> 'ok'.
push(NumItems, Bin) ->
push(NumItems, Bin, []).
Expand All @@ -197,26 +197,26 @@ pull_sync(Name, DeliverFun) ->
ack(Name, Seq) ->
gen_server:cast(?SERVER, {ack, Name, Seq}).

%% @doc Same as ack/2, but blocks the caller.
%% @doc Same as `ack/2', but blocks the caller.
-spec ack_sync(Name :: name(), Seq :: pos_integer()) ->'ok'.
ack_sync(Name, Seq) ->
gen_server:call(?SERVER, {ack_sync, Name, Seq}, infinity).

%% @doc The status of the queue.
%% <dl>
%% <dt>percent_bytes_used</dt><dd>How full the queue is in percentage to 3 significant digits</dd>
%% <dt>bytes</dt><dd>Size of the data store backend</dd>
%% <dt>max_bytes</dt><dd>Maximum size of the data store backend</dd>
%% <dt>consumers</dt><dd>Key - Value pair of the consumer stats, key is the
%% <dt>`percent_bytes_used'</dt><dd>How full the queue is in percentage to 3 significant digits</dd>
%% <dt>`bytes'</dt><dd>Size of the data store backend</dd>
%% <dt>`max_bytes'</dt><dd>Maximum size of the data store backend</dd>
%% <dt>`consumers'</dt><dd>Key - Value pair of the consumer stats, key is the
%% consumer name.</dd>
%% </dl>
%%
%% The consumers have the following data:
%% <dl>
%% <dt>pending</dt><dd>Number of queue items left to send.</dd>
%% <dt>unacked</dt><dd>Number of queue items that are sent, but not yet acked</dd>
%% <dt>drops</dt><dd>Dropped entries due to max_bytes</dd>
%% <dt>errs</dt><dd>Number of non-ok returns from deliver fun</dd>
%% <dt>`pending'</dt><dd>Number of queue items left to send.</dd>
%% <dt>`unacked'</dt><dd>Number of queue items that are sent, but not yet acked</dd>
%% <dt>`drops'</dt><dd>Dropped entries due to `max_bytes'</dd>
%% <dt>`errs'</dt><dd>Number of non-ok returns from deliver fun</dd>
%% </dl>
-spec status() -> [any()].
status() ->
Expand Down
2 changes: 1 addition & 1 deletion src/riak_repl2_rtsink_helper.erl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
%% Riak EnterpriseDS
%% Copyright (c) 2007-2012 Basho Technologies, Inc. All Rights Reserved.
-module(riak_repl2_rtsink_helper).

%% @doc Realtime replication sink module
%%
%% High level responsibility...
%% consider moving out socket responsibilities to another process
%% to keep this one responsive (but it would pretty much just do status)
%%
-module(riak_repl2_rtsink_helper).

%% API
-export([start_link/1,
Expand Down
18 changes: 9 additions & 9 deletions src/riak_repl2_rtsource_conn.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
%% Riak EnterpriseDS
%% Copyright (c) 2007-2012 Basho Technologies, Inc. All Rights Reserved.
-module(riak_repl2_rtsource_conn).

%% @doc Realtime replication source connection module
%%
Expand All @@ -9,29 +8,30 @@
%% process accepts the remote Acks and clears the RTQ.
%%
%% If both sides support heartbeat message, it is sent from the RT source
%% every {riak_repl, rt_heartbeat_interval} which default to 15s. If
%% every `{riak_repl, rt_heartbeat_interval}' which default to 15s. If
%% a response is not received in {riak_repl, rt_heartbeat_timeout}, also
%% default to 15s then the source connection exits and will be re-established
%% by the supervisor.
%%
%% 1. On startup/interval timer - rtsource_conn casts to rtsource_helper
%% to send over the socket. If TCP buffer is full or rtsource_helper
%% is otherwise hung the rtsource_conn process will still continue.
%% rtsource_conn sets up a heartbeat timeout.
%% 1. On startup/interval timer - `rtsource_conn' casts to `rtsource_helper'
%% to send over the socket. If TCP buffer is full or `rtsource_helper'
%% is otherwise hung the `rtsource_conn' process will still continue.
%% `rtsource_conn' sets up a heartbeat timeout.
%%
%% 2. At rtsink, on receipt of a heartbeat message it sends back
%% a heartbeat message and stores the timestamp it last received one.
%% The rtsink does not worry about detecting broken connections
%% as new ones can be established harmlessly. Keep it simple.
%%
%% 3. If rtsource receives the heartbeat back, it cancels the timer
%% and updates the hearbeat round trip time (hb_rtt) then sets
%% and updates the hearbeat round trip time (`hb_rtt') then sets
%% a new heartbeat_interval timer.
%%
%% If the heartbeat_timeout fires, the rtsource connection terminates.
%% The rtsource_helper:stop call is now wrapped in a timeout in
%% case it is hung so we don't get nasty messages about rtsource_conn
%% The `rtsource_helper:stop' call is now wrapped in a timeout in
%% case it is hung so we don't get nasty messages about `rtsource_conn'
%% crashing when it's the helper that is causing the problems.
-module(riak_repl2_rtsource_conn).

-behaviour(gen_server).
-include("riak_repl.hrl").
Expand Down
4 changes: 2 additions & 2 deletions src/riak_repl_fullsync_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,11 @@ missing_key(PBKey, DiffState) ->
%% purposefully created because if you use a lambda then things will
%% go wrong when the MD5 of this module changes. I.e. if the lambda is
%% shipped to another node with a different version of
%% riak_repl_fullsync_helper, even if the code inside the lambda is
%% `riak_repl_fullsync_helper', even if the code inside the lambda is
%% the same, then a badfun error will occur since the MD5s of the
%% modules are not the same.
%%
%% See http://www.javalimit.com/2010/05/passing-funs-to-other-erlang-nodes.html
%% See [http://www.javalimit.com/2010/05/passing-funs-to-other-erlang-nodes.html]
keylist_fold({B,Key}=K, V, {MPid, Count, Total}) ->
try
H = hash_object(B,Key,V),
Expand Down
6 changes: 4 additions & 2 deletions src/riak_repl_keylist_client.erl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
%% Riak EnterpriseDS
%% Copyright (c) 2007-2011 Basho Technologies, Inc. All Rights Reserved.
-module(riak_repl_keylist_client).

%% @doc This is the client-side component of the new fullsync strategy
%% introduced in riak 1.1. See the repl_keylist_server module for more
%% introduced in riak 1.1. See the `repl_keylist_server' module for more
%% information on the protocol and the improvements.
%%
%% @see repl_keylist_server
-module(riak_repl_keylist_client).

-behaviour(gen_fsm).

Expand Down
16 changes: 9 additions & 7 deletions src/riak_repl_keylist_server.erl
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
%% Riak EnterpriseDS
%% Copyright (c) 2007-2011 Basho Technologies, Inc. All Rights Reserved.
-module(riak_repl_keylist_server).

%% @doc This is the server-side component of the new fullsync strategy
%% introduced in riak 1.1. It is an improvement over the previous strategy in
%% several ways:
%%
%% * Client and server build keylist in parallel
%% * No useless merkle tree is built
%% * Differences are calculated and transmitted in batches, not all in one
%% message
%% * Backpressure is introduced in the exchange of differences
%% * Pausing/cancelling the diff is immediate
%% <ul>
%% <li>Client and server build keylist in parallel</li>
%% <li>No useless merkle tree is built</li>
%% <li>Differences are calculated and transmitted in batches, not all in one
%% message</li>
%% <li>Backpressure is introduced in the exchange of differences</li>
%% <li>Pausing/cancelling the diff is immediate</li>
%% </ul>
%%
%% In addition, the client does the requesting of partition data, which makes
%% this more of a pull model as compared to the legacy strategy, which was more
Expand All @@ -34,6 +35,7 @@
%%
%% Note that the new key list algorithm uses a bloom fold filter to keep the
%% keys in disk-order to speed up the key-list creation process.
-module(riak_repl_keylist_server).

-behaviour(gen_fsm).

Expand Down
Loading

0 comments on commit 7d0a3d2

Please sign in to comment.