Class: QstatXmlRListener
- Inherits:
-
Object
- Object
- QstatXmlRListener
- Includes:
- REXML::StreamListener
- Defined in:
- lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb
Overview
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
Instance Attribute Summary collapse
-
#parsed_jobs ⇒ Object
readonly
[Array<Hash>].
Instance Method Summary collapse
- #add_child_tasks ⇒ Object
- #end_hard_req_queue ⇒ Object
- #end_hard_request ⇒ Object
- #end_JAT_start_time ⇒ Object
-
#end_JB_job_number ⇒ Object
Attributes we need.
- #end_JB_name ⇒ Object
- #end_JB_owner ⇒ Object
- #end_JB_project ⇒ Object
- #end_JB_submission_time ⇒ Object
-
#end_job_list ⇒ Object
Store a completed job and reset current_job for the next pass.
- #end_PN_path ⇒ Object
- #end_slots ⇒ Object
- #end_ST_name ⇒ Object
-
#end_state ⇒ Object
Note that this is the native SGE type.
-
#initialize ⇒ QstatXmlRListener
constructor
A new instance of QstatXmlRListener.
-
#start_hard_request(attributes) ⇒ Object
Handle hard_request tags.
- #tag_end(name) ⇒ Object
- #tag_start(name, attributes) ⇒ Object
-
#text(text) ⇒ Object
Always store text nodes temporarily.
Constructor Details
#initialize ⇒ QstatXmlRListener
Returns a new instance of QstatXmlRListener.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 22 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 |
Instance Attribute Details
#parsed_jobs ⇒ Object (readonly)
- Array<Hash>
18 19 20 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 18 def parsed_jobs @parsed_jobs end |
Instance Method Details
#add_child_tasks ⇒ Object
165 166 167 168 169 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 165 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_hard_req_queue ⇒ Object
126 127 128 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 126 def end_hard_req_queue @current_job[:queue_name] = @current_text end |
#end_hard_request ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 138 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_JAT_start_time ⇒ Object
134 135 136 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 134 def end_JAT_start_time @current_job[:dispatch_time] = DateTime.parse(@current_text).to_time.to_i end |
#end_JB_job_number ⇒ Object
Attributes we need
101 102 103 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 101 def end_JB_job_number @current_job[:id] = @current_text end |
#end_JB_name ⇒ Object
113 114 115 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 113 def end_JB_name @current_job[:job_name] = @current_text end |
#end_JB_owner ⇒ Object
105 106 107 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 105 def end_JB_owner @current_job[:job_owner] = @current_text end |
#end_JB_project ⇒ Object
109 110 111 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 109 def end_JB_project @current_job[:accounting_id] = @current_text end |
#end_JB_submission_time ⇒ Object
130 131 132 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 130 def end_JB_submission_time @current_job[:submission_time] = DateTime.parse(@current_text).to_time.to_i end |
#end_job_list ⇒ Object
Store a completed job and reset current_job for the next pass
157 158 159 160 161 162 163 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 157 def end_job_list @parsed_jobs << @current_job @current_job = { :tasks => [], :native => {} } end |
#end_PN_path ⇒ Object
147 148 149 150 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 147 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_slots ⇒ Object
122 123 124 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 122 def end_slots @current_job[:procs] = @current_text.to_i end |
#end_ST_name ⇒ Object
152 153 154 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 152 def end_ST_name @current_job[:native][:ST_name] = @current_job[:native][:ST_name] + @current_text + ' ' end |
#end_state ⇒ Object
Note that this is the native SGE type
118 119 120 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 118 def end_state @current_job[:status] = @current_text end |
#start_hard_request(attributes) ⇒ Object
Handle hard_request tags
Multiple hard_request tags may be present and will be differentiated using their name attribute
92 93 94 95 96 97 98 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 92 def start_hard_request(attributes) if attributes.key?('name') @current_request = attributes['name'] else @current_request = nil end end |
#tag_end(name) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 46 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) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 37 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) ⇒ Object
Always store text nodes temporarily
85 86 87 |
# File 'lib/ood_core/job/adapters/sge/qstat_xml_r_listener.rb', line 85 def text(text) @current_text = text end |