Skip to content

Commit

Permalink
Cleanup build with gen_fsm_compat and removing erlang:now(). Added
Browse files Browse the repository at this point in the history
warnings_as_errors back.
  • Loading branch information
Martin Cox committed Mar 6, 2019
1 parent 0588c2c commit 18572a5
Show file tree
Hide file tree
Showing 23 changed files with 133 additions and 95 deletions.
21 changes: 11 additions & 10 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{erl_first_files, ["src/gen_nb_server.erl", "src/riak_core_gen_server.erl",
"src/riak_core_stat_xform"]}.
{cover_enabled, true}.
{erl_opts, [%warnings_as_errors,
{erl_opts, [warnings_as_errors,
{parse_transform, lager_transform},
debug_info, {platform_define, "^[0-9]+", namespaced_types},
{platform_define, "^R15", "old_hash"}]}.
Expand All @@ -13,15 +13,16 @@
{plugins, [{rebar3_eqc, {git, "https://github.com/Vagabond/rebar3-eqc-plugin", {branch, "master"}}}]}.

{deps, [
{lager, ".*", {git, "git://github.com/erlang-lager/lager.git", {tag, "3.6.1"}}},
{poolboy, ".*", {git, "git://github.com/devinus/poolboy.git", {branch, "master"}}},
{basho_stats, ".*", {git, "git://github.com/basho/basho_stats.git", {branch, "develop-3.0"}}},
{riak_sysmon, ".*", {git, "https://github.com/basho/riak_sysmon.git", {branch, "develop-3.0"}}},
{eleveldb, ".*", {git, "git://github.com/basho/eleveldb.git", {branch, "develop-3.0"}}},
{riak_ensemble, ".*", {git, "https://github.com/basho/riak_ensemble", {branch, "develop-3.0"}}},
{pbkdf2, ".*", {git, "git://github.com/basho/erlang-pbkdf2.git", {branch, "develop-3.0"}}},
exometer_core,
{clique, ".*", {git, "https://github.com/basho/clique.git", {branch, "develop-3.0"}}}
gen_fsm_compat,
{lager, {git, "git://github.com/erlang-lager/lager.git", {tag, "3.6.1"}}},
{poolboy, {git, "git://github.com/devinus/poolboy.git", {branch, "master"}}},
{basho_stats, {git, "git://github.com/basho/basho_stats.git", {branch, "develop-3.0"}}},
{riak_sysmon, {git, "https://github.com/basho/riak_sysmon.git", {branch, "develop-3.0"}}},
{eleveldb, {git, "git://github.com/basho/eleveldb.git", {branch, "develop-3.0"}}},
{riak_ensemble, {git, "https://github.com/basho/riak_ensemble", {branch, "develop-3.0"}}},
{pbkdf2, {git, "git://github.com/basho/erlang-pbkdf2.git", {branch, "develop-3.0"}}},
exometer_core,
{clique, {git, "https://github.com/basho/clique.git", {branch, "develop-3.0"}}}
]}.

{profiles, [
Expand Down
18 changes: 10 additions & 8 deletions rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
{git,"git://github.com/basho/basho_stats.git",
{ref,"176dee0537b5b3aff57646a7379d435ad990488e"}},
0},
{<<"bear">>,{pkg,<<"bear">>,<<"0.8.5">>},2},
{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},2},
{<<"clique">>,
{git,"https://github.com/basho/clique.git",
{ref,"ac5e7b9e68508546e02108e81b7e8d83e1008a0a"}},
{ref,"54d3a9fa2fe3fbe163185232097379b66c3388dc"}},
0},
{<<"cuttlefish">>,
{git,"https://github.com/basho/cuttlefish.git",
Expand All @@ -17,7 +17,8 @@
{ref,"db361b1a8387262e715b27fbdd9353f00a07302c"}},
0},
{<<"exometer_core">>,{pkg,<<"exometer_core">>,<<"1.5.2">>},0},
{<<"folsom">>,{pkg,<<"folsom">>,<<"0.8.5">>},1},
{<<"folsom">>,{pkg,<<"folsom">>,<<"0.8.7">>},1},
{<<"gen_fsm_compat">>,{pkg,<<"gen_fsm_compat">>,<<"0.3.0">>},0},
{<<"getopt">>,
{git,"https://github.com/basho/getopt.git",
{ref,"880030ff0cbecb73ba75a78a7aa0cc1dcb7fe331"}},
Expand All @@ -35,22 +36,23 @@
0},
{<<"poolboy">>,
{git,"git://github.com/devinus/poolboy.git",
{ref,"d378f996182daa6251ad5438cee4d3f6eb7ea50f"}},
{ref,"9212a8770edb149ee7ca0bca353855e215f7cba5"}},
0},
{<<"riak_ensemble">>,
{git,"https://github.com/basho/riak_ensemble",
{ref,"277eb48dca59475b639a01d86fd0c550cae4da55"}},
{ref,"0433e275e82943aa926f22c37e7e75d43912e3f2"}},
0},
{<<"riak_sysmon">>,
{git,"https://github.com/basho/riak_sysmon.git",
{ref,"ad309757fd6fa9cdb8a84ee8a132061688f8a06f"}},
{ref,"3e0b912c26a94a2f1b8f7331678128528b13c64b"}},
0},
{<<"setup">>,{pkg,<<"setup">>,<<"1.8.4">>},1}]}.
[
{pkg_hash,[
{<<"bear">>, <<"E95FCA1627CD9E15BAF93CE0A52AFF16917BAF325F0EE65B88CD715376CD2344">>},
{<<"bear">>, <<"16264309AE5D005D03718A5C82641FCC259C9E8F09ADEB6FD79CA4271168656F">>},
{<<"exometer_core">>, <<"62A99A361BA8A14D53857D4C716A191E810299D2F43C5C981EB7B086C0BFCCE1">>},
{<<"folsom">>, <<"94A027B56FE84FEED264F9B33CB4C6AC9A801FAD84B87DBDA0836CE83C3B8D69">>},
{<<"folsom">>, <<"A885F0AEEE4C84270954C88A55A5A473D6B2C7493E32FFDC5765412DD555A951">>},
{<<"gen_fsm_compat">>, <<"5903549F67D595F58A7101154CBE0FDD46955FBFBE40813F1E53C23A970FF5F4">>},
{<<"goldrush">>, <<"F06E5D5F1277DA5C413E84D5A2924174182FB108DABB39D5EC548B27424CD106">>},
{<<"hut">>, <<"0089DF0FAA2827C605BBADA88153F24FFF5EA7A4BE32ECF0250A7FDC2719CAFB">>},
{<<"parse_trans">>, <<"9E96B1C9C3A0DF54E7B76F8F685D38BFA1EB21B31E042B1D1A5A70258E4DB1E3">>},
Expand Down
2 changes: 1 addition & 1 deletion src/hashtree.erl
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ new_segment_store(Opts, State) ->
DataDir = case proplists:get_value(segment_path, Opts) of
undefined ->
Root = "/tmp/anti/level",
<<P:128/integer>> = md5(term_to_binary({erlang:now(), make_ref()})),
<<P:128/integer>> = md5(term_to_binary({os:timestamp(), make_ref()})),
filename:join(Root, integer_to_list(P));
SegmentPath ->
SegmentPath
Expand Down
2 changes: 1 addition & 1 deletion src/hashtree_tree.erl
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ data_root(Opts) ->
case proplists:get_value(data_dir, Opts) of
undefined ->
Base = "/tmp/hashtree_tree",
<<P:128/integer>> = riak_core_util:md5(term_to_binary(erlang:now())),
<<P:128/integer>> = riak_core_util:md5(term_to_binary(os:timestamp())),
filename:join(Base, riak_core_util:integer_to_list(P, 16));
Root -> Root
end.
2 changes: 1 addition & 1 deletion src/riak_core.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{vsn, git},
{modules, []},
{registered, []},
{included_applications, [folsom, riak_ensemble]},
{included_applications, [riak_ensemble]},
{applications, [
kernel,
stdlib,
Expand Down
32 changes: 31 additions & 1 deletion src/riak_core_claim_sim.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,37 @@
%% @doc riak_core_claim_sim models adding/removing nodes from the ring
%%
-module(riak_core_claim_sim).
-compile(export_all).

-export([help/0,
run/1,
add_choose_params/2,
run_rebalance/4,
read_ringfile/1,
setup_environment/1,
dryrun/3,
make_current/2,
make_prepared/3,
make_postxfer/2,
make_percmd/1,
make_rebalance/2,
make_analysis/2,
default_simopts/3,
dryrun1/3,
sim_node/1,
command/2,
pretty_print/3,
run_analysis/3,
o/2,
o/3,
commission/0,
commission/1,
commission/2,
commission/3,
commission_test_dir/6,
commission_tests_all/0,
commission_tests_first/0,
commission_tests_rest/0,
commission_claims/0]).

-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
Expand Down
14 changes: 7 additions & 7 deletions src/riak_core_claimant.erl
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ bucket_type_iterator() ->
%%%===================================================================

reassign_indices(CState) ->
reassign_indices(CState, [], erlang:now(), fun no_log/2).
reassign_indices(CState, [], os:timestamp(), fun no_log/2).

%%%===================================================================
%%% Internal API helpers
Expand All @@ -250,7 +250,7 @@ maybe_filter_inactive_type(true, Default, Props) ->

init([]) ->
schedule_tick(),
{ok, #state{changes=[], seed=erlang:now()}}.
{ok, #state{changes=[], seed=os:timestamp()}}.

handle_call(clear, _From, State) ->
State2 = clear_staged(State),
Expand Down Expand Up @@ -388,7 +388,7 @@ commit_staged(State) ->
{ok, _} ->
State2 = State#state{next_ring=undefined,
changes=[],
seed=erlang:now()},
seed=os:timestamp()},
{ok, State2};
not_changed ->
{error, State};
Expand Down Expand Up @@ -438,7 +438,7 @@ maybe_commit_staged(Ring, NextRing, #state{next_ring=PlannedRing}) ->
%% call {@link clear/0}.
clear_staged(State) ->
remove_joining_nodes(),
State#state{changes=[], seed=erlang:now()}.
State#state{changes=[], seed=os:timestamp()}.

%% @private
remove_joining_nodes() ->
Expand Down Expand Up @@ -662,7 +662,7 @@ maybe_force_ring_update(Ring) ->
end.

do_maybe_force_ring_update(Ring) ->
case compute_next_ring([], erlang:now(), Ring) of
case compute_next_ring([], os:timestamp(), Ring) of
{ok, NextRing} ->
case same_plan(Ring, NextRing) of
false ->
Expand Down Expand Up @@ -1109,7 +1109,7 @@ internal_ring_changed(Node, CState) ->
%% Set cluster name if it is undefined
case {IsClaimant, riak_core_ring:cluster_name(CState5)} of
{true, undefined} ->
ClusterName = {Node, erlang:now()},
ClusterName = {Node, os:timestamp()},
{_,_} = riak_core_util:rpc_every_member(riak_core_ring_manager,
set_cluster_name,
[ClusterName],
Expand Down Expand Up @@ -1143,7 +1143,7 @@ do_claimant_quiet(Node, CState, Replacing, Seed) ->
do_claimant(Node, CState, Replacing, Seed, fun no_log/2).

do_claimant(Node, CState, Log) ->
do_claimant(Node, CState, [], erlang:now(), Log).
do_claimant(Node, CState, [], os:timestamp(), Log).

do_claimant(Node, CState, Replacing, Seed, Log) ->
AreJoining = are_joining_nodes(CState),
Expand Down
10 changes: 5 additions & 5 deletions src/riak_core_coverage_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

-include("riak_core_vnode.hrl").

-behaviour(gen_fsm).
-behaviour(gen_fsm_compat).

%% API
-export([behaviour_info/1]).
Expand Down Expand Up @@ -127,7 +127,7 @@ behaviour_info(_) ->
-spec start_link(module(), from(), [term()]) ->
{ok, pid()} | ignore | {error, term()}.
start_link(Mod, From, RequestArgs) ->
gen_fsm:start_link(?MODULE, [Mod, From, RequestArgs], []).
gen_fsm_compat:start_link(?MODULE, [Mod, From, RequestArgs], []).

%% ===================================================================
%% Test API
Expand All @@ -138,7 +138,7 @@ start_link(Mod, From, RequestArgs) ->
%% Create a coverage FSM for testing.
test_link(Mod, From, RequestArgs, _Options, StateProps) ->
Timeout = 60000,
gen_fsm:start_link(?MODULE,
gen_fsm_compat:start_link(?MODULE,
{test,
[Mod,
From,
Expand All @@ -150,7 +150,7 @@ test_link(Mod, From, RequestArgs, _Options, StateProps) ->
-endif.

%% ====================================================================
%% gen_fsm callbacks
%% gen_fsm_compat callbacks
%% ====================================================================

%% @private
Expand Down Expand Up @@ -200,7 +200,7 @@ maybe_start_timeout_timer(infinity) ->
maybe_start_timeout_timer(Bad) when not is_integer(Bad) ->
maybe_start_timeout_timer(?DEFAULT_TIMEOUT);
maybe_start_timeout_timer(Timeout) ->
gen_fsm:start_timer(Timeout, {timer_expired, Timeout}),
gen_fsm_compat:start_timer(Timeout, {timer_expired, Timeout}),
ok.


Expand Down
2 changes: 1 addition & 1 deletion src/riak_core_gossip.erl
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ log_node_removed(Node, Old) ->
lager:info("'~s' removed from cluster (previously: '~s')~n", [Node, Old]).

remove_from_cluster(Ring, ExitingNode) ->
remove_from_cluster(Ring, ExitingNode, rand:seed(exrop, erlang:now())).
remove_from_cluster(Ring, ExitingNode, rand:seed(exrop, os:timestamp())).

remove_from_cluster(Ring, ExitingNode, Seed) ->
% Get a list of indices owned by the ExitingNode...
Expand Down
2 changes: 1 addition & 1 deletion src/riak_core_handoff_receiver.erl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ process_message(?PT_MSG_BATCH, MsgData, State) ->
process_message(?PT_MSG_OBJ, MsgData, State=#state{vnode=VNode, count=Count,
vnode_timeout_len=VNodeTimeout}) ->
Msg = {handoff_data, MsgData},
try gen_fsm:sync_send_all_state_event(VNode, Msg, VNodeTimeout) of
try gen_fsm_compat:sync_send_all_state_event(VNode, Msg, VNodeTimeout) of
ok ->
State#state{count=Count+1};
E={error, _} ->
Expand Down
10 changes: 5 additions & 5 deletions src/riak_core_handoff_sender.erl
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ start_fold(TargetNode, Module, {Type, Opts}, ParentPid, SslOpts) ->
riak_core_format:human_size_fmt("~.2f", ThroughputBytes)]),
case Type of
repair -> ok;
resize -> gen_fsm:send_event(ParentPid, {resize_transfer_complete,
resize -> gen_fsm_compat:send_event(ParentPid, {resize_transfer_complete,
NotSentAcc});
_ -> gen_fsm:send_event(ParentPid, handoff_complete)
_ -> gen_fsm_compat:send_event(ParentPid, handoff_complete)
end;
{error, ErrReason} ->
if ErrReason == timeout ->
Expand All @@ -273,15 +273,15 @@ start_fold(TargetNode, Module, {Type, Opts}, ParentPid, SslOpts) ->
exit({shutdown, timeout});
exit:{shutdown, {error, Reason}} ->
?log_fail("because of ~p", [Reason]),
gen_fsm:send_event(ParentPid, {handoff_error,
gen_fsm_compat:send_event(ParentPid, {handoff_error,
fold_error, Reason}),
exit({shutdown, {error, Reason}});
throw:{be_quiet, Err, Reason} ->
gen_fsm:send_event(ParentPid, {handoff_error, Err, Reason});
gen_fsm_compat:send_event(ParentPid, {handoff_error, Err, Reason});
Err:Reason ->
?log_fail("because of ~p:~p ~p",
[Err, Reason, erlang:get_stacktrace()]),
gen_fsm:send_event(ParentPid, {handoff_error, Err, Reason})
gen_fsm_compat:send_event(ParentPid, {handoff_error, Err, Reason})
end.

start_visit_item_timer() ->
Expand Down
16 changes: 8 additions & 8 deletions src/riak_core_metadata_exchange_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
%% -------------------------------------------------------------------
-module(riak_core_metadata_exchange_fsm).

-behaviour(gen_fsm).
-behaviour(gen_fsm_compat).

%% API
-export([start/2]).

%% gen_fsm callbacks
%% gen_fsm_compat callbacks
-export([init/1, handle_event/3, handle_sync_event/4,
handle_info/3, terminate/3, code_change/4]).

%% gen_fsm states
%% gen_fsm_compat states
-export([prepare/2,
prepare/3,
update/2,
Expand Down Expand Up @@ -71,14 +71,14 @@
%% to aqcuire the remote lock or to upate both trees.
-spec start(node(), pos_integer()) -> {ok, pid()} | ignore | {error, term()}.
start(Peer, Timeout) ->
gen_fsm:start(?MODULE, [Peer, Timeout], []).
gen_fsm_compat:start(?MODULE, [Peer, Timeout], []).

%%%===================================================================
%%% gen_fsm callbacks
%%% gen_fsm_compat callbacks
%%%===================================================================

init([Peer, Timeout]) ->
gen_fsm:send_event(self(), start),
gen_fsm_compat:send_event(self(), start),
{ok, prepare, #state{peer=Peer,built=0,timeout=Timeout}}.

handle_event(_Event, StateName, State) ->
Expand All @@ -98,7 +98,7 @@ code_change(_OldVsn, StateName, State, _Extra) ->
{ok, StateName, State}.

%%%===================================================================
%%% gen_fsm states
%%% gen_fsm_compat states
%%%===================================================================
prepare(start, State) ->
%% get local lock
Expand Down Expand Up @@ -296,6 +296,6 @@ as_event(F) ->
Self = self(),
spawn_link(fun() ->
Result = F(),
gen_fsm:send_event(Self, Result)
gen_fsm_compat:send_event(Self, Result)
end),
ok.
2 changes: 1 addition & 1 deletion src/riak_core_ring.erl
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ fresh(RingSize, NodeName) ->
VClock=vclock:increment(NodeName, vclock:fresh()),
GossipVsn = riak_core_gossip:gossip_version(),
?CHSTATE{nodename=NodeName,
clustername={NodeName, erlang:now()},
clustername={NodeName, os:timestamp()},
members=[{NodeName, {valid, VClock, [{gossip_vsn, GossipVsn}]}}],
chring=chash:fresh(RingSize, NodeName),
next=[],
Expand Down
2 changes: 1 addition & 1 deletion src/riak_core_ring_manager.erl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ force_update() ->
ring_trans(
fun(Ring, _) ->
NewRing = riak_core_ring:update_member_meta(node(), Ring, node(),
unused, now()),
unused, os:timestamp()),
{new_ring, NewRing}
end, []),
ok.
Expand Down
Loading

0 comments on commit 18572a5

Please sign in to comment.