Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another round of Dialyzer work. #564

Merged
merged 17 commits into from
Mar 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dialyzer.ignore-warnings
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ riak_repl_keylist_client.erl:264: The call application:unset_env('riak_repl',{'p
riak_repl_keylist_client.erl:116: The call application:unset_env('riak_repl',{'progress',_}) breaks the contract (Application,Par) -> 'ok' when is_subtype(Application,atom()), is_subtype(Par,atom())
riak_repl_keylist_client.erl:128: The call application:set_env('riak_repl',{'progress',_},nonempty_maybe_improper_list()) breaks the contract (Application,Par,Val) -> 'ok' when is_subtype(Application,atom()), is_subtype(Par,atom()), is_subtype(Val,term())
riak_repl_leader_helper.erl:24: Callback info about the gen_leader behaviour is not available
riak_core_connection.erl:108: Function exchange_handshakes_with/4 has no local return
riak_core_connection.erl:110: The call ranch_tcp:send(Socket::port(),Hello::binary()) breaks the contract (inet:socket(),iolist()) -> 'ok' | {'error',atom()}
riak_core_connection.erl:189: Function try_ssl/4 will never be called
riak_core_connection.erl:225: Function negotiate_proto_with_server/3 will never be called
6 changes: 3 additions & 3 deletions src/gen_leader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ init_it(Starter,Parent,Name,Mod,{CandidateNodes,OptArgs,Arg},Options) ->
proc_lib:init_ack(Starter, {ok, self()}),
case lists:member(self(), Workers) of
false ->
rpc:multicall(CandidateNodes,
gen_leader, worker_announce,
[Name, node(self())]),
_ = rpc:multicall(CandidateNodes,
gen_leader, worker_announce,
[Name, node(self())]),
ok;
_ ->
ok
Expand Down
2 changes: 1 addition & 1 deletion src/riak_core_cluster_mgr.erl
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ persist_members_to_ring(State, ClusterName, Members) ->
%% that were saved in the ring
cluster_mgr_sites_fun() ->
%% get cluster names from cluster manager
Ring = riak_core_ring_manager:get_my_ring(),
{ok, Ring} = riak_core_ring_manager:get_my_ring(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, good catch. Amazing this hasn't caused issues in the past

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've flattened a bunch of the locator stuff, so it's probably used in very few cases at this point.

Clusters = riak_repl_ring:get_clusters(Ring),
[{?CLUSTER_NAME_LOCATOR_TYPE, Name} || {Name, _Addrs} <- Clusters].

Expand Down
3 changes: 1 addition & 2 deletions src/riak_core_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@
%%
%% -------------------------------------------------------------------
-module(riak_core_connection).
-author("Chris Tilt").

-include("riak_core_connection.hrl").

-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.


%% public API
-export([connect/2,
sync_connect/2]).
Expand Down Expand Up @@ -98,6 +96,7 @@ connect({IP,Port}, ClientSpec) ->
%% start a process to handle the connection request asyncrhonously
proc_lib:spawn_link(?MODULE, async_connect_proc, [self(), {IP,Port}, ClientSpec]).

-spec sync_connect(ip_addr(), clientspec()) -> ok | {error, atom()}.
sync_connect({IP,Port}, ClientSpec) ->
sync_connect_status(self(), {IP,Port}, ClientSpec).

Expand Down
2 changes: 1 addition & 1 deletion src/riak_core_connection_mgr.erl
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ fail_endpoint(Addr, Reason, ProtocolId, State) ->
nb_failures = EP#ep.nb_failures + 1,
backoff_delay = increase_backoff(Backoff),
last_fail_time = os:timestamp(),
next_try_secs = Backoff/1000,
next_try_secs = erlang:trunc(Backoff/1000),
is_black_listed = true}
end,
update_endpoint(Addr, Fun, State).
Expand Down
13 changes: 5 additions & 8 deletions src/riak_core_connection_mgr_stats.erl
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).

register_stats() ->
[(catch folsom_metrics:delete_metric(Stat)) || Stat <- folsom_metrics:get_metrics(),
is_tuple(Stat), element(1, Stat) == ?APP],
[register_stat({?APP, Name}, Type) || {Name, Type} <- stats()],
_ = [(catch folsom_metrics:delete_metric(Stat)) ||
Stat <- folsom_metrics:get_metrics(),
is_tuple(Stat), element(1, Stat) == ?APP],
riak_core_stat_cache:register_app(?APP, {?MODULE, produce_stats, []}).

%% @spec get_stats() -> proplist()
Expand Down Expand Up @@ -264,9 +264,9 @@ create_or_update(Name, UpdateVal, Type) ->
end.

register_stat(Name, spiral) ->
folsom_metrics:new_spiral(Name);
ok = folsom_metrics:new_spiral(Name);
register_stat(Name, counter) ->
folsom_metrics:new_counter(Name).
ok = folsom_metrics:new_counter(Name).

%% @spec produce_stats() -> proplist()
%% @doc Produce a proplist-formatted view of the current aggregation
Expand All @@ -279,6 +279,3 @@ produce_stats() ->
%% NOTE: won't work for Histograms
get_stat(Name) ->
folsom_metrics:get_metric_value(Name).

%% Return list of static stat names and types to register
stats() -> []. %% no static stats to register
6 changes: 4 additions & 2 deletions src/riak_repl2_leader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ handle_info(check_mailbox, State) when State#state.i_am_leader =:= false,
exit(normal)
catch
_:_ ->
ok
exit(normal)
after
exit(normal)
end
end,

exit(normal)
end),
{noreply, State};
handle_info(check_mailbox, State) ->
Expand Down
6 changes: 3 additions & 3 deletions src/riak_repl_console.erl
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ disconnect([Address]) ->
2 ->
IP = string:sub_word(Address, 1, $:),
PortStr = string:sub_word(Address, 2, $:),
disconnect([IP, PortStr]),
_ = disconnect([IP, PortStr]),
ok;
_ ->
{error, {badarg, Address}}
Expand Down Expand Up @@ -470,12 +470,12 @@ fullsync([Cmd]) ->
case Cmd of
"start" ->
?LOG_USER_CMD("Start Fullsync Replication to all connected clusters",[]),
[riak_repl2_fscoordinator:start_fullsync(Pid) || {_, Pid} <-
_ = [riak_repl2_fscoordinator:start_fullsync(Pid) || {_, Pid} <-
Fullsyncs],
ok;
"stop" ->
?LOG_USER_CMD("Stop Fullsync Replication to all connected clusters",[]),
[riak_repl2_fscoordinator:stop_fullsync(Pid) || {_, Pid} <-
_ = [riak_repl2_fscoordinator:stop_fullsync(Pid) || {_, Pid} <-
Fullsyncs],
ok
end,
Expand Down
19 changes: 12 additions & 7 deletions src/riak_repl_fullsync_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ handle_call({get, B, K, Transport, Socket, Pool, Ver}, From, State) ->
%% key and let the other side sort things out.
case riak_repl_util:repl_helper_send(RObj, Client) of
cancel ->
skipped;
ok;
Objects when is_list(Objects) ->
%% Cindy: Santa, why can we encode our own binary object?
%% Santa: Because the send() function will convert our tuple
Expand All @@ -56,7 +56,8 @@ handle_call({get, B, K, Transport, Socket, Pool, Ver}, From, State) ->
|| O <- Objects],
_ = riak_repl_tcp_server:send(Transport, Socket,
riak_repl_util:encode_obj_msg(
Ver,{fs_diff_obj,RObj}))
Ver,{fs_diff_obj,RObj})),
ok
end,
ok;
{error, notfound} ->
Expand All @@ -78,7 +79,7 @@ handle_call({get, B, K, Transport, Socket, Pool, Partition, Ver}, From, State) -

Preflist = [{Partition, OwnerNode}],

ReqID = make_ref(),
ReqID = make_req_id(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, another great catch.


Req = ?KV_GET_REQ{bkey={B, K}, req_id=ReqID},
%% Assuming this function is called from a FSM process
Expand All @@ -97,18 +98,19 @@ handle_call({get, B, K, Transport, Socket, Pool, Partition, Ver}, From, State) -
{ok, Client} = riak:local_client(),
case riak_repl_util:repl_helper_send(RObj, Client) of
cancel ->
skipped;
ok;
Objects when is_list(Objects) ->
%% Cindy: Santa, why can we encode our own binary object?
%% Santa: Because, Cindy, the send() function accepts
%% either a binary or a term.
[riak_repl_tcp_server:send(Transport, Socket,
_ = [riak_repl_tcp_server:send(Transport, Socket,
riak_repl_util:encode_obj_msg(
Ver,{fs_diff_obj,O}))
|| O <- Objects],
riak_repl_tcp_server:send(Transport, Socket,
_ = riak_repl_tcp_server:send(Transport, Socket,
riak_repl_util:encode_obj_msg(
Ver,{fs_diff_obj,RObj}))
Ver,{fs_diff_obj,RObj})),
ok
end,
ok;
{r, {error, notfound}, _, ReqID} ->
Expand Down Expand Up @@ -161,3 +163,6 @@ do_binputs_internal(BinObjs, DoneFun, Pool, Ver) ->
poolboy:checkin(Pool, self()),
%% let the caller know
DoneFun().

make_req_id() ->
erlang:phash2({self(), os:timestamp()}). % stolen from riak_client
9 changes: 6 additions & 3 deletions src/riak_repl_leader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,12 @@ handle_info(check_mailbox, State) when State#state.i_am_leader =:= false,
exit(normal)
catch
_:_ ->
ok
exit(normal)
after
exit(normal)
end
end,

exit(normal)
end),
{noreply, State};
handle_info(check_mailbox, State) ->
Expand Down Expand Up @@ -499,7 +501,8 @@ ensure_sites(Leader) ->
_ = [rpc:call(Node, riak_repl_client_sup, stop_site, [Site])
|| {Node, Site} <- ToStop],
_ = [rpc:call(Node, riak_repl_client_sup, start_site, [Site])
|| {Node, Site} <- ToStart]
|| {Node, Site} <- ToStart],
ok
end
end.

Expand Down