Skip to content
Browse files

Merge branch '1.2'

Conflicts:
	rebar.config
  • Loading branch information...
2 parents fd21fea + 7cff01c commit 3b66b12dae0313fce2a395c3cbdf9f8d73c3ec7b @kellymclaughlin kellymclaughlin committed Sep 27, 2012
View
2 ebin/riak_core.app
@@ -3,7 +3,7 @@
{application, riak_core,
[
{description, "Riak Core"},
- {vsn, "1.2.0"},
+ {vsn, "1.2.1"},
{modules, [
app_helper,
bloom,
View
13 src/riak_core_capability.erl
@@ -216,14 +216,17 @@ handle_call({ring_changed, Ring}, _From, State) ->
State2 = update_supported(Ring, State),
{reply, ok, State2}.
-handle_cast(tick, State) ->
+handle_cast(_Msg, State) ->
+ {noreply, State}.
+
+handle_info(tick, State) ->
schedule_tick(),
State2 =
lists:foldl(fun(Node, StateAcc) ->
add_node(Node, [], StateAcc)
end, State, State#state.unknown),
State3 = renegotiate_capabilities(State2),
- {noreply, State3}.
+ {noreply, State3};
handle_info(_Info, State) ->
{noreply, State}.
@@ -245,7 +248,7 @@ schedule_tick() ->
Tick = app_helper:get_env(riak_core,
capability_tick,
10000),
- timer:apply_after(Tick, gen_server, cast, [?MODULE, tick]).
+ erlang:send_after(Tick, ?MODULE, tick).
%% Capabilities are re-initialized if riak_core_capability server crashes
reload(State=#state{registered=[]}) ->
@@ -374,9 +377,7 @@ publish_supported(State) ->
ignore
end
end,
- spawn(fun() ->
- riak_core_ring_manager:ring_trans(F, ok)
- end),
+ riak_core_ring_manager:ring_trans(F, ok),
ok.
%% Add a node's capabilities to the provided ring
View
8 src/riak_core_dtrace.erl
@@ -201,9 +201,9 @@ timeit_mochiglobal_test() ->
Reps = lists:seq(1, ?REPS),
test_common("timeit_mochiglobal",
fun() ->
- Start = now(),
+ Start = os:timestamp(),
[?MODULE:timeit_mg([42]) || _ <- Reps],
- [unused, {timer:now_diff(now(), Start), unused}]
+ [unused, {timer:now_diff(os:timestamp(), Start), unused}]
end,
?REPS),
mochiglobal:delete(?MAGIC).
@@ -238,10 +238,10 @@ timeit_best_common(Label, InitTheDTraceStuff_p) ->
Reps = lists:seq(1, ?REPS),
test_common(Label,
fun() ->
- Start = now(),
+ Start = os:timestamp(),
[?MODULE:timeit_best([42]) || _ <- Reps],
%% X = lists:usort([?MODULE:timeit_best([42]) || _ <- Reps]), io:format(user, "Label ~s out ~p\n", [Label, X]),
- [unused, {timer:now_diff(now(), Start), unused}]
+ [unused, {timer:now_diff(os:timestamp(), Start), unused}]
end,
?REPS)
end.
View
4 src/riak_core_gen_server.erl
@@ -419,7 +419,7 @@ loop(Parent, Name, State, Mod, hibernate, undefined, Queue, Debug) ->
loop(Parent, Name, State, Mod, hibernate, {Current, Min, undefined}, Queue,
Debug) ->
proc_lib:hibernate(?MODULE,wake_hib,[Parent, Name, State, Mod,
- {Current, Min, now()}, Queue, Debug]);
+ {Current, Min, os:timestamp()}, Queue, Debug]);
loop(Parent, Name, State, Mod, Time, TimeoutState, Queue, Debug) ->
receive
Input -> loop(Parent, Name, State, Mod,
@@ -462,7 +462,7 @@ wake_hib(Parent, Name, State, Mod, TimeoutState, Queue, Debug) ->
adjust_hibernate_after(undefined) ->
undefined;
adjust_hibernate_after({Current, Min, HibernatedAt}) ->
- NapLengthMicros = timer:now_diff(now(), HibernatedAt),
+ NapLengthMicros = timer:now_diff(os:timestamp(), HibernatedAt),
CurrentMicros = Current * 1000,
LowTargetMicros = CurrentMicros * 4,
HighTargetMicros = LowTargetMicros * 4,
View
15 src/riak_core_gossip.erl
@@ -297,12 +297,6 @@ handle_cast({reconcile_ring, RingIn}, State) ->
{noreply, State2}
end;
-handle_cast(reset_tokens, State) ->
- schedule_next_reset(),
- gen_server:cast(?MODULE, gossip_ring),
- {Tokens, _} = app_helper:get_env(riak_core, gossip_limit, ?DEFAULT_LIMIT),
- {noreply, State#state{gossip_tokens=Tokens}};
-
handle_cast(gossip_ring, State) ->
% Gossip the ring to some random other node...
{ok, MyRing} = riak_core_ring_manager:get_raw_ring(),
@@ -328,7 +322,12 @@ handle_cast({rejoin, RingIn}, State) ->
handle_cast(_, State) ->
{noreply, State}.
-%% @private
+handle_info(reset_tokens, State) ->
+ schedule_next_reset(),
+ gen_server:cast(?MODULE, gossip_ring),
+ {Tokens, _} = app_helper:get_env(riak_core, gossip_limit, ?DEFAULT_LIMIT),
+ {noreply, State#state{gossip_tokens=Tokens}};
+
handle_info(_Info, State) -> {noreply, State}.
%% @private
@@ -346,7 +345,7 @@ code_change(_OldVsn, State, _Extra) ->
schedule_next_reset() ->
{_, Reset} = app_helper:get_env(riak_core, gossip_limit, ?DEFAULT_LIMIT),
- timer:apply_after(Reset, gen_server, cast, [?MODULE, reset_tokens]).
+ erlang:send_after(Reset, ?MODULE, reset_tokens).
reconcile(Ring0, [OtherRing0]) ->
%% Due to rolling upgrades and legacy gossip, a ring's cluster name
View
4 src/riak_core_handoff_manager.erl
@@ -463,7 +463,7 @@ send_handoff({Mod, Src, Target}, Node, Vnode, HS, {Filter, FilterModFun}, Origin
{ok, #handoff_status{ transport_pid=Pid,
transport_mon=PidM,
direction=outbound,
- timestamp=now(),
+ timestamp=os:timestamp(),
src_node=node(),
target_node=Node,
mod_src_tgt={Mod, Src, Target},
@@ -496,7 +496,7 @@ receive_handoff (SSLOpts) ->
{ok, #handoff_status{ transport_pid=Pid,
transport_mon=PidM,
direction=inbound,
- timestamp=now(),
+ timestamp=os:timestamp(),
mod_src_tgt={undefined, undefined, undefined},
src_node=undefined,
target_node=undefined,
View
2 src/riak_core_tracer.erl
@@ -125,7 +125,7 @@ handle_call({collect, Duration, Nodes}, _From, State) ->
[] ->
ok;
_ ->
- {Mega, Secs, Micro} = now(),
+ {Mega, Secs, Micro} = os:timestamp(),
Ts = 1000000 * (1000000 * Mega + Secs) + Micro,
TsEntries = [{Ts, E} || E <- Entries],
gen_server:call(Pid, {traces, TsEntries})
View
6 src/riak_core_util.erl
@@ -133,7 +133,7 @@ integer_to_list(I0, Base, R0) ->
%% @doc Create a random identifying integer, returning its string
%% representation in base 62.
unique_id_62() ->
- Rand = crypto:sha(term_to_binary({make_ref(), now()})),
+ Rand = crypto:sha(term_to_binary({make_ref(), os:timestamp()})),
<<I:160/integer>> = Rand,
integer_to_list(I, 62).
@@ -155,8 +155,8 @@ reload_all(Module) ->
%% @doc Create a unique-enough id for vclock clients.
mkclientid(RemoteNode) ->
{{Y,Mo,D},{H,Mi,S}} = erlang:universaltime(),
- {_,_,NowPart} = now(),
- Id = erlang:phash2([Y,Mo,D,H,Mi,S,node(),RemoteNode,NowPart]),
+ {_,_,NowPart} = os:timestamp(),
+ Id = erlang:phash2([Y,Mo,D,H,Mi,S,node(),RemoteNode,NowPart,self()]),
<<Id:32>>.
%% @spec chash_key(BKey :: riak_object:bkey()) -> chash:index()
View
30 src/riak_core_vnode_manager.erl
@@ -359,7 +359,20 @@ handle_cast({ring_changed, Ring}, State) ->
{noreply, State3};
-handle_cast(management_tick, State) ->
+handle_cast(maybe_start_vnodes, State) ->
+ {ok, Ring} = riak_core_ring_manager:get_raw_ring(),
+ State2 = maybe_start_vnodes(Ring, State),
+ {noreply, State2};
+
+handle_cast({kill_repairs, Reason}, State) ->
+ lager:warning("Killing all repairs: ~p", [Reason]),
+ kill_repairs(State#state.repairs, Reason),
+ {noreply, State#state{repairs=[]}};
+
+handle_cast(_, State) ->
+ {noreply, State}.
+
+handle_info(management_tick, State) ->
schedule_management_timer(),
{ok, Ring} = riak_core_ring_manager:get_raw_ring(),
Mods = [Mod || {_, Mod} <- riak_core:vnode_modules()],
@@ -386,19 +399,6 @@ handle_cast(management_tick, State) ->
Repairs2 = check_repairs(State4#state.repairs),
{noreply, State5#state{repairs=Repairs2}};
-handle_cast(maybe_start_vnodes, State) ->
- {ok, Ring} = riak_core_ring_manager:get_raw_ring(),
- State2 = maybe_start_vnodes(Ring, State),
- {noreply, State2};
-
-handle_cast({kill_repairs, Reason}, State) ->
- lager:warning("Killing all repairs: ~p", [Reason]),
- kill_repairs(State#state.repairs, Reason),
- {noreply, State#state{repairs=[]}};
-
-handle_cast(_, State) ->
- {noreply, State}.
-
handle_info({'DOWN', MonRef, process, _P, _I}, State) ->
delmon(MonRef, State),
{noreply, State}.
@@ -433,7 +433,7 @@ schedule_management_timer() ->
ManagementTick = app_helper:get_env(riak_core,
vnode_management_timer,
10000),
- timer:apply_after(ManagementTick, gen_server, cast, [?MODULE, management_tick]).
+ erlang:send_after(ManagementTick, ?MODULE, management_tick).
trigger_ownership_handoff(Transfers, Mods, State) ->
Limit = app_helper:get_env(riak_core,
View
14 src/riak_core_vnode_proxy.erl
@@ -45,16 +45,22 @@ init([Parent, RegName, Mod, Index]) ->
unregister_vnode(Mod, Index, Pid) ->
cast(reg_name(Mod, Index), {unregister_vnode, Pid}).
+-spec command_return_vnode({atom(), non_neg_integer(), atom()}, term()) ->
+ {ok, pid()} | {error, term()}.
command_return_vnode({Mod,Index,Node}, Req) ->
call(reg_name(Mod, Index, Node), {return_vnode, Req}).
call(Name, Msg) ->
- {ok,Res} = (catch gen:call(Name, '$vnode_proxy_call', Msg)),
- Res.
+ call_reply(catch gen:call(Name, '$vnode_proxy_call', Msg)).
call(Name, Msg, Timeout) ->
- {ok,Res} = (catch gen:call(Name, '$vnode_proxy_call', Msg, Timeout)),
- Res.
+ call_reply(catch gen:call(Name, '$vnode_proxy_call', Msg, Timeout)).
+
+-spec call_reply({atom(), term()}) -> term().
+call_reply({ok, Res}) ->
+ Res;
+call_reply({'EXIT', Reason}) ->
+ {error, Reason}.
cast(Name, Msg) ->
catch erlang:send(Name, {'$vnode_proxy_cast', Msg}),

0 comments on commit 3b66b12

Please sign in to comment.
Something went wrong with that request. Please try again.