class QstatXmlRListener
An XML stream listener to build an array of OodCore::Job::Info
from qstat output
Handles parsing `qstat -xml -r` which provides: :accounting_id :id :job_name :job_owner :procs :queue_name :status :wallclock_limit
Attributes
parsed_jobs[R]
- Array<Hash>
Public Class Methods
new()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 23 def initialize @parsed_jobs = [] @current_job = { :tasks => [], :native => { :ST_name => '' } } @current_text = nil @processing_JB_stdout_path_list = false @current_request = nil @native_tags = ['JB_job_number', 'JB_job_name', 'JB_version', 'JB_project', 'JB_exec_file', 'JB_script_file', 'JB_script_size', 'JB_submission_time', 'JB_execution_time', 'JB_deadline', 'JB_owner', 'JB_uid', 'JB_group', 'JB_gid', 'JB_account', 'JB_cwd', 'JB_notify', 'JB_type', 'JB_reserve', 'JB_priority', 'JB_jobshare', 'JB_verify', 'JB_checkpoint_attr', 'JB_checkpoint_interval', 'JB_restart'] end
Public Instance Methods
add_child_tasks()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 166 def add_child_tasks @current_job[:tasks] = OodCore::Job::ArrayIds.new(@current_text).ids.sort.map{ |task_id| { :id => task_id, :status => :queued } } end
end_JAT_start_time()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 135 def end_JAT_start_time @current_job[:dispatch_time] = DateTime.parse(@current_text).to_time.to_i end
end_JB_job_number()
click to toggle source
Attributes we need
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 102 def end_JB_job_number @current_job[:id] = @current_text end
end_JB_name()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 114 def end_JB_name @current_job[:job_name] = @current_text end
end_JB_owner()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 106 def end_JB_owner @current_job[:job_owner] = @current_text end
end_JB_project()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 110 def end_JB_project @current_job[:accounting_id] = @current_text end
end_JB_submission_time()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 131 def end_JB_submission_time @current_job[:submission_time] = DateTime.parse(@current_text).to_time.to_i end
end_PN_path()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 148 def end_PN_path @current_job[:native][:PN_path] = @current_text if @processing_JB_stdout_path_list @processing_JB_stdout_path_list = false end
end_ST_name()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 153 def end_ST_name @current_job[:native][:ST_name] = @current_job[:native][:ST_name] + @current_text + ' ' end
end_hard_req_queue()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 127 def end_hard_req_queue @current_job[:queue_name] = @current_text end
end_hard_request()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 139 def end_hard_request return nil if @current_request.nil? case @current_request when 'h_rt' # hard run time limit @current_job[:wallclock_limit] = @current_text.to_i end end
end_job_list()
click to toggle source
Store a completed job and reset current_job for the next pass
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 158 def end_job_list @parsed_jobs << @current_job @current_job = { :tasks => [], :native => {} } end
end_slots()
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 123 def end_slots @current_job[:procs] = @current_text.to_i end
end_state()
click to toggle source
Note that this is the native SGE type
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 119 def end_state @current_job[:status] = @current_text end
start_hard_request(attributes)
click to toggle source
Handle hard_request tags
Multiple hard_request tags may be present and will be differentiated using their name attribute
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 93 def start_hard_request(attributes) if attributes.key?('name') @current_request = attributes['name'] else @current_request = nil end end
tag_end(name)
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 47 def tag_end(name) #Add text if in native_tags if (@native_tags.include?(name)) @current_job[:native][:"#{name}"] = @current_text end case name when 'job_list' end_job_list when 'JB_job_number' end_JB_job_number when 'JB_name' end_JB_name when 'JB_owner' end_JB_owner when 'JB_project' end_JB_project when 'state' end_state when 'slots' end_slots when 'JB_submission_time' end_JB_submission_time when 'hard_req_queue' end_hard_req_queue when 'JAT_start_time' end_JAT_start_time when 'hard_request' end_hard_request when 'tasks' add_child_tasks when 'PN_path' end_PN_path when 'ST_name' end_ST_name end end
tag_start(name, attributes)
click to toggle source
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 38 def tag_start(name, attributes) case name when 'hard_request' start_hard_request(attributes) when "JB_stdout_path_list" @processing_JB_stdout_path_list = true end end
text(text)
click to toggle source
Always store text nodes temporarily
# File lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb, line 86 def text(text) @current_text = text end