Anonymous avatar Anonymous committed 6475b58 Merge

merge

Comments (0)

Files changed (4)

 Jay Doane
 Martin Scholl
 Jayson Baird
+Kirill A. Korinskiy
 
 

src/jiak_util.erl

 bucket_from_uri_test() ->
     PI = dict:store(bucket, "foo", dict:new()),
     RD0 = wrq:create('PUT', "1.1", "/jiak/foo", mochiweb_headers:empty()),
-    RD = wrq:load_dispatch_data(PI, none, none, none, none, RD0),
+    RD = wrq:load_dispatch_data(PI, none, none, none, none, none, RD0),
     ?assertEqual(<<"foo">>, bucket_from_reqdata(RD)).

src/riak_fs_backend.erl

 
 %% @spec start(Partition :: integer()) ->
 %%          {ok, state()} | {{error, Reason :: term()}, state()}
-%% @doc Start this backend.  'riak_fs_backend_root' must be
-%%      set in Riak's application environment.  It must be set to
-%%      a string representing the base directory where this backend
-%%      should store its files.
+%% @doc Start this backend.  'riak_fs_backend_root' must be set in
+%%      Riak's application environment.  It must be set to a string
+%%      representing the base directory where this backend should
+%%      store its files.
 start(Partition) ->
     PartitionName = integer_to_list(Partition),
     ConfigRoot = riak:get_app_env(riak_fs_backend_root),
         true -> file:read_file(File)
     end.
 
+%% @spec atomic_write(File :: string(), Val :: binary()) ->
+%%       ok | {error, Reason :: term()}
+%% @doc store a atomic value to disk. Write to temp file and rename to
+%%       normal path.
+atomic_write(State, File, Val) ->
+    FakeFile = File ++ ".tmpwrite",
+    case file:write_file(FakeFile, Val) of
+        ok ->
+            file:rename(FakeFile, File);
+        X -> X
+    end.
+
 %% @spec put(state(), BKey :: riak_object:bkey(), Val :: binary()) ->
 %%         ok | {error, Reason :: term()}
 %% @doc Store Val under Bkey
 put(State,BKey,Val) ->       
     File = location(State,BKey),
     case filelib:ensure_dir(File) of
-        ok -> file:write_file(File,Val);
+        ok -> atomic_write(State, File, Val);
         X -> X
     end.
 

src/riak_util.erl

 %%          {[{Index :: term(), Node :: node(), Node :: node()}],
 %%           [{Index :: term(), Node :: node()}]}
 %% @doc Cast {Cmd, {Index,Node}, Msg} at riak_vnode_master on Node
-%%      if Node responds 'pong' to a net_adm:ping.  The list of
-%%      successful casts is the first element of the return tuple, and
-%%      the list of pang-responding nodes is the second element.
-%%      Used in riak_put_fsm and riak_get_fsm.
+%%      if Node is in UpNodes.  The list of successful casts is the
+%%      first element of the return tuple, and the list of unavailable
+%%      nodes is the second element.  Used in riak_put_fsm and riak_get_fsm.
 try_cast(Cmd, Msg, UpNodes, Targets) ->
     try_cast(Cmd, Msg, UpNodes, Targets, [], []).
 try_cast(_Cmd, _Msg, _UpNodes, [], Sent, Pangs) -> {Sent, Pangs};
 try_cast(Cmd, Msg, UpNodes, [{Index,Node}|Targets], Sent, Pangs) ->
-    case lists:member(Node, [node()|UpNodes])
-          orelse net_adm:ping(Node) == pong of
+    case lists:member(Node, [node()|UpNodes]) of
         false ->
             try_cast(Cmd, Msg, UpNodes, Targets, Sent, [{Index,Node}|Pangs]);
         true ->
 fallback(_Cmd, _Msg, [], _Fallbacks, Sent) -> Sent;
 fallback(_Cmd, _Msg, _Pangs, [], Sent) -> Sent;
 fallback(Cmd, Msg, [{Index,Node}|Pangs], [{_,FN}|Fallbacks], Sent) ->
-    case lists:member(FN, [node()|nodes()]) orelse net_adm:ping(FN) == pong of
+    case lists:member(FN, [node()|nodes()]) of
         false -> fallback(Cmd, Msg, [{Index,Node}|Pangs], Fallbacks, Sent);
         true ->
             gen_server:cast({riak_vnode_master, FN},
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.