Snapshot Work - Interim Commit

Some initial work to get snapshots going.

Changes required, as need to snapshot through the Bookie to ensure that
there is no race between extracting the Bookie's in-memory view and the
Penciller's view if a push_to_mem has occurred inbetween.

A lot still outstanding, especially around Inker snapshots, and handling
timeouts
This commit is contained in:
martinsumner 2016-09-23 18:50:29 +01:00
parent d3e985ed80
commit c64d67d9fb
5 changed files with 160 additions and 75 deletions

View file

@ -138,6 +138,8 @@
book_riakput/3,
book_riakget/3,
book_riakhead/3,
book_snapshotstore/3,
book_snapshotledger/3,
book_close/1,
strip_to_keyonly/1,
strip_to_keyseqonly/1,
@ -180,6 +182,12 @@ book_riakhead(Pid, Bucket, Key) ->
PrimaryKey = {o, Bucket, Key},
gen_server:call(Pid, {head, PrimaryKey}, infinity).
book_snapshotstore(Pid, Requestor, Timeout) ->
gen_server:call(Pid, {snapshot, Requestor, store, Timeout}, infinity).
book_snapshotledger(Pid, Requestor, Timeout) ->
gen_server:call(Pid, {snapshot, Requestor, ledger, Timeout}, infinity).
book_close(Pid) ->
gen_server:call(Pid, close, infinity).
@ -268,6 +276,19 @@ handle_call({head, Key}, _From, State) ->
{reply, {ok, OMD}, State}
end
end;
handle_call({snapshot, Requestor, SnapType, _Timeout}, _From, State) ->
PCLopts = #penciller_options{start_snapshot=true,
source_penciller=State#state.penciller,
requestor=Requestor},
{ok, LedgerSnapshot} = leveled_penciller:pcl_start(PCLopts),
case SnapType of
store ->
InkerOpts = #inker_options{},
{ok, JournalSnapshot} = leveled_inker:ink_start(InkerOpts),
{reply, {ok, LedgerSnapshot, JournalSnapshot}, State};
ledger ->
{reply, {ok, LedgerSnapshot, null}, State}
end;
handle_call(close, _From, State) ->
{stop, normal, ok, State}.