Class: GameMachine::Console::TestCluster

Inherits:
Object
  • Object
show all
Defined in:
server/lib/game_machine/console/test_cluster.rb

Instance Method Summary collapse

Constructor Details

#initializeTestCluster

Returns a new instance of TestCluster


7
8
# File 'server/lib/game_machine/console/test_cluster.rb', line 7

def initialize
end

Instance Method Details

#ping_node(name) ⇒ Object


37
38
39
40
41
42
43
44
45
# File 'server/lib/game_machine/console/test_cluster.rb', line 37

def ping_node(name)
  client = GameMachine::Clients::TestClient.new('test',name)
  if client.
    puts "Logged in successfully"
    client.logout
  else
    puts "Unable to login"
  end
end

#run_node(node, seed_node, is_seed) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'server/lib/game_machine/console/test_cluster.rb', line 16

def run_node(node,seed_node,is_seed)
  cmd = 'CLUSTER_TEST=1 '
  cmd << "NODE_HOST=#{node[:host]} "
  cmd << "AKKA_PORT=#{node[:akka_port]} "
  cmd << "UDP_PORT=#{node[:udp_port]} "
  cmd << "TCP_PORT=#{node[:tcp_port]} "
  cmd << "WWW_PORT=#{node[:www_port]} "
  unless is_seed
    cmd << "AKKA_SEED_HOST=#{seed_node[:host]} AKKA_SEED_PORT=#{seed_node[:akka_port]} "
  end
  classpath = File.join(ENV['JAVA_ROOT'],'lib/*')
  cmd << "jruby -J-cp \"#{classpath}\" bin/game_machine s &"
  puts cmd
  system(cmd)
end

#start_node(name) ⇒ Object


10
11
12
13
14
# File 'server/lib/game_machine/console/test_cluster.rb', line 10

def start_node(name)
  node = Clients::TestClient.node_for(name)
  seed_node = Clients::TestClient.node_for(:seed)
  run_node(node,seed_node,name == 'seed')
end

#stop_node(name) ⇒ Object


32
33
34
35
# File 'server/lib/game_machine/console/test_cluster.rb', line 32

def stop_node(name)
  client = GameMachine::Clients::TestClient.new('test',name)
  client.kill_node
end