Class: Gorgon::HostState
- Inherits:
-
Object
- Object
- Gorgon::HostState
- Defined in:
- lib/gorgon/host_state.rb
Instance Method Summary collapse
- #each_running_file ⇒ Object
- #file_finished(worker_id, filename) ⇒ Object
- #file_started(worker_id, filename) ⇒ Object
-
#initialize ⇒ HostState
constructor
A new instance of HostState.
- #total_running_workers ⇒ Object
Constructor Details
#initialize ⇒ HostState
Returns a new instance of HostState.
3 4 5 |
# File 'lib/gorgon/host_state.rb', line 3 def initialize @running_workers = {} end |
Instance Method Details
#each_running_file ⇒ Object
27 28 29 30 31 |
# File 'lib/gorgon/host_state.rb', line 27 def each_running_file @running_workers.each_value do |filename| yield filename end end |
#file_finished(worker_id, filename) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/gorgon/host_state.rb', line 15 def file_finished worker_id, filename if !@running_workers.has_key? worker_id || @running_workers[:worker_id] != filename puts "WARNING: worker #{worker_id} finished running a file, but a 'start' message for that file was not received. File: #{filename}" end @running_workers.delete(worker_id) end |
#file_started(worker_id, filename) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/gorgon/host_state.rb', line 7 def file_started worker_id, filename if @running_workers.has_key? worker_id puts "WARNING: worker #{worker_id} started running a new file, but a 'finish' message has not been received for file #{@running_workers[:filename]}" end @running_workers[worker_id] = filename end |
#total_running_workers ⇒ Object
23 24 25 |
# File 'lib/gorgon/host_state.rb', line 23 def total_running_workers @running_workers.size end |