Permalink
Browse files

kv changes for riak_core vnode master refactoring

  • Loading branch information...
1 parent 8ffc1f1 commit 478f2c6480446ee2598527f04f62fe62c1506609 @argv0 argv0 committed Apr 17, 2011
Showing with 49 additions and 51 deletions.
  1. +1 −1 rebar.config
  2. +1 −1 src/riak_kv_delete.erl
  3. +8 −8 src/riak_kv_legacy_vnode.erl
  4. +5 −5 src/riak_kv_util.erl
  5. +34 −36 src/riak_kv_vnode.erl
View
@@ -5,7 +5,7 @@
{erl_first_files, ["src/riak_kv_backend.erl"]}.
{deps, [
- {riak_core, "0.14.0", {git, "git://github.com/basho/riak_core",
+ {riak_core, "0.14.0", {git, "git://github.com/argv0/riak_core",
{branch, "master"}}},
{riakc, "1.1.0", {git, "git://github.com/basho/riak-erlang-client",
{branch, "master"}}},
View
@@ -131,7 +131,7 @@ setup() ->
cleanup(_Pid) ->
do_dep_apps(stop, lists:reverse(dep_apps())),
- catch exit(whereis(riak_kv_vnode_master), kill), %% Leaks occasionally
+ catch exit(whereis(riak_kv_vnode), kill), %% Leaks occasionally
catch exit(whereis(riak_sysmon_filter), kill), %% Leaks occasionally
net_kernel:stop(),
%% Reset the riak_core vnode_modules
@@ -34,7 +34,7 @@
rewrite_cast({vnode_map, {Partition,_Node},
{ClientPid,QTerm,BKey,KeyData}}) ->
- Req = riak_core_vnode_master:make_request(
+ Req = riak_core_vnode:make_request(
?KV_MAP_REQ{
qterm = QTerm,
bkey = BKey,
@@ -44,7 +44,7 @@ rewrite_cast({vnode_map, {Partition,_Node},
{ok, Req};
rewrite_cast({vnode_put, {Partition,_Node},
{FSM_pid,BKey,RObj,ReqID,FSMTime,Options}}) ->
- Req = riak_core_vnode_master:make_request(
+ Req = riak_core_vnode:make_request(
?KV_PUT_REQ{
bkey = BKey,
object = RObj,
@@ -56,7 +56,7 @@ rewrite_cast({vnode_put, {Partition,_Node},
{ok, Req};
rewrite_cast({vnode_get, {Partition,_Node},
{FSM_pid,BKey,ReqId}}) ->
- Req = riak_core_vnode_master:make_request(
+ Req = riak_core_vnode:make_request(
?KV_GET_REQ{
bkey = BKey,
req_id = ReqId
@@ -70,7 +70,7 @@ rewrite_cast({vnode_get, {Partition,_Node},
%% {noreply, State};
rewrite_cast({vnode_list_bucket, {Partition,_Node},
{FSM_pid, Bucket, ReqID}}) ->
- Req = riak_core_vnode_master:make_request(
+ Req = riak_core_vnode:make_request(
#riak_kv_listkeys_req_v1{
bucket=Bucket,
req_id=ReqID},
@@ -89,7 +89,7 @@ rewrite_cast({vnode_list_bucket, {Partition,_Node},
%% {reply, all_vnodes(State), State};
rewrite_call({vnode_del, {Partition,_Node},
{BKey,ReqID}}, _From) ->
- Req = riak_core_vnode_master:make_request(
+ Req = riak_core_vnode:make_request(
?KV_DELETE_REQ{bkey=BKey,
req_id=ReqID},
ignore,
@@ -128,14 +128,14 @@ start_servers() ->
application:set_env(riak_core, default_bucket_props, []),
Ring = riak_core_ring:fresh(16, node()),
mochiglobal:put(?RING_KEY, Ring),
- riak_kv_test_util:stop_process(riak_kv_vnode_master),
+ riak_kv_test_util:stop_process(riak_kv_vnode),
riak_kv_test_util:stop_process(riak_core_vnode_sup),
{ok, _Sup} = riak_core_vnode_sup:start_link(),
{ok, _Vmaster} = riak_core_vnode_master:start_link(riak_kv_vnode, ?MODULE),
ok.
stop_servers(_R) ->
- riak_kv_test_util:stop_process(riak_kv_vnode_master),
+ riak_kv_test_util:stop_process(riak_kv_vnode),
riak_kv_test_util:stop_process(riak_core_vnode_sup).
legacy_kv_test_() ->
@@ -193,7 +193,7 @@ legacy_kv_test_() ->
}}.
send_0_11_0_cmd(Cmd, Msg) ->
- gen_server:cast({riak_kv_vnode_master, node()},
+ gen_server:cast({riak_kv_vnode, node()},
{Cmd, {0, node()}, Msg}).
View
@@ -81,7 +81,7 @@ try_cast(Msg, UpNodes, [{Index,Node}|Targets], Sent, Pangs) ->
false ->
try_cast(Msg, UpNodes, Targets, Sent, [{Index,Node}|Pangs]);
true ->
- gen_server:cast({riak_kv_vnode_master, Node}, make_request(Msg, Index)),
+ gen_server:cast({riak_kv_vnode, Node}, make_request(Msg, Index)),
try_cast(Msg, UpNodes, Targets, [{Index,Node,Node}|Sent],Pangs)
end.
@@ -102,16 +102,16 @@ fallback(Cmd, UpNodes, [{Index,Node}|Pangs], [{_,FN}|Fallbacks], Sent) ->
case lists:member(FN, UpNodes) of
false -> fallback(Cmd, UpNodes, [{Index,Node}|Pangs], Fallbacks, Sent);
true ->
- gen_server:cast({riak_kv_vnode_master, FN}, make_request(Cmd, Index)),
+ gen_server:cast({riak_kv_vnode, FN}, make_request(Cmd, Index)),
fallback(Cmd, UpNodes, Pangs, Fallbacks, [{Index,Node,FN}|Sent])
end.
-spec make_request(vnode_req(), partition()) -> #riak_vnode_req_v1{}.
make_request(Request, Index) ->
- riak_core_vnode_master:make_request(Request,
- {fsm, undefined, self()},
- Index).
+ riak_core_vnoder:make_request(Request,
+ {fsm, undefined, self()},
+ Index).
get_bucket_option(Type, BucketProps) ->
case proplists:get_value(Type, BucketProps, default) of
View
@@ -82,7 +82,7 @@
%% API
start_vnode(I) ->
- riak_core_vnode_master:get_vnode_pid(I, riak_kv_vnode).
+ riak_core_vnode:get_vnode_pid(I, riak_kv_vnode).
test_vnode(I) ->
riak_core_vnode:start_link(riak_kv_vnode, I, infinity).
@@ -92,24 +92,22 @@ get(Preflist, BKey, ReqId) ->
req_id=ReqId},
%% Assuming this function is called from a FSM process
%% so self() == FSM pid
- riak_core_vnode_master:command(Preflist,
- Req,
- {fsm, undefined, self()},
- riak_kv_vnode_master).
+ riak_core_vnode:command(Preflist,
+ Req,
+ {fsm, undefined, self()},
+ ?MODULE).
mget(Preflist, BKeys, ReqId) ->
Req = ?KV_MGET_REQ{bkeys=BKeys,
req_id=ReqId,
from={fsm, self()}},
- riak_core_vnode_master:command(Preflist,
- Req,
- riak_kv_vnode_master).
+ riak_core_vnode:command(Preflist, Req, ?MODULE).
del(Preflist, BKey, ReqId) ->
- riak_core_vnode_master:command(Preflist,
- ?KV_DELETE_REQ{bkey=BKey,
- req_id=ReqId},
- riak_kv_vnode_master).
+ riak_core_vnode:command(Preflist,
+ ?KV_DELETE_REQ{bkey=BKey,
+ req_id=ReqId},
+ ?MODULE).
%% Issue a put for the object to the preflist, expecting a reply
%% to an FSM.
@@ -118,40 +116,40 @@ put(Preflist, BKey, Obj, ReqId, StartTime, Options) when is_integer(StartTime) -
put(Preflist, BKey, Obj, ReqId, StartTime, Options, Sender)
when is_integer(StartTime) ->
- riak_core_vnode_master:command(Preflist,
- ?KV_PUT_REQ{
- bkey = BKey,
- object = Obj,
- req_id = ReqId,
- start_time = StartTime,
- options = Options},
- Sender,
- riak_kv_vnode_master).
+ riak_core_vnode:command(Preflist,
+ ?KV_PUT_REQ{
+ bkey = BKey,
+ object = Obj,
+ req_id = ReqId,
+ start_time = StartTime,
+ options = Options},
+ Sender,
+ ?MODULE).
%% Do a put without sending any replies
readrepair(Preflist, BKey, Obj, ReqId, StartTime, Options) ->
put(Preflist, BKey, Obj, ReqId, StartTime, [rr | Options], ignore).
list_keys(Preflist, ReqId, Caller, Bucket) ->
- riak_core_vnode_master:command(Preflist,
- ?KV_LISTKEYS_REQ{
- bucket=Bucket,
- req_id=ReqId,
- caller=Caller},
- ignore,
- riak_kv_vnode_master).
+ riak_core_vnode:command(Preflist,
+ ?KV_LISTKEYS_REQ{
+ bucket=Bucket,
+ req_id=ReqId,
+ caller=Caller},
+ ignore,
+ ?MODULE).
fold(Preflist, Fun, Acc0) ->
- riak_core_vnode_master:sync_spawn_command(Preflist,
- ?FOLD_REQ{
- foldfun=Fun,
- acc0=Acc0},
- riak_kv_vnode_master).
+ riak_core_vnoder:sync_spawn_command(Preflist,
+ ?FOLD_REQ{
+ foldfun=Fun,
+ acc0=Acc0},
+ ?MODULE).
get_vclocks(Preflist, BKeyList) ->
- riak_core_vnode_master:sync_spawn_command(Preflist,
- ?KV_VCLOCK_REQ{bkeys=BKeyList},
- riak_kv_vnode_master).
+ riak_core_vnode:sync_spawn_command(Preflist,
+ ?KV_VCLOCK_REQ{bkeys=BKeyList},
+ ?MODULE).
%% VNode callbacks

0 comments on commit 478f2c6

Please sign in to comment.