Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
James Aimonetti committed Mar 26, 2012
1 parent 7e1cb1b commit 78ede87
Show file tree
Hide file tree
Showing 14 changed files with 514 additions and 452 deletions.
8 changes: 1 addition & 7 deletions ecallmgr/src/ecallmgr_fs_auth.erl
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,13 @@ handle_info({'EXIT', LU, _Reason}, #state{node=Node, lookups=LUs}=State) ->
{noreply, State#state{lookups=lists:keydelete(LU, 1, LUs)}, hibernate};

handle_info(timeout, #state{node=Node}=State) ->
Type = {bind, directory},

{foo, Node} ! Type,
receive
case freeswitch:bind(Node, directory) of
ok ->
lager:debug("bound to directory request on ~s", [Node]),
{noreply, State};
{error, Reason} ->
lager:debug("failed to bind to directory requests on ~s, ~p", [Node, Reason]),
{stop, Reason, State}
after ?FS_TIMEOUT ->
lager:debug("timed out binding to directory requests on ~s", [Node]),
{stop, timeout, State}
end;

handle_info(_Info, State) ->
Expand Down
8 changes: 1 addition & 7 deletions ecallmgr/src/ecallmgr_fs_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,13 @@ handle_info({_Fetch, _Section, _Something, _Key, _Value, ID, [undefined | _Data]
{noreply, State};

handle_info(timeout, #state{node=Node}=State) ->
Type = {bind, config},

{foo, Node} ! Type,
receive
case freeswitch:bind(Node, config) of
ok ->
lager:debug("bound to config request on ~s", [Node]),
{noreply, State};
{error, Reason} ->
lager:debug("failed to bind to config requests on ~s, ~p", [Node, Reason]),
{stop, Reason, State}
after ?FS_TIMEOUT ->
lager:debug("timed out binding to config requests on ~s", [Node]),
{stop, timeout, State}
end;

handle_info(_Info, State) ->
Expand Down
9 changes: 5 additions & 4 deletions ecallmgr/src/ecallmgr_fs_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ handle_cast(_Msg, State) ->
%% @end
%%--------------------------------------------------------------------
handle_info({nodedown, Node}, #state{fs_nodes=Nodes, node_reconnect_pids=ReconPids}=State) ->
lager:debug("node ~p has gone down", [Node]),
lager:warning("node ~p has gone down", [Node]),
WatcherPid = spawn_link(fun() ->
case [N || #node_handler{node=Node1}=N <- Nodes, Node =:= Node1] of
[#node_handler{node=Node, options=Opts}] ->
Expand All @@ -227,7 +227,6 @@ handle_info({'EXIT', Pid, _Reason}, #state{node_reconnect_pids=ReconPids}=State)
lager:debug("pid ~p exited: ~p", [Pid, _Reason]),
{noreply, State#state{node_reconnect_pids=lists:keydelete(Pid, 2, ReconPids)}};
handle_info(_Info, State) ->
lager:debug("unhandled message: ~p", [_Info]),
{noreply, State}.

%%--------------------------------------------------------------------
Expand Down Expand Up @@ -275,7 +274,7 @@ watch_node_for_restart(Node, Opts, Timeout) ->
is_node_up(Node, Opts, Timeout) ->
case net_adm:ping(Node) of
pong ->
lager:debug("node ~s has risen", [Node]),
lager:info("node ~s has risen", [Node]),
?MODULE:add_fs_node(Node, Opts);
pang ->
lager:debug("waiting ~b seconds to ping again", [Timeout div 1000]),
Expand Down Expand Up @@ -333,13 +332,15 @@ add_fs_node(Node, Options, #state{fs_nodes=Nodes}=State) ->
(_) -> false
end, ecallmgr_fs_sup:start_handlers(Node, Options)) of
true ->
lager:info("successfully connected to node '~s'", [Node]),
{ok, State#state{fs_nodes=[#node_handler{node=Node, options=Options} | Nodes]}};
false ->
lager:warning("failed to start all handlers for node '~s'", [Node]),
self() ! {nodedown, Node},
{{error, failed_starting_handlers}, State}
end;
pang ->
lager:debug("node ~p not responding, can't connect", [Node]),
lager:info("unable to connect to node '~s'; ensure it is reachable from this server and using cookie '~s'", [Node, erlang:get_cookie()]),
self() ! {nodedown, Node},
{{error, no_connection}, State}
end;
Expand Down
245 changes: 139 additions & 106 deletions ecallmgr/src/ecallmgr_fs_node.erl

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions ecallmgr/src/ecallmgr_fs_route.erl
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ handle_info({is_node_up, Timeout}, #state{node=Node}=State) ->

handle_info(shutdown, #state{node=Node, lookups=LUs}=State) ->
lists:foreach(fun({Pid, _CallID, _StartTime}) ->
case erlang:is_process_alive(Pid) of
case erlang:is_process_alive(Pid) of
true -> Pid ! shutdown;
false -> ok
end
Expand All @@ -194,19 +194,13 @@ handle_info({diagnostics, Pid}, #state{stats=Stats, lookups=LUs}=State) ->
{noreply, State};

handle_info(timeout, #state{node=Node}=State) ->
Type = {bind, dialplan},

{foo, Node} ! Type,
receive
case freeswitch:bind(Node, dialplan) of
ok ->
lager:debug("bound to dialplan request on ~s", [Node]),
{noreply, State};
{error, Reason} ->
lager:debug("failed to bind to dialplan requests on ~s, ~p", [Node, Reason]),
{stop, Reason, State}
after ?FS_TIMEOUT ->
lager:debug("timed out binding to dialplan requests on ~s", [Node]),
{stop, timeout, State}
end;

handle_info(_Other, State) ->
Expand Down
Loading

0 comments on commit 78ede87

Please sign in to comment.