157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/scenario.rb', line 157
def run(clients)
clients.each do |client|
client.msg 't' => 'STOP'
end
rand_clients = clients.sort_by { rand }
proxies = rand_clients.slice!(0,2)
peer_dbs = rand_clients.slice!(0,3)
stats_nodes = rand_clients.slice!(0,2)
rails_nodes = rand_clients.slice!(0,5)
peer_dbs.each do |peer_db|
peer_db.msg 't' => 'ROLE', 'role' => 'db', 'slaves' => [], 'slave' => false
end
stats_nodes.each do |stats|
stats.msg 't' => 'ROLE', 'role' => 'stats', 'db_peer' => peer_dbs.map { |n| n.addr }
end
rails_nodes.each do |rails|
rails.msg 't' => 'ROLE', 'role' => 'rails', 'db_peer' => peer_dbs.map { |n| n.addr }
end
proxies.each do |proxy|
proxy.msg 't' => 'ROLE', 'role' => 'proxy', 'backends' => rails_nodes.map { |n| n.addr }, 'stats_backends' => stats_nodes.map { |n| n.addr }
end
end
|