Class: Fairy::OutputFile

Inherits:
Filter
  • Object
show all
Defined in:
lib/fairy/client/output-file.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Filter

#backend, #backend=, #backend_class, #def_pool_variable

Constructor Details

#initialize(fairy, opts = nil) ⇒ OutputFile

Returns a new instance of OutputFile.



18
19
20
21
22
23
# File 'lib/fairy/client/output-file.rb', line 18

def initialize(fairy, opts=nil)
  super

  @old_vfile = nil
  @vfile = nil
end

Class Method Details

.output(fairy, opts, vfn) ⇒ Object



12
13
14
15
16
# File 'lib/fairy/client/output-file.rb', line 12

def OutputFile.output(fairy, opts, vfn)
  ffile = new(fairy, opts)
  ffile.output(vfn)
  ffile
end

Instance Method Details

#backend_class_nameObject



25
26
27
# File 'lib/fairy/client/output-file.rb', line 25

def backend_class_name
  "COutputFile"
end

#input=(job) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fairy/client/output-file.rb', line 42

def input=(job)
  @input = job
  backend.input=job.backend
  backend.wait_all_output_finished

  if @old_vfile
	rmfiles = @old_vfile.real_file_names.zip(@vfile.real_file_names).select{|n1, n2| n1 != n2}.map{|n1, n2| n1}
	if !rmfiles.empty?
	  rm = @fairy.exec(rmfiles).map(%{|uri|
         path = URI(uri).path
         begin
           File.unlink(path)
         rescue
         end
         }, :BEGIN => %{require "uri"})
	  rm.done
	end
  end
  @vfile.create_vfile
end

#output(vfn) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fairy/client/output-file.rb', line 29

def output(vfn)
  if File.exists?(vfn)
	@old_vfile = VFile.vfile(vfn)
  end

  @descripter = vfn
  @vfile = VFile.new
  @vfile.vfile_name = vfn
  backend.output(@vfile)

#      vf.create_vfile(vfn)
end