Commits

Anonymous committed 4810df0

Issue 18: vnodes should be supervised

  • Participants
  • Parent commits 149185f

Comments (0)

Files changed (4)

File apps/riak/ebin/riak.app

              riak_map_phase_fsm,
              riak_mapreduce,
              riak_mapreduce_fsm,
-			 riak_multi_backend,
+             riak_multi_backend,
              riak_object,
              riak_osmos_backend,
              riak_put_fsm,
              riak_util,
              riak_vnode,
              riak_vnode_master,
+             riak_vnode_sup,
              riak_web,
              riakserver_pb,
              slide,

File apps/riak/src/riak_sup.erl

     Eventer = {riak_eventer,
                {riak_eventer, start_link, []},
                permanent, 5000, worker, [riak_eventer]},
+    VSup = {riak_vnode_sup,
+            {riak_vnode_sup, start_link, []},
+            permanent, infinity, supervisor, [riak_vnode_sup]},
     VMaster = {riak_vnode_master,
                {riak_vnode_master, start_link, []},
                permanent, 5000, worker, [riak_vnode_master]},
     
     % Build the process list...
     Processes = lists:flatten([
-        Eventer,
+        Eventer, 
+        VSup,                               
         ?IF(HasStorageBackend, VMaster, []),
         RingMgr, 
         Connect, 

File apps/riak/src/riak_vnode.erl

 -module(riak_vnode).
 -behaviour(gen_fsm).
 
--export([start/1]).
+-export([start_link/1]).
 -export([init/1, handle_event/3, handle_sync_event/4,
          handle_info/3, terminate/3, code_change/4]).
 -export([active/2,merk_waiting/2,waiting_diffobjs/2]).
 
 -record(state, {idx,mapcache,mod,modstate,waiting_diffobjs}).
 
-start(Idx) ->
-    gen_fsm:start(?MODULE, [Idx], []).
+start_link(Idx) ->
+    gen_fsm:start_link(?MODULE, [Idx], []).
+
 init([VNodeIndex]) ->
     Mod = riak:get_app_env(storage_backend),
     Configuration = riak:get_app_env(),

File apps/riak/src/riak_vnode_master.erl

     {noreply, State}.
 
 %% @private
-terminate(_Reason, _State) -> ok.
+terminate(_Reason, _State) -> 
+    io:format("riak_vnode terminating with reason ~p~n", [_Reason]),
+    ok.
 
 %% @private
 code_change(_OldVsn, State, _Extra) ->  {ok, State}.
 get_vnode(Idx, State) ->
     case idx2vnode(Idx, State) of
         no_match ->
-            {ok, Pid} = riak_vnode:start(Idx),
+            {ok, Pid} = riak_vnode_sup:start_vnode(Idx),
             MonRef = erlang:monitor(process, Pid),
             add_vnode_rec(#idxrec{idx=Idx,pid=Pid,monref=MonRef}, State),
             Pid;