Sha256: 38edaa04f33b75a2838fbcecff768f1a22fc132dee2a9678f69e7b2de57a3cc6

Contents?: true

Size: 854 Bytes

Versions: 46

Compression:

Stored size: 854 Bytes

Contents

class HostState
  def initialize
    @running_workers = {}
  end

  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

  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

  def total_running_workers
    @running_workers.size
  end

  def each_running_file
    @running_workers.each_value do |filename|
      yield filename
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
gorgon-0.6.4 lib/gorgon/host_state.rb
gorgon-0.6.3 lib/gorgon/host_state.rb
gorgon-0.6.2 lib/gorgon/host_state.rb
gorgon-0.6.1 lib/gorgon/host_state.rb
gorgon-0.6.0 lib/gorgon/host_state.rb
gorgon-0.6.0.rc2 lib/gorgon/host_state.rb
gorgon-0.6.0.rc1 lib/gorgon/host_state.rb
gorgon-0.5.0.rc1 lib/gorgon/host_state.rb
gorgon-0.4.5 lib/gorgon/host_state.rb
gorgon-0.4.5.rc1 lib/gorgon/host_state.rb
gorgon-0.4.4 lib/gorgon/host_state.rb
gorgon-0.4.3 lib/gorgon/host_state.rb
gorgon-0.4.2 lib/gorgon/host_state.rb
gorgon-0.4.1 lib/gorgon/host_state.rb
gorgon-0.4.1.rc1 lib/gorgon/host_state.rb
gorgon-0.4.0 lib/gorgon/host_state.rb
gorgon-0.4.0.rc2 lib/gorgon/host_state.rb
gorgon-0.4.0.rc1 lib/gorgon/host_state.rb
gorgon-0.3.2 lib/gorgon/host_state.rb
gorgon-0.3.1 lib/gorgon/host_state.rb