Class: SGE::QAcct::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/sge/qacct/job.rb

Overview

This class is used for loading jobs from a YAML file generated by transform_qacct_to_yaml

Constant Summary collapse

FIELDS =
[:qname, :hostname, :group, :owner, :project, :department, :jobname, :jobnumber, :taskid, :account, :priority, :qsub_time, :start_time, :end_time, :granted_pe, :slots, :failed, :exit_status, :ru_wallclock, :ru_utime, :ru_stime, :ru_maxrss, :ru_ixrss, :ru_ismrss, :ru_idrss, :ru_isrss, :ru_minflt, :ru_majflt, :ru_nswap, :ru_inblock, :ru_oublock, :ru_msgsnd, :ru_msgrcv, :ru_nsignals, :ru_nvcsw, :ru_nivcsw, :cpu, :mem, :io, :iow, :maxvmem, :arid]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Job

Returns a new instance of Job.



9
10
11
12
13
# File 'lib/sge/qacct/job.rb', line 9

def initialize(opts = {})
  FIELDS.each do |a|
    instance_variable_set("#{a}", opts[a]) if opts.key?(a)
  end
end

Class Method Details

.command(opts) ⇒ Object



44
45
46
47
# File 'lib/sge/qacct/job.rb', line 44

def self.command(opts)
 return opts[:cmd] if opts[:cmd]
 raise "Not Implemented Yet"
end

.load_documents(opts) ⇒ Object



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
# File 'lib/sge/qacct/job.rb', line 15

def self.load_documents(opts)
  documents = []
  transformer = SGE::QAcct::Transformer.new

  # Compute command
  cmd = command(opts)

  # Make a fifo to dump
  fifo = opts[:file] || SGE::Utils.mkfifo(opts[:tmp_dir])

  # Add transformer to yaml command
  cmd = transformer.command(opts.merge(:cmd => cmd, :file => fifo))

  # Execute this command
  SGE::Utils.execute(cmd)

  # Load documents
  if block_given?
    transformer.load_from_yaml_file(fifo, opts[:remove_tmp_file]) do |doc|
      documents << yield(doc)
    end
  else
    transformer.load_from_yaml_file(fifo, opts[:remove_tmp_file]) do |doc|
      documents << doc
    end
  end
  documents
end