Class: DeepTest::Distributed::RemoteWorkerClient

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_test/distributed/remote_worker_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, test_server, failover_workers) ⇒ RemoteWorkerClient

Returns a new instance of RemoteWorkerClient.



4
5
6
7
8
# File 'lib/deep_test/distributed/remote_worker_client.rb', line 4

def initialize(options, test_server, failover_workers)
  @failover_workers = failover_workers
  @options = options
  @test_server = test_server
end

Instance Method Details

#fail_over(method, exception) ⇒ Object



56
57
58
59
# File 'lib/deep_test/distributed/remote_worker_client.rb', line 56

def fail_over(method, exception)
  @options.ui_instance.distributed_failover_to_local(method, exception)
  @worker_server = @failover_workers
end

#failed_over?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/deep_test/distributed/remote_worker_client.rb', line 61

def failed_over?
  @worker_server == @failover_workers
end

#load_files(filelist) ⇒ Object



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
# File 'lib/deep_test/distributed/remote_worker_client.rb', line 10

def load_files(filelist)
  @options.new_listener_list.before_sync

  t = Thread.new do
    @test_server.sync(@options)
    @worker_server = @test_server.spawn_worker_server(@options)
    
    @worker_server.slaves.each do |s|
      DeepTest.logger.debug "Startng the DRb service to connect to: #{s.inspect}"
      DRb.start_service(s.__drburi, nil, DRbFire::ROLE => DRbFire::CLIENT)
    end
    
    @worker_server.load_files filelist
  end

  filelist.each {|f| load f}

  begin
    t.join
  rescue => e
    # The failover here doesn't invoke load_files on the failover_workers
    # because they will be LocalWorkers, which fork from the current 
    # process.  The fact that we depend in this here is damp...
    #
    fail_over("load_files", e)
  end
end

#start_all(drbserver) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/deep_test/distributed/remote_worker_client.rb', line 38

def start_all(drbserver)
  
  @worker_server.slaves.each do |s|
    DeepTest.logger.debug "Remote worker client start_all sending Server reference to RemoteWorkerServer: #{s.inspect}"
    s.drbserver = drbserver
  end
  
  @worker_server.start_all
rescue => e
  raise if failed_over?
  fail_over("start_all", e)
  retry
end

#stop_allObject



52
53
54
# File 'lib/deep_test/distributed/remote_worker_client.rb', line 52

def stop_all
  @worker_server.stop_all
end