Permalink
Browse files

demo files

  • Loading branch information...
1 parent 2506d92 commit 30b136e6cef4d90b26e4c31ba38ca57cdf33fa09 @bernardpaulus committed May 18, 2012
Showing with 73 additions and 0 deletions.
  1. +21 −0 erlang/project/demo_epoch_change.erl
  2. +17 −0 erlang/project/demo_rwec.erl
  3. +35 −0 erlang/project/demo_rwec.erl.log
@@ -0,0 +1,21 @@
+-module(demo_epoch_change).
+-compile(export_all).
+
+dslinks(N) ->
+ Links = link:damn_simple_link([node() || _ <- lists:seq(1, N)]),
+ test(Links, N).
+
+perfect_link(N) ->
+
+ Links = link:perfect_link([node() || _ <- lists:seq(1, N)]),
+ test(Links, N).
+
+test(Links, N) ->
+ Bebs = beb:start(Links),
+ Fail_Dets = inc_timeout_fd:start(Links),
+ Mon_ELD = monarch_eld:start(Fail_Dets, Links),
+ Rs = [utils:dummy_receiver() || _ <- lists:seq(1, N)],
+ Echs = epoch_change:start(Mon_ELD, Bebs, Links),
+ receive after 100 -> pass end,
+ [utils:subscribe(R, Ech) || {Ech, R} <- lists:zip(Echs, Rs)],
+ {echs, Echs, rs, Rs}.
@@ -0,0 +1,17 @@
+-module(demo_rwec).
+-compile(export_all).
+
+start(N) ->
+ %% The links
+ Links = link:perfect_link([ node() || _ <- lists:seq(1, N)]),
+ receive after 100 -> pass end,
+ Bebs = beb:start(Links),
+ Rs = [utils:dummy_receiver() || _ <- lists:seq(1, N)],
+ E_States = [{0, bottom} || _ <- Bebs],
+ receive after 100 -> pass end,
+ Epoch_Conss = [_E1, _E2, _E3] = rw_epoch_cons:start(Bebs, Links, 0, E_States),
+ [utils:subscribe(R, Ec) || {Ec, R} <- lists:zip(Epoch_Conss, Rs)],
+ receive after 100 -> pass end,
+ hd(Epoch_Conss) ! {propose, bonjour},
+
+ {econs, Epoch_Conss, rs, Rs}.
@@ -0,0 +1,35 @@
+1> Ret = demo_rwec:start(3).
+{econs,[<0.46.0>,<0.47.0>,<0.48.0>],
+ rs,
+ [<0.43.0>,<0.44.0>,<0.45.0>]}
+process <0.43.0> of nonode@nohost received
+{decide,bonjour,0}
+process <0.44.0> of nonode@nohost received
+{decide,bonjour,0}
+process <0.45.0> of nonode@nohost received
+{decide,bonjour,0}
+2> {_, ECs, _, _} = Ret.
+{econs,[<0.46.0>,<0.47.0>,<0.48.0>],
+ rs,
+ [<0.43.0>,<0.44.0>,<0.45.0>]}
+3> lists:foreach(fun(E) -> E ! {abort, self(), 0}, receive {aborted, State, Ets} -> rw_epoch_cons:reinit(E, Ets + 1, State) after 100 -> fail end end, ECs).
+ok
+4> hd(ECs) ! {propose, boire_un_cafe}.
+{propose,boire_un_cafe}
+process <0.43.0> of nonode@nohost received
+{decide,bonjour,1}
+process <0.44.0> of nonode@nohost received
+{decide,bonjour,1}
+process <0.45.0> of nonode@nohost received
+{decide,bonjour,1}
+5> lists:foreach(fun(E) -> E ! {abort, self(), 1}, receive {aborted, {State_ts, _Val}, Ets} -> rw_epoch_cons:reinit(E, Ets + 1, {State_ts, bottom}) after 100 -> fail end end, ECs).
+ok
+6> hd(ECs) ! {propose, boire_un_cafe}.
+{propose,boire_un_cafe}
+process <0.43.0> of nonode@nohost received
+{decide,boire_un_cafe,2}
+process <0.45.0> of nonode@nohost received
+{decide,boire_un_cafe,2}
+process <0.44.0> of nonode@nohost received
+{decide,boire_un_cafe,2}
+7>

0 comments on commit 30b136e

Please sign in to comment.