Cleanup MACROs and changed default value

* machi_file_proxy now uses application environment
  value `max_file_size` via machi_config
* changed name from MAX_FILE_SIZE to DEFAULT_MAX_FILE_SIZE
This commit is contained in:
UENISHI Kota 2015-10-27 11:05:07 +09:00
parent 5913531e32
commit b2eb3e089c
4 changed files with 13 additions and 13 deletions

View file

@ -18,10 +18,9 @@
%%
%% -------------------------------------------------------------------
-define(MAX_FILE_SIZE, 256*1024*1024). % 256 MBytes
-define(MAX_CHUNK_SIZE, ((1 bsl 32) - 1)).
%% -define(DATA_DIR, "/Volumes/SAM1/seq-tests/data").
-define(DATA_DIR, "./data").
%% @doc Now 4GiBytes, could be up to 64bit due to PB message limit of
%% chunk size
-define(DEFAULT_MAX_FILE_SIZE, ((1 bsl 32) - 1)).
-define(MINIMUM_OFFSET, 1024).
%% 0th draft of checksum typing with 1st byte.
@ -34,4 +33,5 @@
-define(PB_MAX_MSG_SIZE, (33*1024*1024)).
-define(PB_PACKET_OPTS, [{packet, 4}, {packet_size, ?PB_MAX_MSG_SIZE}]).
%% TODO: it's used in flu_sup and elsewhere, change this to suitable name
-define(TEST_ETS_TABLE, test_ets_table).

View file

@ -5,9 +5,6 @@
{mod,{machi_app,[]}},
{registered, []},
{env, [
{flu_list,
[
%%%%%% {flu_a, 32900, "./data.flu_a"}
]}
%% Don't use this env for defaults, or I'll give some poopies
]}
]}.

View file

@ -40,4 +40,4 @@
-spec max_file_size() -> pos_integer().
max_file_size() ->
application:get_env(machi, max_file_size, ?MAX_FILE_SIZE).
application:get_env(machi, max_file_size, ?DEFAULT_MAX_FILE_SIZE).

View file

@ -86,7 +86,8 @@
csum_path :: string()|undefined,
data_filehandle :: file:io_device(),
csum_table :: machi_csum_table:table(),
eof_position = 0 :: non_neg_integer(),
eof_position = 0 :: machi_dt:chunk_pos(),
max_file_size = ?DEFAULT_MAX_FILE_SIZE :: machi_dt:chunk_pos(),
tref :: reference(), %% timer ref
ticks = 0 :: non_neg_integer(), %% ticks elapsed with no new operations
ops = 0 :: non_neg_integer(), %% sum of all ops
@ -222,7 +223,8 @@ init({Filename, DataDir}) ->
data_filehandle = FHd,
csum_table = CsumTable,
tref = Tref,
eof_position = Eof},
eof_position = Eof,
max_file_size = machi_config:max_file_size()},
lager:debug("Starting file proxy ~p for filename ~p, state = ~p, Eof = ~p",
[self(), Filename, St, Eof]),
{ok, St}.
@ -390,9 +392,10 @@ handle_cast(Cast, State) ->
{noreply, State}.
% @private
handle_info(tick, State = #state{eof_position = Eof}) when Eof >= ?MAX_FILE_SIZE ->
handle_info(tick, State = #state{eof_position = Eof,
max_file_size = MaxFileSize}) when Eof >= MaxFileSize ->
lager:notice("Eof position ~p >= max file size ~p. Shutting down.",
[Eof, ?MAX_FILE_SIZE]),
[Eof, MaxFileSize]),
{stop, file_rollover, State};
%% XXX Is this a good idea? Need to think this through a bit.