Skip to content

Commit

Permalink
hibari >> GH36 - Update for Erlang/OTP 17.x.
Browse files Browse the repository at this point in the history
    - Conditionally use namespaced dict and queue types.
    - Add "17" to {require_otp_vsn, _}.
  • Loading branch information
tatsuya6502 committed Oct 14, 2014
1 parent afdd9e2 commit 2c40f66
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 16 deletions.
26 changes: 22 additions & 4 deletions include/brick_hash.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
%%% Purpose : brick hash stuff
%%%----------------------------------------------------------------------

-ifndef(hibari_dict).
-define(hibari_dict, true).
-ifdef(namespaced_dict_and_queue).
-type hibari_dict() :: dict:dict().
-else.
-type hibari_dict() :: dict().
-endif. %% namespaced_dict_and_queue
-endif. %% hibari_dict

-ifndef(hibari_queue).
-define(hibari_queue, true).
-ifdef(namespaced_dict_and_queue).
-type hibari_queue() :: queue:queue().
-else.
-type hibari_queue() :: queue().
-endif. %% namespaced_dict_and_queue
-endif. %% hibari_queue

%% Hash descriptor for a *single* table.
-record(hash_r, {
method :: naive | var_prefix | fixed_prefix | chash, % name of method,
Expand All @@ -38,15 +56,15 @@
minor_rev = 1 :: integer(), % updated each time that
% either of the 2 dicts below
% is updated
current_chain_dict :: dict(), % dict keyed by chain name
new_chain_dict :: dict(),
current_chain_dict :: hibari_dict(), % dict keyed by chain name
new_chain_dict :: hibari_dict(),

%% Migration-related stuff, maintained locally by each brick.
migrating_p = false :: boolean(),
phase = pre :: pre | migrating,
cookie :: term(),
migr_dict :: dict() | undefined % migration dictionary
% dict keyed by chain name
migr_dict :: hibari_dict() | undefined % migration dictionary
% dict keyed by chain name
}).

%% Character that separates the hashable prefix
Expand Down
16 changes: 10 additions & 6 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
%%% -*- mode: erlang -*-

%% Require OTP version R16
{require_otp_vsn, "R16"}.
%% Require OTP version R16 or 17
{require_otp_vsn, "R16|17"}.

%% Depends
{deps_dir, "../"}.
{deps, [{lager, ".*"}]}.

%% Erlang compiler options
{erl_opts, [debug_info, warnings_as_errors
, {parse_transform, lager_transform}
, {i, "../gmt_util/include/"}
, {i, "../partition_detector/include/"}
{erl_opts, [%% In Erlang releases after 17, use dict:dict()
%% and queue:queue() for dict() and queue() types.
{platform_define, "^[0-9]+", namespaced_dict_and_queue},
debug_info,
warnings_as_errors,
{parse_transform, lager_transform},
{i, "../gmt_util/include/"},
{i, "../partition_detector/include/"}
]}.

%% EUnit options
Expand Down
6 changes: 3 additions & 3 deletions src/brick_ets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@
n_do = 0 :: non_neg_integer(),
n_expired = 0 :: non_neg_integer(),
%% CHAIN TODO: Do these 2 items really belong here??
logging_op_serial = 42 :: non_neg_integer(), % Serial # of logging op
logging_op_q = queue:new() :: queue(), % Queue of logged ops for
logging_op_serial = 42 :: non_neg_integer(), % Serial # of logging op
logging_op_q = queue:new() :: hibari_queue(), % Queue of logged ops for
% replay when log sync is done.
%% n_log_replay = 0,
log :: pid(), % disk_log for data mod cmds
Expand All @@ -193,7 +193,7 @@
checkpoint_timer :: reference(), % Timer for checkpoint
checkpoint_opts :: proplist(), % Proplist for checkpoint
dirty_tab :: table_name(), % ETS table: dirty key search
wait_on_dirty_q :: queue(), % Queue of ops waiting on
wait_on_dirty_q :: hibari_queue(), % Queue of ops waiting on
% dirty keys
read_only_p = false :: boolean(), % Mirror of upper-level's var.
expiry_tref :: reference(), % Timer ref for expiry events
Expand Down
8 changes: 7 additions & 1 deletion src/brick_itimer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@
%% Internal export
-export([start_interval_loop/1, interval_loop/1]).

-ifdef(namespaced_dict_and_queue).
-type hibari_dict() :: dict:dict().
-else.
-type hibari_dict() :: dict().
-endif.

-define(SERVER, ?MODULE).

-record(state, {
interval_d=dict:new() :: dict() % key: interval size, val: pid
interval_d=dict:new() :: hibari_dict() % key: interval size, val: pid
}).

%%%===================================================================
Expand Down
4 changes: 2 additions & 2 deletions src/brick_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@
% downstream
, down_acked = 0 :: integer() % Serial # for last ack'ed item
% by downstream.
, down_unacked :: queue() % queue() of un-acked
, down_unacked :: hibari_queue() % queue() of un-acked
% ch_log_replay messages
, last_ack = undefined :: brick_bp:nowtime() | undefined % now() time of last ack by
% downstream.
Expand Down Expand Up @@ -599,7 +599,7 @@
, impl_state :: tuple() % state record of implementation module
%% Chain replication stuff.
, chainstate :: #chain_r{} % Chain state
, logging_op_q :: queue() % Queue of logged ops for
, logging_op_q :: hibari_queue() % Queue of logged ops for
% replay when log sync is done.
, globalhash = undefined :: #g_hash_r{} | undefined % Global hash state
, sweepstate :: #sweep_r{} | undefined % Migration sweep state
Expand Down

0 comments on commit 2c40f66

Please sign in to comment.