Commits

dizzyd committed aeb2fa8

Fix stupid typos; try to load existing ring on startup by default

  • Participants
  • Parent commits 5f92e6e

Comments (0)

Files changed (2)

apps/riak/ebin/riak.app

          {cluster_name, "default"},
          
          %% Default location of ringstate
-         {ring_state_dir, "ringstate"},
+         {ring_state_dir, "data/ringstate"},
          
          %% Default ring creation size
          {ring_creation_size, 64},

apps/riak/src/riak_app.erl

 
     %% Validate that the ring state directory exists
     RingStateDir = riak:get_app_env(ring_state_dir),
-    case filelib:is_directory(RingStateDir) of
+    case filelib:is_dir(RingStateDir) of
         true ->
             ok;
         false ->
-            error_lgoger:error_msg("Ring state directory ~p does not exist.\n", [RingStateDir]),
+            error_logger:error_msg("Ring state directory ~p does not exist.\n", [RingStateDir]),
             throw({error, invalid_ring_state_dir})
     end,
 
     check_deps(),
 
     %% Spin up supervisor
-    io:format("Plain args: ~p\n", [init:get_plain_arguments()]),
     case riak_sup:start_link() of
         {ok, Pid} ->
-            %% App is basically running. Now we need to either initialize a new
-            %% ring (noop), join a new ring or rejoin existing ring (default)
-            case ring_args(init:get_plain_arguments()) of
-                new_ring ->
-                    error_logger:info_msg("Starting new ring\n"),
-                    ok;
-                {join_ring, Node} ->
-                    error_logger:info_msg("Attempting to join ring at ~p\n", [Node]),
-                    riak_connect:send_ring(Node, node());
-                rejoin ->
-                    riak_ring_manager:prune_ringfiles(),
-                    riak_ring_manager:set_my_ring(
-                      riak_ring_manager:read_ringfile(
-                        riak_ring_manager:find_latest_ringfile()))
+            %% App is running; search for latest ring file and initialize with it
+            riak_ring_manager:prune_ringfiles(),
+            case riak_ring_manager:find_latest_ringfile() of
+                {ok, Ring} ->
+                    riak_ring_manager:set_my_ring(riak_ring_manager:read_ringfile(Ring));
+                {error, not_found} ->
+                    error_logger:warning_msg("No ring file available.\n");
+                {error, Reason} ->
+                    error_logger:error_msg("Failed to load ring file: ~p\n", [Reason]),
+                    throw({error, Reason})
             end,
             {ok, Pid};
         {error, Reason} ->
                       lists:keysort(1, riak_bucket:defaults()))).
 
 
-%%
-%% Scan init:get_plain_arguments/0 looking for what to do with
-%% ring initialization
-%%
-ring_args([]) ->
-    rejoin;
-ring_args(["join", Node | _Rest]) ->
-    {join, list_to_atom(Node)};
-ring_args(["bootstrap" | _Rest]) ->
-    new_ring;
-ring_args([_ | Rest]) ->
-    ring_args(Rest).
-
 
 check_deps() ->
     % explicit list of external modules we should fail-fast on missing