initial message passing structure for runner
This commit is contained in:
parent
a3057b88b5
commit
9916d7a6e5
|
@ -0,0 +1,54 @@
|
|||
# runners = []
|
||||
# cores.each do |c|
|
||||
# in = pipes[c][0]
|
||||
# out = pipes[c][1]
|
||||
# runners << TestRunner.new(in, out)
|
||||
# end
|
||||
#
|
||||
# files = [ ... ]
|
||||
# results = []
|
||||
#
|
||||
# runners.each do |r|
|
||||
# Thread.new do
|
||||
# while !files.empty?
|
||||
# results << r.run_file(files.pop)
|
||||
# end
|
||||
# r.shutdown
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# puts results.join("\n")
|
||||
#
|
||||
|
||||
|
||||
# Master
|
||||
# boot up workers
|
||||
# listen for worker messages
|
||||
# add worker messages to message queue
|
||||
# process message queue
|
||||
# "reply" to a message allows sending a message back down to worker
|
||||
#
|
||||
# When worker asks for file but no files left, send shutdown message to worker
|
||||
# when worker connection breaks, end thread
|
||||
# wait on all threads
|
||||
# when all threads are done, all workers must be done
|
||||
#
|
||||
#
|
||||
# Worker
|
||||
# boot up runners
|
||||
# listen for runner messages
|
||||
# add runner messages to message queue
|
||||
# process message queue
|
||||
# "reply" to a message allows sending message back down to runner
|
||||
#
|
||||
# when a runner asks for file but master responds with shutdown, mark self
|
||||
# as terminated, shut down runners. Any runner that asks for a file is
|
||||
# auto-terminated
|
||||
# wait for runner threads to finish
|
||||
# then exit, breaking master connection
|
||||
#
|
||||
# Runner
|
||||
# when booted, ask for a file
|
||||
# then process messages on the queue
|
||||
# when it's a file, run it and send a results message
|
||||
# when it's a shutdown, break main loop
|
|
@ -1,2 +1,5 @@
|
|||
require 'hydra/pipe'
|
||||
require 'hydra/ssh'
|
||||
require 'hydra/message'
|
||||
require 'hydra/runner'
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
module Hydra #:nodoc:
|
||||
class Message #:nodoc:
|
||||
def self.build(str)
|
||||
eval(str).new
|
||||
end
|
||||
end
|
||||
end
|
||||
require 'hydra/message/runner_requests_file'
|
|
@ -0,0 +1,9 @@
|
|||
module Hydra #:nodoc:
|
||||
module Messages #:nodoc:
|
||||
class RunnerRequestsFile < Hydra::Message
|
||||
def serialize
|
||||
"Hydra::Messages::RunnerRequestsFile"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
module Hydra #:nodoc:
|
||||
class Runner
|
||||
def initialize(io)
|
||||
@io = io
|
||||
@io.write Hydra::Messages::RunnerRequestsFile.new.serialize
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
require File.join(File.dirname(__FILE__), 'helper')
|
||||
|
||||
class TestRunner < Test::Unit::TestCase
|
||||
context "a test runner" do
|
||||
setup do
|
||||
@pipe = Hydra::Pipe.new
|
||||
Process.fork do
|
||||
@pipe.identify_as_child
|
||||
Hydra::Runner.new(@pipe)
|
||||
end
|
||||
@pipe.identify_as_parent
|
||||
end
|
||||
should "request a file on boot" do
|
||||
@message = Hydra::Message.build(@pipe.gets)
|
||||
assert @message.is_a?(Hydra::Messages::RunnerRequestsFile)
|
||||
end
|
||||
should "return a result message after processing a file"
|
||||
should "terminate when sent a shutdown message"
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue