Class: Pwrake::GfarmPostprocess

Inherits:
Object
  • Object
show all
Defined in:
lib/pwrake/gfarm/gfarm_postprocess.rb

Instance Method Summary collapse

Constructor Details

#initialize(selector) ⇒ GfarmPostprocess

Returns a new instance of GfarmPostprocess.



7
8
9
10
11
12
# File 'lib/pwrake/gfarm/gfarm_postprocess.rb', line 7

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

#closeObject



50
51
52
53
54
# File 'lib/pwrake/gfarm/gfarm_postprocess.rb', line 50

def close
  @writer.halt
  @reader.halt
  @io.close
end

#run(task_wrap) ⇒ Object



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
47
48
# File 'lib/pwrake/gfarm/gfarm_postprocess.rb', line 14

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 GfwhereError,"lost connection to gfwhere-pipe"
  end
  s.chomp!
  if s != filename
    raise GfwhereError,"path mismatch: send=#{filename}, return=#{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