class Torque::JobLog
Represents a job record file
Attributes
filename[R]
The name of the accounting file opened
Public Class Methods
filename_for_date(date)
click to toggle source
Converts a date to the name of the file holding entries for that date
# File lib/bookie/senders/torque_cluster.rb, line 149 def self.filename_for_date(date) File.join(Torque::torque_root, 'server_priv', 'accounting', date.strftime("%Y%m%d")) end
new(filename)
click to toggle source
Creates a JobRecord using the TORQUE record file for the given date
# File lib/bookie/senders/torque_cluster.rb, line 62 def initialize(filename) @filename = filename @file = File.open(filename) end
Public Instance Methods
each_job() { |job| ... }
click to toggle source
Yields each completed job to the given block
# File lib/bookie/senders/torque_cluster.rb, line 77 def each_job @file.rewind line_num = 0 @file.each_line do |line| line_num += 1 next if line.strip! == '' #Skip the timestamp. index = line.index(';') raise invalid_line_error(line_num) unless index #Find the event type. event_type = line[index + 1] old_index = index index = line.index(';', index + 1) raise invalid_line_error(line_num) unless index == old_index + 2 next unless event_type == ?E #Find the fields. index = line.index(';', index + 1) raise invalid_line_error(line_num) unless index fields = line[index + 1 .. -1].split(' ') job = Job.new() #To consider: make sure all fields are present? fields.each do |field| key, value = *field.split('=') case key when "user" job.user_name = value when "group" job.group_name = value when "start" job.start_time = Time.at(Integer(value)) when "resources_used.walltime" job.wall_time = parse_duration(value) when "resources_used.cput" job.cpu_time = parse_duration(value) when "resources_used.mem" job.physical_memory = Integer(value[0 ... -2]) when "resources_used.vmem" job.virtual_memory = Integer(value[0 ... -2]) when "Exit_status" job.exit_code = Integer(value) end end job.command_name = "" yield job end end
Protected Instance Methods
invalid_line_error(line_num)
click to toggle source
Creates an InvalidLineError
associated with this object’s file
# File lib/bookie/senders/torque_cluster.rb, line 131 def invalid_line_error(line_num) InvalidLineError.new(@filename, line_num) end
parse_duration(str)
click to toggle source
Parses a duration in HH:MM:SS format, returning seconds
# File lib/bookie/senders/torque_cluster.rb, line 141 def parse_duration(str) hours, minutes, seconds = *str.split(':').map!{ |s| Integer(s) } return hours * 3600 + minutes * 60 + seconds end