Class: Rub2::JobResultCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/rub2.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, timeout, job_count) ⇒ JobResultCollector

Returns a new instance of JobResultCollector.



277
278
279
280
281
282
283
# File 'lib/rub2.rb', line 277

def initialize(uri, timeout, job_count)
  @drb = DRbObject.new_with_uri(uri)
  @pid = Process.pid
  @timeout = timeout
  @job_count = job_count
  @success_count = 0
end

Instance Method Details

#collect_job_result(job_store) ⇒ Object

block thread



286
287
288
289
290
291
292
293
# File 'lib/rub2.rb', line 286

def collect_job_result(job_store)
  _pid, job_id, array_id, host, exit_code, start_time, exit_time = @drb.take([@pid, nil, nil, nil, nil, nil, nil], @timeout)
  job_store.update_exit_code([{:array_id => array_id, :exit_code => exit_code}])
  @success_count += 1 if exit_code == 0
  t = Time.at(exit_time) - Time.at(start_time)
  min, sec = t.divmod(60)
  Rub2.putlog "#{job_id}(#{host}) => #{exit_code}\t[#{min}m#{sec.truncate}s]\t(#{@success_count}/#{@job_count})"
end