Commits

Kirill Korinskiy committed 152355d

If set use_fallback_nodes to false and sent to 0 nodes return {error, notnodes}

Comments (0)

Files changed (2)

src/riak_get_fsm.erl

     {ok,initialize,StateData,0}.
 
 %% @private
-initialize(timeout, StateData0=#state{timeout=Timeout, req_id=ReqId,
+initialize(timeout, StateData0=#state{timeout=Timeout, req_id=ReqId, client=Client,
                                       bkey={Bucket,Key}, ring=Ring}) ->
     RealStartTime = riak_util:moment(),
     DocIdx = riak_util:chash_key({Bucket, Key}),
 	   end,
     riak_eventer:notify(riak_get_fsm, get_fsm_sent,
                                 {ReqId, [{T,S} || {_I,T,S} <- Sent]}),
-    StateData = StateData0#state{n=N,allowmult=AllowMult,repair_sent=[],
+    StateData = StateData0#state{n=length(Sent),allowmult=AllowMult,repair_sent=[],
                        preflist=Preflist,final_obj=undefined,
                        replied_r=[],replied_fail=[],
                        replied_notfound=[],starttime=riak_util:moment(),
                        waiting_for=Sent,endtime=Timeout+riak_util:moment()},
-    {next_state,waiting_vnode_r,StateData,Timeout}.
+    case length(Sent) of
+	0 ->
+	    Client ! {ReqId, {error, notnode}},
+	    {stop, normal, StateData};
+	_ ->
+	    {next_state, waiting_vnode_r, StateData, Timeout}
+    end.
 
 waiting_vnode_r({r, {ok, RObj}, Idx, ReqId},
                   StateData=#state{r=R,allowmult=AllowMult,

src/riak_put_fsm.erl

     {ok,initialize,StateData,0}.
 
 %% @private
-initialize(timeout, StateData0=#state{robj=RObj0, req_id=ReqId,
+initialize(timeout, StateData0=#state{robj=RObj0, req_id=ReqId, client=Client,
                                       timeout=Timeout, ring=Ring}) ->
     RObj = update_metadata(RObj0),
     RealStartTime = riak_util:moment(),
     riak_eventer:notify(riak_put_fsm, put_fsm_sent,
                                 {ReqId, [{T,S} || {_I,T,S} <- Sent]}),
     StateData = StateData0#state{
-                  robj=RObj, n=N, preflist=Preflist, bkey={Bucket,Key},
+                  robj=RObj, n=length(Sent), preflist=Preflist, bkey={Bucket,Key},
                   waiting_for=Sent, starttime=riak_util:moment(),
                   replied_w=[], replied_dw=[], replied_fail=[],
                   endtime=Timeout+riak_util:moment()},
-    {next_state,waiting_vnode_w,StateData,Timeout}.
+    case length(Sent) of
+	0 ->
+	    Client ! {ReqId, {error, notnode}},
+	    {stop, normal, StateData};
+	_ ->
+	    {next_state, waiting_vnode_w, StateData, Timeout}
+    end.
 
 waiting_vnode_w({w, Idx, ReqId},
                   StateData=#state{w=W,dw=DW,req_id=ReqId,client=Client, bkey={Bucket, Key},
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.