Skip to content

Commit

Permalink
hibari >> GH51 - Update for Erlang/OTP 18
Browse files Browse the repository at this point in the history
- Add "18" to require_otp_vsn of rebar.config.
- Replace deprecated erlang:now/0 with erlang:timestamp/0.
  • Loading branch information
tatsuya6502 committed Nov 9, 2015
1 parent cb9f954 commit a08883f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions include/partition_detector.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
node, % Node name (atom)
net, % 'A' | 'B'
count, % Counter (integer)
time, % now()
time, % erlang:timestamp()
extra = []
}).

-record(history, {
node_net, % {node(), 'A' | 'B'}
lastcount, % int()
lasttime, % now()
lasttime, % erlang:timestamp()
beacon % #beacon
}).

10 changes: 5 additions & 5 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
%%% -*- mode: erlang -*-

%% Require OTP version R13B04, R14, R15, R16, or 17
{require_otp_vsn, "R13B04|R14|R15|R16|17"}.
{require_otp_vsn, "R13B04|R14|R15|R16|17|18"}.

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

%% Erlang compiler options
{erl_opts, [debug_info, warnings_as_errors
, {parse_transform, lager_transform}
, {i, "../gmt_util/include/"}
{erl_opts, [debug_info,
warnings_as_errors,
{parse_transform, lager_transform},
{i, "../gmt_util/include/"}
]}.

%% EUnit options
Expand Down
10 changes: 6 additions & 4 deletions src/partition_detector_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
-include("partition_detector.hrl").
-include("gmt_elog.hrl").

-define(TIME, gmt_time_otp18).

-define(UDP_PORT_STATUS, 63099).
-define(UDP_PORT_STATUS_XMIT, 63100). % Actual port may be higher

Expand Down Expand Up @@ -451,7 +453,7 @@ open_a_udp_sock(PortNum, MyAddr) ->

pack_beacon(Count, NetAbbr, Extra) ->
term_to_binary(#beacon{node = node(), net = NetAbbr, count = Count,
time = now(), extra = Extra}).
time = ?TIME:timestamp(), extra = Extra}).

unpack_beacon(B) ->
binary_to_term(B).
Expand All @@ -462,14 +464,14 @@ process_beacon(FromAddr, FromPort, B, S) ->
gen_event:notify(S#state.event_pid, {beacon_event, FromAddr, FromPort, B}),
Key = {B#beacon.node, B#beacon.net},
H = #history{node_net = Key,
lastcount = B#beacon.count, lasttime = now(), beacon = B},
lastcount = B#beacon.count, lasttime = ?TIME:timestamp(), beacon = B},
NewH = [H|lists:keydelete(Key, #history.node_net, S#state.h_list)],
S#state{h_list = NewH}.

%% @spec (S::state_r()) -> state_r()

do_check_status(S) ->
Now = now(),
Now = ?TIME:timestamp(),
HeartWarnUsec = S#state.heart_warn * 1000*1000,
CheckNet =
fun(Net) ->
Expand Down Expand Up @@ -513,7 +515,7 @@ do_check_status(S) ->
last_onlyabad = OnlyABad, last_onlybbad = OnlyBBad}.

do_check_failure(S) ->
Now = now(),
Now = ?TIME:timestamp(),
HeartFailUsec = S#state.heart_fail * 1000*1000,
F = fun(N) ->
BSecs = case get_history(N, 'B',
Expand Down

0 comments on commit a08883f

Please sign in to comment.