59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/scenario.rb', line 59
def run(clients)
clients.each do |client|
client.msg 't' => 'STOP'
end
rand_clients = clients.sort_by { rand }
proxy = rand_clients.pop
master_db = rand_clients.pop
slave_dbs = rand_clients.slice!(0,2)
rails_nodes = rand_clients.slice!(0,5)
slave_dbs.each do |slave_db|
slave_db.msg 't' => 'ROLE', 'role' => 'db', 'slaves' => [], 'slave' => true
end
master_db.msg 't' => 'ROLE', 'role' => 'db', 'slaves' => slave_dbs.map { |n| n.addr }
rails_nodes.each do |rails|
rails.msg 't' => 'ROLE', 'role' => 'rails', 'db_write' => [master_db.addr], 'db_read' => slave_dbs.map { |n| n.addr }
end
proxy.msg 't' => 'ROLE', 'role' => 'proxy', 'backends' => rails_nodes.map { |n| n.addr }
end
|