Permalink
Browse files

kv_vnode: expose backend size for handoff progress if backend is capable

  • Loading branch information...
1 parent cafd2d0 commit 7079daa6f6fdb1b38fff63b0b327fdaa1d206429 @jrwest jrwest committed Feb 21, 2013
Showing with 15 additions and 1 deletion.
  1. +15 −1 src/riak_kv_vnode.erl
View
@@ -760,7 +760,21 @@ encode_handoff_item({B, K}, V) ->
#riakobject_pb{bucket=B, key=K, val=Val})).
is_empty(State=#state{mod=Mod, modstate=ModState}) ->
- {Mod:is_empty(ModState), State}.
+ IsEmpty = Mod:is_empty(ModState),
+ case IsEmpty of
+ true ->
+ {true, State};
+ false ->
+ Size = maybe_calc_handoff_size(State),
+ {false, Size, State}
+ end.
+
+maybe_calc_handoff_size(#state{mod=Mod,modstate=ModState}) ->
+ {ok, Capabilities} = Mod:capabilities(ModState),
+ case lists:member(size, Capabilities) of
+ true -> Mod:data_size(ModState);
+ false -> undefined
+ end.
delete(State=#state{idx=Index,mod=Mod, modstate=ModState}) ->
%% clear vnodeid first, if drop removes data but fails

0 comments on commit 7079daa

Please sign in to comment.