Class: Pwrake::GfarmPostprocess

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

Instance Method Summary collapse

Constructor Details

#initializeGfarmPostprocess

Returns a new instance of GfarmPostprocess.



209
210
211
212
213
# File 'lib/pwrake/gfarm_feature.rb', line 209

def initialize
  @lock = Mutex.new
  @io = IO.popen('gfwhere-pipe','r+')
  @io.sync = true
end

Instance Method Details

#gfwhere(file) ⇒ Object



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/pwrake/gfarm_feature.rb', line 215

def gfwhere(file)
  return [] if file==''
  @lock.synchronize do
    @io.puts(file)
    @io.flush
    s = @io.gets
    if s.nil?
      raise "gfwhere: unexpected end"
    end
    s.chomp!
    if s != file
      raise "gfwhere: file=#{file}, result=#{s}"
    end
    while s = @io.gets
      s.chomp!
      case s
      when ""
        next
      when /^gfarm:\/\//
        next
      when /^Error:/
        return []
      else
        return s.split(/\s+/)
      end
    end
  end
end

#postprocess(t) ⇒ Object



244
245
246
247
248
# File 'lib/pwrake/gfarm_feature.rb', line 244

def postprocess(t)
  if t.kind_of? Rake::FileTask
    t.location = gfwhere(t.name)
  end
end

#postprocess_bulk(tasks) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/pwrake/gfarm_feature.rb', line 250

def postprocess_bulk(tasks)
  list = []
  tasks.each do |t|
   list << t.name if t.kind_of? Rake::FileTask
  end
  if !list.empty?
   Log.info "-- after_check: size=#{list.size} #{list.inspect}"
   gfwhere_result = GfarmPath.gfwhere(list)
   tasks.each do |t|
     if t.kind_of? Rake::FileTask
       t.location = gfwhere_result[GfarmPath.local_to_fs(t.name)]
     end
   end
   #puts "'#{self.name}' exist? => #{File.exist?(self.name)} loc => #{loc}"
  end
end