Module: Experiment::Distributed::Master
- Defined in:
- lib/experiment/distributed/master.rb
Overview
this module is included into base when running with –distributed
Instance Method Summary collapse
-
#distribution_done? ⇒ Boolean
returns true if all work has been disseminated.
-
#get_work ⇒ Hash, false
Send work from the master server.
-
#master_done! ⇒ Object
Cleans up the master server after all work is done.
-
#run!(cv) ⇒ Object
Strats up the master server.
-
#submit_result(cv, result, performance) ⇒ Object
Sends the result of the computation back to the master server.
Instance Method Details
#distribution_done? ⇒ Boolean
returns true if all work has been disseminated
22 23 24 |
# File 'lib/experiment/distributed/master.rb', line 22 def distribution_done? @started.all? end |
#get_work ⇒ Hash, false
Send work from the master server
12 13 14 15 16 17 18 19 |
# File 'lib/experiment/distributed/master.rb', line 12 def get_work() if cv = @started.index(false) @started[cv] = true {:cv => cv, :input => @data[cv], :dir => @dir, :options => Experiment::Config.to_hash, :cvs => cvs } else false end end |
#master_done! ⇒ Object
Cleans up the master server after all work is done
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/experiment/distributed/master.rb', line 49 def master_done! @done = true specification! true summarize_performance! summarize_results! @results cleanup! Notify.completed @experiment #sleep 1 #DRb.stop_service end |
#run!(cv) ⇒ Object
Strats up the master server
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/experiment/distributed/master.rb', line 37 def run!(cv) @cvs = cv || 1 @results = {} Notify.started @experiment split_up_data write_dir! @completed = (1..@cvs).map {|a| false } @started = @completed.dup end |
#submit_result(cv, result, performance) ⇒ Object
Sends the result of the computation back to the master server. Called on the master server object.
28 29 30 31 32 33 34 |
# File 'lib/experiment/distributed/master.rb', line 28 def submit_result(cv, result, performance) @completed[cv] = true array_merge(@results, result) @abm << performance Notify.cv_done @experiment, cv master_done! if @completed.all? end |