Class: Pwrake::GfarmPostprocess
- Inherits:
-
Object
- Object
- Pwrake::GfarmPostprocess
- Defined in:
- lib/pwrake/gfarm/gfarm_postprocess.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(selector) ⇒ GfarmPostprocess
constructor
A new instance of GfarmPostprocess.
- #run(task_wrap) ⇒ Object
Constructor Details
#initialize(selector) ⇒ GfarmPostprocess
Returns a new instance of GfarmPostprocess.
5 6 7 8 9 10 |
# File 'lib/pwrake/gfarm/gfarm_postprocess.rb', line 5 def initialize(selector) @io = IO.popen('gfwhere-pipe','r+') @io.sync = true @reader = NBIO::Reader.new(selector,@io) @writer = NBIO::Writer.new(selector,@io) end |
Instance Method Details
#close ⇒ Object
48 49 50 51 52 |
# File 'lib/pwrake/gfarm/gfarm_postprocess.rb', line 48 def close @writer.halt @reader.halt @io.close end |
#run(task_wrap) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pwrake/gfarm/gfarm_postprocess.rb', line 12 def run(task_wrap) if !task_wrap.is_file_task? return [] end filename = task_wrap.name begin @writer.put_line(filename) rescue Errno::EPIPE Log.warn "GfarmPostprocess#run: Errno::EPIPE for #{filename}" return [] end s = @reader.get_line if s.nil? raise "gfwhere: unexpected end" end s.chomp! if s != filename raise "gfwhere: file=#{filename}, result=#{s}" end while s = @reader.get_line s.chomp! case s when /^gfarm:\/\// next when /^Error:/ a = [] break else a = s.split(/\s+/) break end end Log.debug "Gfarm file=#{filename} nodes=#{a.join("|")}" a end |