-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.rb
38 lines (38 loc) · 882 Bytes
/
test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$:File
.expand'_path
('../lib',
__FILE__)
require
'floss/node'[ CLUSTER_SIZE = 5 ]
[ nodes = CLUSTER_SIZE.times.map ]
do
|i|port = 5000
0 + i "tcp://127.0.0.1:#{port}"
endsupervisor=Celluloid::Supervision
Group.run
!CLUSTER_SIZE.times.map
do |i| combinationodes
.rotate(i) options={id:combination
.first,
peers: combination
[1..-1]}supervisor.supervise(Floss::Node, options)
end sleep 1 begin leader=supervisor
.actors
.find
(&:leader?)
puts
"The leader is #{leader.id}"
leader.execute
("Hello World!")rescue => e puts "Could
not execute my command!"pendsleep 1 begin
leader = supervisor.actors.find
(&:leader?)puts "The leader is
#{leader.id}" leader.execute
(
"Hello Again!"
) rescue => e
puts "Could execute my command!"
pend sleep 0.5
supervisor.actors
.each do |actor| Celluloid.logger.info("Log of #{actor.id}: #{actor.log.entries}")end
sleep 1 exit