class DeepTest::Distributed::RemoteWorkerServer

Constants

MERCY_KILLING_GRACE_PERIOD

Public Class Methods

new(base_path, workers) click to toggle source
# File lib/deep_test/distributed/remote_worker_server.rb, line 8
def initialize(base_path, workers)
  @base_path = base_path
  @workers = workers
end
running_server_count() click to toggle source
# File lib/deep_test/distributed/remote_worker_server.rb, line 47
def self.running_server_count
  @warlock.demon_count if @warlock
end
start(address, base_path, workers, grace_period = MERCY_KILLING_GRACE_PERIOD) click to toggle source
# File lib/deep_test/distributed/remote_worker_server.rb, line 55
def self.start(address, base_path, workers, grace_period = MERCY_KILLING_GRACE_PERIOD)
  innie, outie = IO.pipe

  warlock.start("RemoteWorkerServer") do
    innie.close

    server = new(base_path, workers)

    DRb.start_service("drubyall://#{address}:0", server)
    DeepTest.logger.info "RemoteWorkerServer started at #{DRb.uri}"

    outie.write DRb.uri
    outie.close

    server.launch_mercy_killer(grace_period)

    DRb.thread.join
  end

  outie.close
  uri = innie.gets
  innie.close
  DRbObject.new_with_uri(uri)
end
stop_all() click to toggle source
# File lib/deep_test/distributed/remote_worker_server.rb, line 51
def self.stop_all
  @warlock.stop_all if @warlock
end
warlock() click to toggle source
# File lib/deep_test/distributed/remote_worker_server.rb, line 43
def self.warlock
  @warlock ||= DeepTest::Warlock.new
end

Public Instance Methods

launch_mercy_killer(grace_period) click to toggle source
# File lib/deep_test/distributed/remote_worker_server.rb, line 13
def launch_mercy_killer(grace_period)
  Thread.new do
    sleep grace_period
    exit(0) unless workers_started?
  end
end
load_files(files) click to toggle source
# File lib/deep_test/distributed/remote_worker_server.rb, line 20
def load_files(files)
  Dir.chdir @base_path
  resolver = FilenameResolver.new(@base_path)
  files.each do |file|
    load resolver.resolve(file)
  end
end
start_all() click to toggle source
# File lib/deep_test/distributed/remote_worker_server.rb, line 28
def start_all
  @workers_started = true
  @workers.start_all
end
stop_all() click to toggle source
# File lib/deep_test/distributed/remote_worker_server.rb, line 33
def stop_all
  Thread.new do
    @workers.stop_all
  end
end
workers_started?() click to toggle source
# File lib/deep_test/distributed/remote_worker_server.rb, line 39
def workers_started?
  @workers_started
end