diff options
author | Piotr Dorobisz <[email protected]> | 2011-03-09 13:39:13 +0100 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2011-08-30 15:22:17 +0200 |
commit | 97fd7481fa5f6ba04b86e0251750a6f9386ca964 (patch) | |
tree | a195b3304a5a3671a390d9fc129ea19a503795d1 /lib | |
parent | 45dbca7a4719eb4472e41cc83aac977d0f4b1e5c (diff) | |
download | otp-97fd7481fa5f6ba04b86e0251750a6f9386ca964.tar.gz otp-97fd7481fa5f6ba04b86e0251750a6f9386ca964.tar.bz2 otp-97fd7481fa5f6ba04b86e0251750a6f9386ca964.zip |
Overload protection
Diffstat (limited to 'lib')
-rw-r--r-- | lib/observer/src/ttb.erl | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/lib/observer/src/ttb.erl b/lib/observer/src/ttb.erl index 71afe434bf..0491f3c202 100644 --- a/lib/observer/src/ttb.erl +++ b/lib/observer/src/ttb.erl @@ -60,9 +60,9 @@ tracer(Nodes) -> tracer(Nodes,[]). tracer(Nodes,Opt) -> {PI,Client,Traci} = opt(Opt), %%We use initial Traci as SessionInfo for loop/2 - start(Traci), + Pid = start(Traci), store(tracer,[Nodes,Opt]), - do_tracer(Nodes,PI,Client,Traci). + do_tracer(Nodes,PI,Client,[{ttb_control, Pid}|Traci]). do_tracer(Nodes0,PI,Client,Traci) -> Nodes = nods(Nodes0), @@ -124,6 +124,8 @@ opt([{timer, {MSec, StopOpts}}|O],{PI,Client,Traci}) -> opt(O,{PI,Client,[{timer,{MSec, StopOpts}}|Traci]}); opt([{timer, MSec}|O],{PI,Client,Traci}) -> opt(O,{PI,Client,[{timer,{MSec, []}}|Traci]}); +opt([{overload_check, {MSec,M,F}}|O],{PI,Client,Traci}) -> + opt(O,{PI,Client,[{overload_check,{MSec,M,F}}|Traci]}); opt([],Opt) -> Opt. @@ -330,6 +332,7 @@ arg_list([A1|A],Acc) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Set trace flags on processes p(Procs0,Flags0) -> + ensure_no_overloaded_nodes(), store(p,[Procs0,Flags0]), no_store_p(Procs0,Flags0). no_store_p(Procs0,Flags0) -> @@ -383,22 +386,28 @@ proc({global,Name}) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Trace pattern tp(A,B) -> + ensure_no_overloaded_nodes(), store(tp,[A,ms(B)]), dbg:tp(A,ms(B)). tp(A,B,C) -> + ensure_no_overloaded_nodes(), store(tp,[A,B,ms(C)]), dbg:tp(A,B,ms(C)). tp(A,B,C,D) -> + ensure_no_overloaded_nodes(), store(tp,[A,B,C,ms(D)]), dbg:tp(A,B,C,ms(D)). tpl(A,B) -> + ensure_no_overloaded_nodes(), store(tpl,[A,ms(B)]), dbg:tpl(A,ms(B)). tpl(A,B,C) -> + ensure_no_overloaded_nodes(), store(tpl,[A,B,ms(C)]), dbg:tpl(A,B,ms(C)). tpl(A,B,C,D) -> + ensure_no_overloaded_nodes(), store(tpl,[A,B,C,ms(D)]), dbg:tpl(A,B,C,ms(D)). @@ -451,6 +460,14 @@ ms({codestr, FunStr}) -> ms(Other) -> Other. +ensure_no_overloaded_nodes() -> + ttb ! {get_overloaded, self()}, + Overloaded = receive O -> O after 300 -> [] end, + case Overloaded of + [] -> ok; + Overloaded -> exit({error, overload_protection_active, Overloaded}) + end. + -spec string2ms(string()) -> {ok, list()} | {error, fun_format}. string2ms(FunStr) -> case erl_scan:string(fix_dot(FunStr)) of @@ -568,9 +585,10 @@ start(SessionInfo) -> undefined -> Parent = self(), Pid = spawn(fun() -> init(Parent, SessionInfo) end), - receive {started,Pid} -> ok end; + receive {started,Pid} -> ok end, + Pid; Pid when is_pid(Pid) -> - ok + Pid end. @@ -612,6 +630,14 @@ loop(NodeInfo, SessionInfo) -> {timeout, StopOpts} -> spawn(?MODULE, stop, [StopOpts]), loop(NodeInfo, SessionInfo); + {node_overloaded, Node} -> + io:format("Overload check activated on node: ~p.~n", [Node]), + {Overloaded, SI} = {proplists:get_value(overloaded, SessionInfo, []), + lists:keydelete(overloaded, 1, SessionInfo)}, + loop(NodeInfo, [{overloaded, [Node|Overloaded]} | SI]); + {get_overloaded, Pid} -> + Pid ! proplists:get_value(overloaded, SessionInfo, []), + loop(NodeInfo, SessionInfo); trace_started -> case proplists:get_value(timer, SessionInfo) of undefined -> ok; |