Skip to content

Commit 7079daa

Browse files
committed
kv_vnode: expose backend size for handoff progress if backend is capable
1 parent cafd2d0 commit 7079daa

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/riak_kv_vnode.erl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,21 @@ encode_handoff_item({B, K}, V) ->
760760
#riakobject_pb{bucket=B, key=K, val=Val})).
761761

762762
is_empty(State=#state{mod=Mod, modstate=ModState}) ->
763-
{Mod:is_empty(ModState), State}.
763+
IsEmpty = Mod:is_empty(ModState),
764+
case IsEmpty of
765+
true ->
766+
{true, State};
767+
false ->
768+
Size = maybe_calc_handoff_size(State),
769+
{false, Size, State}
770+
end.
771+
772+
maybe_calc_handoff_size(#state{mod=Mod,modstate=ModState}) ->
773+
{ok, Capabilities} = Mod:capabilities(ModState),
774+
case lists:member(size, Capabilities) of
775+
true -> Mod:data_size(ModState);
776+
false -> undefined
777+
end.
764778

765779
delete(State=#state{idx=Index,mod=Mod, modstate=ModState}) ->
766780
%% clear vnodeid first, if drop removes data but fails

0 commit comments

Comments
 (0)