面对软件错误构建可靠的分布式系统_笔记13
来源:互联网 发布:法兰绒哪个牌子好 知乎 编辑:程序博客网 时间:2024/05/29 14:34
-module(thesis_simple_sup).
-behaviour(supervisor).
-export([start/0, init/1]).
start() ->
supervisor:start_link({local, thesis_simple_sup}, ?MODULE, nil).
init(_) ->
{ok,
{%%one_for_one:或型监督树,如果1000秒内被监督者重启超过5次,则监督者本身也错误
{one_for_one, 5, 1000},
[
{packet, %%被监督节点名称,要树内唯一
{thesis_packet_assembler, start,[]}, %%被监督者模块、启动命令和参数
%%permanent表示如果出错则自动重启,500指关停协议中Timer=500ms,worker指工作进程,最后是模块名称
permanent, 500, worker, [thesis_packet_assembler]},
{server,
{thesis_kv, start, []},
permanent, 500, worker,[thesis_kv]},
{logger,
{thesis_simple_logger, start, []},
permanent, 500, worker, [thesis_simple_logger]
}
]
}}.
-module(thesis_simple_sup).
-behaviour(supervisor).
-export([start/0, init/1]).
start() ->
supervisor:start_link({local, thesis_simple_sup}, ?MODULE, nil).
init(_) ->
{ok,
{{one_for_one, 5, 1000},
[
{packet,
{thesis_assember, start,[]},
permanent, 500, worker, [thesis_assember]},
{server,
{thesis_kv, start, []},
permanent, 500, worker,[thesis_kv]},
{logger,
{thesis_logger, start, []},
permanent, 500, worker, [thesis_logger]}
]
}}.
[ {description, "A simple application"},
{vsn, "1.0"},
{modules, [thesis_simple,thesis_kv,thesis_logger,
thesis_assember,thesis_simple_sup]},
{maxT, infinity},
{registered, [thesis_kv,my_simple_event_logger,my_simple_packet_assembler]},
{applications, []},
{included_applications, []},
{evn, []},
{mod, {thesis_simple, go}}]}.
-module(thesis_simple).
-behaviour(application).
-export([start/2]).
start(_,_) -> thesis_simple_sup:start().
1> application:start(thesis_simple, temporary).
Packet assembler starting
Key-Value server starting
Logger starting
ok
2> thesis_kv:store("yes","test").
ack
3> thesis_logger:log("hello").
ok
4> thesis_assember:send_header(2).
ok
5> thesis_assember:send_data("h")
5> .
ok
6> thesis_assember:send_data("h").
Got data:hh
ok
7> application:stop(thesis_simple).
=INFO REPORT==== 29-Jan-2009::20:59:07 ===
application: thesis_simple
exited: stopped
type: temporary
ok
- 面对软件错误构建可靠的分布式系统_笔记13
- 面对软件错误构建可靠的分布式系统_笔记01
- 面对软件错误构建可靠的分布式系统_笔记02
- 面对软件错误构建可靠的分布式系统_笔记03
- 面对软件错误构建可靠的分布式系统_笔记04
- 面对软件错误构建可靠的分布式系统_笔记05
- 面对软件错误构建可靠的分布式系统_笔记06
- 面对软件错误构建可靠的分布式系统_笔记07
- 面对软件错误构建可靠的分布式系统_笔记08
- 面对软件错误构建可靠的分布式系统_笔记09
- 面对软件错误构建可靠的分布式系统_笔记10
- 面对软件错误构建可靠的分布式系统_笔记11
- 面对软件错误构建可靠的分布式系统_笔记12
- 面对软件错误构建可靠的分布式系统_笔记14
- 面对软件错误构建可靠的分布式系统-1摘要
- 面对软件错误构建可靠的分布式系统-2绪论
- 面对软件错误构建可靠的分布式系统-4Erlang
- 面对软件错误构建可靠的分布式系统-11总结
- 面对软件错误构建可靠的分布式系统_笔记10
- 征婚
- 面对软件错误构建可靠的分布式系统_笔记11
- 面对软件错误构建可靠的分布式系统_笔记12
- jQuery - UI
- 面对软件错误构建可靠的分布式系统_笔记13
- 面对软件错误构建可靠的分布式系统_笔记14
- Socket Kernel Source Chapter01 Introducation
- Socket Kernel Source Chapter02 sys_socketcall
- jQuery - fadeIn淡入效果
- Socket Kernel Source Chapter03 socket
- Class.getResourceAsStream 和 ClassLoader.getResourceAsStream
- Socket Kernel Source Chapter04 bind
- 读后感:>