Trim command and GC prototype implementation #32

Merged
kuenishi merged 4 commits from ku/trim-and-gc into master 2015-10-29 06:07:10 +00:00
3 changed files with 7 additions and 17 deletions
Showing only changes of commit 170b3cd797 - Show all commits

View file

@ -171,11 +171,11 @@ trim(#machi_csum_table{fd=Fd, table=T}, Offset, Size) ->
Error Error
end. end.
-spec all_trimmed(table(), machi_dt:chunk_pos(), machi_dt:chunk_pos()) -> boolean(). -spec all_trimmed(table(), non_neg_integer(), non_neg_integer()) -> boolean().
all_trimmed(#machi_csum_table{table=T}, Left, Right) -> all_trimmed(#machi_csum_table{table=T}, Left, Right) ->
runthru(ets:tab2list(T), Left, Right). runthru(ets:tab2list(T), Left, Right).
-spec all_trimmed(table(), machi_dt:chunk_pos()) -> boolean(). -spec all_trimmed(table(), non_neg_integer()) -> boolean().
all_trimmed(#machi_csum_table{table=T}, Pos) -> all_trimmed(#machi_csum_table{table=T}, Pos) ->
case ets:tab2list(T) of case ets:tab2list(T) of
[{0, ?MINIMUM_OFFSET, _}|L] -> [{0, ?MINIMUM_OFFSET, _}|L] ->

View file

@ -80,7 +80,7 @@
%% For "internal" replication only. %% For "internal" replication only.
-export([ -export([
write_chunk/5, write_chunk/6, write_chunk/5, write_chunk/6,
trim_chunk/5, trim_chunk/6, trim_chunk/5,
delete_migration/3, delete_migration/4, delete_migration/3, delete_migration/4,
trunc_hack/3, trunc_hack/4 trunc_hack/3, trunc_hack/4
]). ]).
@ -490,16 +490,6 @@ trim_chunk(Sock, EpochID, File0, Offset, Size)
{low_trim_chunk, EpochID, File, Offset, Size, 0}), {low_trim_chunk, EpochID, File, Offset, Size, 0}),
do_pb_request_common(Sock, ReqID, Req). do_pb_request_common(Sock, ReqID, Req).
%% @doc Restricted API: Write a chunk of already-sequenced data to
%% `File' at `Offset'.
-spec trim_chunk(machi_dt:inet_host(), machi_dt:inet_port(),
machi_dt:epoch_id(), machi_dt:file_name(), machi_dt:file_offset(), machi_dt:chunk_size()) ->
ok | {error, machi_dt:error_general()} | {error, term()}.
trim_chunk(_Host, _TcpPort, _EpochID, _File, _Offset, _Size) ->
not_used.
%% @doc Restricted API: Delete a file after it has been successfully %% @doc Restricted API: Delete a file after it has been successfully
%% migrated. %% migrated.

View file

@ -9,14 +9,14 @@
-endif. -endif.
-record(machi_plist, -record(machi_plist,
{filename :: string(), {filename :: file:filename_all(),
fd :: file:descriptor(), fd :: file:io_device(),
list}). list = [] :: list(string)}).
-type plist() :: #machi_plist{}. -type plist() :: #machi_plist{}.
-export_type([plist/0]). -export_type([plist/0]).
-spec open(filename:filename(), proplists:proplist()) -> -spec open(file:filename_all(), proplists:proplist()) ->
{ok, plist()} | {error, file:posix()}. {ok, plist()} | {error, file:posix()}.
open(Filename, _Opt) -> open(Filename, _Opt) ->
List = case file:read_file(Filename) of List = case file:read_file(Filename) of