Anonymous avatar Anonymous committed 8d96d21

ensure use of gen_server2:call/cast

Comments (0)

Files changed (10)

src/riak_backup.erl

     All_I_VN = lists:flatten(
           [gen_server:call({riak_vnode_master, Node},all_possible_vnodes) ||
                   Node <- nodes()]),
-    IV_Lists = [{I, VN, gen_server:call(VN,list)} || {I,VN} <- All_I_VN],
+    IV_Lists = [{I, VN, gen_server2:call(VN,list)} || {I,VN} <- All_I_VN],
     {ok, dumptable} = dets:open_file(dumptable, [{file, Filename}]),
     dump_records(IV_Lists),
     ok = dets:sync(dumptable),
 %% @private
 dump_records1(_VN,[]) -> ok;
 dump_records1(VN,[K|K_Tail]) ->
-    {ok, V} = gen_server:call(VN, {get_binary, K}),
+    {ok, V} = gen_server2:call(VN, {get_binary, K}),
     Obj = binary_to_term(V),
     Bucket = riak_object:bucket(Obj),
     Key = riak_object:key(Obj),

src/riak_bucketkeys.erl

 %% @private
 get_keysobj(Bucket, Ring) ->
     fix_bucket(Ring),
-    case gen_server:call({riak_api,node()},
-                         {get,?BUCK,Bucket,1,120000}) of
+    case gen_server2:call({riak_api,node()},
+                          {get,?BUCK,Bucket,1,120000}) of
         {error, notfound} ->
             riak_object:new(?BUCK,Bucket,{sets:new(), []});
         {error, Err} -> {error, Err};

src/riak_client.erl

 %%      See the map/reduce documentation for explanation of behavior.
 mapred(Inputs,Query,Timeout)
   when is_list(Inputs), is_list(Query), is_integer(Timeout) ->
-    gen_server:call({riak_api,Node}, {mapred,Inputs,Query,Timeout}, Timeout).
+    gen_server2:call({riak_api,Node}, {mapred,Inputs,Query,Timeout}, Timeout).
 
 
 %% @spec get(riak_object:bucket(), riak_object:key(), R :: integer()) ->
 get(Bucket, Key, R, Timeout) when is_atom(Bucket),
                                   (is_list(Key) orelse is_binary(Key)),
                                   is_integer(R), is_integer(Timeout) ->
-    gen_server:call({riak_api,Node}, {get,Bucket,Key,R,Timeout}, Timeout).
+    gen_server2:call({riak_api,Node}, {get,Bucket,Key,R,Timeout}, Timeout).
 
 
 %% @spec put(RObj :: riak_object:riak_object(), W :: integer()) ->
 %%      TimeoutMillisecs passes.
 put(RObj, W, DW, Timeout) ->
     R0 = riak_object:increment_vclock(RObj, ClientId),
-    gen_server:call({riak_api,Node}, {put,R0,W,DW,Timeout}, Timeout).
+    gen_server2:call({riak_api,Node}, {put,R0,W,DW,Timeout}, Timeout).
 
 
 %% @spec delete(riak_object:bucket(), riak_object:key(), RW :: integer()) ->
 %% @doc Delete the object at Bucket/Key.  Return a value as soon as RW
 %%      nodes have responded with a value or error, or TimeoutMillisecs passes.
 delete(Bucket,Key,RW,Timeout) ->
-    gen_server:call({riak_api,Node}, {delete,Bucket,Key,RW,Timeout}, Timeout).
+    gen_server2:call({riak_api,Node}, {delete,Bucket,Key,RW,Timeout}, Timeout).
 
 
 %% @spec list_keys(riak_object:bucket()) ->
 %%      Key lists are updated asynchronously, so this may be slightly
 %%      out of date if called immediately after a put or delete.
 list_keys(Bucket) -> 
-    gen_server:call({riak_api,Node}, {list_keys,Bucket}, ?DEFAULT_TIMEOUT*4).
+    gen_server2:call({riak_api,Node}, {list_keys,Bucket}, ?DEFAULT_TIMEOUT*4).
 
 %% @spec set_bucket(riak_object:bucket(), [BucketProp :: {atom(),term()}]) -> ok
 %% @doc Set the given properties for Bucket.
 %%      to ensure expected per-bucket behavior.
 %% See riak_bucket for expected useful properties.
 set_bucket(BucketName,BucketProps) ->
-    gen_server:call({riak_api,Node}, {set_bucket,BucketName,BucketProps}).
+    gen_server2:call({riak_api,Node}, {set_bucket,BucketName,BucketProps}).
 %% @spec get_bucket(riak_object:bucket()) -> [BucketProp :: {atom(),term()}]
 %% @doc Get all properties for Bucket.
 %% See riak_bucket for expected useful properties.
 get_bucket(BucketName) ->
-    gen_server:call({riak_api,Node}, {get_bucket,BucketName}).
+    gen_server2:call({riak_api,Node}, {get_bucket,BucketName}).
 
 %% @spec reload_all(Module :: atom()) -> term()
 %% @doc Force all Riak nodes to reload Module.
 %%      This is used when loading new modules for map/reduce functionality.
-reload_all(Module) -> gen_server:call({riak_api,Node}, {reload_all, Module}).
+reload_all(Module) -> gen_server2:call({riak_api,Node}, {reload_all, Module}).
 
 %% @spec remove_from_cluster(ExitingNode :: atom()) -> term()
 %% @doc Cause all partitions owned by ExitingNode to be taken over
 %%      by other nodes.
 remove_from_cluster(ExitingNode) ->
-    gen_server:call({riak_api,Node}, {remove_from_cluster,ExitingNode}).
+    gen_server2:call({riak_api,Node}, {remove_from_cluster,ExitingNode}).
 
 %% @spec send_event(EventName::atom(), EventDetail::term()) -> ok
 %% @doc  Send a client-generated event to the Riak eventer.
 send_event(EventName, EventDetail) ->
-    gen_server:cast({riak_api,Node},
-                    {send_event,ClientId,EventName,EventDetail}).
+    gen_server2:cast({riak_api,Node},
+                     {send_event,ClientId,EventName,EventDetail}).

src/riak_delete.erl

     RealStartTime = riak_util:moment(),
     ReqID = erlang:phash2({random:uniform(),self(),Bucket,Key,RealStartTime}),
     riak_eventer:notify(riak_delete, delete_start, {ReqID, Bucket, Key}),
-    case gen_server:call({riak_api, node()},
-                              {get,Bucket,Key,RW,Timeout}) of
+    case gen_server2:call({riak_api, node()},
+                          {get,Bucket,Key,RW,Timeout}) of
         {ok, OrigObj} ->
             RemainingTime = Timeout - (riak_util:moment() - RealStartTime),
             OrigMD = hd([MD || {MD,_V} <- riak_object:get_contents(OrigObj)]),
                 _ -> nop
             end,
             riak_eventer:notify(riak_delete, delete_reply, {ReqID, Reply}),
-            gen_server:reply(Client, Reply);
+            gen_server2:reply(Client, Reply);
         {error, notfound} ->
             spawn(fun()-> riak_bucketkeys:del_key(Bucket,Key) end),
             riak_eventer:notify(riak_delete, delete_reply,
                                 {ReqID, {error, notfound}}),
-            gen_server:reply(Client, {error, notfound});
+            gen_server2:reply(Client, {error, notfound});
         X ->
             riak_eventer:notify(riak_delete, delete_reply, {ReqID, X}),
-            gen_server:reply(Client, X)
+            gen_server2:reply(Client, X)
     end.
 
 reap(Bucket, Key, WaitTime, Timeout, ReqId) ->
     timer:sleep(WaitTime),
-    case gen_server:call({riak_api, node()}, 
-                         {get, Bucket, Key, 1, Timeout}) of
+    case gen_server2:call({riak_api, node()}, 
+                          {get, Bucket, Key, 1, Timeout}) of
         {error, notfound} ->
             riak_eventer:notify(riak_delete, finalize_reap, 
                                 {ReqId, Bucket, Key, ok});

src/riak_get_fsm.erl

         false ->
             riak_eventer:notify(riak_get_fsm, get_fsm_reply,
                                 {ReqID, notfound}),
-            gen_server:reply(Client,{error,notfound}),
+            gen_server2:reply(Client,{error,notfound}),
             {stop,normal,NewStateData}
     end;
 waiting_vnode_r({r, {error, Err}, Idx, ReqID},
                     FullErr = [E || {E,_I} <- Replied],
                     riak_eventer:notify(riak_get_fsm, get_fsm_reply,
                                         {ReqID, {error,FullErr}}),
-                    gen_server:reply(Client,{error,FullErr}),
+                    gen_server2:reply(Client,{error,FullErr}),
                     {stop,normal,NewStateData};
                 _ ->
                     riak_eventer:notify(riak_get_fsm, get_fsm_reply,
                                         {ReqID, notfound}),
-                    gen_server:reply(Client,{error,notfound}),
+                    gen_server2:reply(Client,{error,notfound}),
                     {stop,normal,NewStateData}
             end
     end;
 waiting_vnode_r(timeout, StateData=#state{client=Client,req_id=ReqID}) ->
     riak_eventer:notify(riak_get_fsm, get_fsm_reply,
                         {ReqID, timeout}),
-    gen_server:reply(Client,{error,timeout}),
+    gen_server2:reply(Client,{error,timeout}),
     {stop,normal,StateData}.
 
 waiting_read_repair({r, {ok, RObj}, Idx, ReqID},
                                                 delete_finalize_start,
                                                 {ReqID, Bucket, Key}),
                             riak_bucketkeys:del_key(Bucket,Key),
-                            [gen_server:call({riak_vnode_master, Node},
+                            [gen_server2:call({riak_vnode_master, Node},
                                              {vnode_del, {Idx,Node},
                                               {Storekey,ReqID}}) ||
                                 {Idx,Node} <- IdealNodes];
 
 respond(Client,VResponses,AllowMult) ->
     Reply = merge_robjs([R || {R,_I} <- VResponses],AllowMult),
-    gen_server:reply(Client,Reply),
+    gen_server2:reply(Client,Reply),
     Reply.
 
 merge_robjs(RObjs0,AllowMult) ->

src/riak_mapreduce_fsm.erl

         {bad_qterm, QTerm} ->
             riak_eventer:notify(riak_mapreduce_fsm, mr_fsm_done,
                                 {error, {bad_qterm, QTerm}}),
-            gen_server:reply(Client,{error, {bad_qterm, QTerm}}),
+            gen_server2:reply(Client,{error, {bad_qterm, QTerm}}),
             {stop,normal}
     end.
 
         [] -> 
             riak_eventer:notify(riak_mapreduce_fsm, mr_fsm_done,
                                 {ok, ReqID, length(Acc)}),
-            gen_server:reply(Client,{ok, Acc}),
+            gen_server2:reply(Client,{ok, Acc}),
             {stop,normal,StateData};
         _ ->
             {next_state, wait, StateData#state{fsms=FSMs},
     FSMs = lists:delete(ErrFSM,FSMs0),
     [gen_fsm:send_event(FSM, die) || FSM <- FSMs],
     riak_eventer:notify(riak_mapreduce_fsm, mr_fsm_done, {error, ReqID}),
-    gen_server:reply(Client,{error, ErrMsg}),
+    gen_server2:reply(Client,{error, ErrMsg}),
     {stop,normal,StateData};
 wait({acc,Data}, StateData=#state{acc=Acc,endtime=End}) ->
     AccData = case Data of
     {next_state, wait, StateData#state{acc=AccData},End-riak_util:moment()};
 wait(timeout, StateData=#state{reqid=ReqID,client=Client}) ->
     riak_eventer:notify(riak_mapreduce_fsm, mr_fsm_done, {timeout, ReqID}),
-    gen_server:reply(Client,{error, timeout}),
+    gen_server2:reply(Client,{error, timeout}),
     {stop,normal,StateData}.
 
 %% @private

src/riak_put_fsm.erl

             case DW of
                 0 ->
                     send_key_update(RObj),
-                    gen_server:reply(Client,ok),
+                    gen_server2:reply(Client,ok),
                     riak_eventer:notify(riak_put_fsm, put_fsm_reply,
                                         {ReqID, ok}),
                     {stop,normal,StateData};
         false ->
             riak_eventer:notify(riak_put_fsm, put_fsm_reply,
                                 {ReqID, {error,too_many_fails,Replied}}),
-            gen_server:reply(Client,{error,too_many_fails}),
+            gen_server2:reply(Client,{error,too_many_fails}),
             {stop,normal,NewStateData}
     end;
 waiting_vnode_w(timeout, StateData=#state{client=Client,req_id=ReqID}) ->
     riak_eventer:notify(riak_put_fsm, put_fsm_reply,
                         {ReqID, {error,timeout}}),
-    gen_server:reply(Client,{error,timeout}),
+    gen_server2:reply(Client,{error,timeout}),
     {stop,normal,StateData}.
 
 waiting_vnode_dw({w, _Idx, ReqID},
             send_key_update(RObj),
             riak_eventer:notify(riak_put_fsm, put_fsm_reply,
                                 {ReqID, ok}),
-            gen_server:reply(Client,ok),
+            gen_server2:reply(Client,ok),
             {stop,normal,StateData};
         false ->
             NewStateData = StateData#state{replied_dw=Replied},
         false ->
             riak_eventer:notify(riak_put_fsm, put_fsm_reply,
                                 {ReqID, {error,too_many_fails,Replied}}),
-            gen_server:reply(Client,{error,too_many_fails}),
+            gen_server2:reply(Client,{error,too_many_fails}),
             {stop,normal,NewStateData}
     end;
 waiting_vnode_dw(timeout, StateData=#state{client=Client,req_id=ReqID}) ->
     riak_eventer:notify(riak_put_fsm, put_fsm_reply,
                         {ReqID, {error,timeout}}),
-    gen_server:reply(Client,{error,timeout}),
+    gen_server2:reply(Client,{error,timeout}),
     {stop,normal,StateData}.
 
 %% @private

src/riak_vnode.erl

             {qfun,F} -> F(V,KeyData,Arg);
             {modfun,M,F} ->
                 MF_Res = M:F(V,KeyData,Arg),
-                gen_server:cast(VNode,
-                                {mapcache, Storekey,{M,F,Arg,KeyData},MF_Res}),
+                gen_server2:cast(VNode,
+                                 {mapcache, Storekey,{M,F,Arg,KeyData},MF_Res}),
                 MF_Res
         end,
         {mapexec_reply, MapVal, self()}

src/riak_vnode_master.erl

 handle_cast({vnode_map, {Partition,_Node},
              {ClientPid,QTerm,Storekey,KeyData}}, State) ->
     Pid = get_vnode(Partition, State),
-    gen_server:cast(Pid, {map, ClientPid, QTerm, Storekey, KeyData}),
+    gen_server2:cast(Pid, {map, ClientPid, QTerm, Storekey, KeyData}),
     % (obligation done, now the problem of the vnodes)
     {noreply, State};
 handle_cast({vnode_put, {Partition,_Node},
              {FSM_pid,Storekey,RObj,ReqID}}, State) ->
     Pid = get_vnode(Partition, State),
-    gen_server:cast(Pid, {put, FSM_pid, Storekey, RObj, ReqID}),
+    gen_server2:cast(Pid, {put, FSM_pid, Storekey, RObj, ReqID}),
     % (obligation done, now the problem of the vnodes)
     {noreply, State};
 handle_cast({vnode_get, {Partition,_Node},
              {FSM_pid,Storekey,ReqID}}, State) ->
     Pid = get_vnode(Partition, State),
-    gen_server:cast(Pid, {get, FSM_pid, Storekey, ReqID}),
+    gen_server2:cast(Pid, {get, FSM_pid, Storekey, ReqID}),
     % (obligation done, now the problem of the vnodes)
     {noreply, State};
 handle_cast({vnode_merkle, {RemoteVN,Partition,Merkle}}, State) ->
     Pid = get_vnode(Partition, State),
-    gen_server:cast(Pid, {vnode_merkle, {RemoteVN,Merkle}}),
+    gen_server2:cast(Pid, {vnode_merkle, {RemoteVN,Merkle}}),
     % (obligation done, now the problem of the vnodes)
     {noreply, State}.
 
 handle_call({vnode_del, {Partition,_Node},
              {Storekey,ReqID}}, From, State) ->
     Pid = get_vnode(Partition, State),
-    gen_server:cast(Pid, {delete, From, Storekey, ReqID}),
+    gen_server2:cast(Pid, {delete, From, Storekey, ReqID}),
     % (obligation done, now the problem of the vnodes)
     {noreply, State}.
 

src/riak_vnode_sidekick.erl

     Me = node(),
     case riak_ring:index_owner(MyRing, Idx) of
         Me ->
-            gen_server:cast(VNode, activate),
+            gen_server2:cast(VNode, activate),
             case Count > 9 of
                 true ->
-                    gen_server:cast(VNode, cache_purge),
+                    gen_server2:cast(VNode, cache_purge),
                     {next_state,home,StateData#state{counter=0},?TIMEOUT};
                 false ->
                     {next_state,home,StateData#state{counter=Count+1},?TIMEOUT}
             case net_adm:ping(TargetNode) of
                 pang -> {next_state,not_home,StateData,?TIMEOUT};
                 pong ->
-                    ObjList = gen_server:call(VNode, list, 60000),
+                    ObjList = gen_server2:call(VNode, list, 60000),
                     case ObjList of
                         [] ->
-                            gen_server:cast(VNode, {rexit, "sidekick"}),
+                            gen_server2:cast(VNode, {rexit, "sidekick"}),
                             {next_state,not_home,StateData,?LONGTIMEOUT};
                         _ -> 
-                            gen_server:cast(VNode, deactivate),
+                            gen_server2:cast(VNode, deactivate),
                             Merk = make_merk(VNode, Idx, ObjList),
                             gen_server:cast({riak_vnode_master, TargetNode},
                                             {vnode_merkle, {VNode,Idx,Merk}}),
 make_merk(VNode, Idx, ObjList) ->
     riak_eventer:notify(riak_vnode_sidekick, merkle_prep, Idx),
     merkerl:build_tree([{K,crypto:sha(V)} || {K,{ok,V}} <- 
-                        [{K,gen_server:call(VNode, {get_binary, K})} ||
+                        [{K,gen_server2:call(VNode, {get_binary, K})} ||
                            K <- ObjList]]).
 
 %% @private
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.