Class: OodCore::Job::Adapters::Fujitsu_TCS
- Inherits:
-
OodCore::Job::Adapter
- Object
- OodCore::Job::Adapter
- OodCore::Job::Adapters::Fujitsu_TCS
- Defined in:
- lib/ood_core/job/adapters/fujitsu_tcs.rb
Overview
An adapter object that describes the communication with a Fujitsu TCS resource manager for job management.
Defined Under Namespace
Classes: Batch
Constant Summary collapse
- STATE_MAP =
Mapping of state codes for Fujitsu TCS resource manager
{ 'ACC' => :queued, # Accepted job submission 'RJT' => :completed, # Rejected job submission 'QUE' => :queued, # Waiting for job execution 'RNA' => :queued, # Acquiring resources required for job execution 'RNP' => :running, # Executing prologue 'RUN' => :running, # Executing job 'RNE' => :running, # Executing epilogue 'RNO' => :running, # Waiting for completion of job termination processing 'SPP' => :suspended, # Suspend in progress 'SPD' => :suspended, # Suspended 'RSM' => :running, # Resume in progress 'EXT' => :completed, # Exited job end execution 'CCL' => :completed, # Exited job execution by interruption 'HLD' => :suspended, # In fixed state due to users 'ERR' => :completed, # In fixed state due to an error }
Instance Method Summary collapse
-
#delete(id) ⇒ void
Delete the submitted job.
- #directive_prefix ⇒ Object
-
#hold(id) ⇒ void
Put the submitted job on hold.
-
#info(id) ⇒ Info
Retrieve job info from the resource manager.
-
#info_all(attrs: nil) ⇒ Array<Info>
Retrieve info for all jobs from the resource manager.
-
#info_where_owner(owner, attrs: nil) ⇒ Array<Info>
Retrieve info for all jobs for a given owner or owners from the resource manager.
-
#initialize(opts = {}) ⇒ Fujitsu_TCS
constructor
private
A new instance of Fujitsu_TCS.
-
#release(id) ⇒ void
Release the job that is on hold.
-
#status(id) ⇒ Status
Retrieve job status from resource manager.
-
#submit(script, after: [], afterok: [], afternotok: [], afterany: []) ⇒ String
Submit a job with the attributes defined in the job template instance.
Methods inherited from OodCore::Job::Adapter
#accounts, #cluster_info, #info_all_each, #info_where_owner_each, #job_name_illegal_chars, #queues, #sanitize_job_name, #supports_job_arrays?
Constructor Details
#initialize(opts = {}) ⇒ Fujitsu_TCS
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Fujitsu_TCS.
175 176 177 178 179 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 175 def initialize(opts = {}) o = opts.to_h.symbolize_keys @fujitsu_tcs = o.fetch(:fujitsu_tcs) { raise ArgumentError, "No Fujitsu TCS object specified. Missing argument: fujitsu_tcs" } end |
Instance Method Details
#delete(id) ⇒ void
This method returns an undefined value.
Delete the submitted job
357 358 359 360 361 362 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 357 def delete(id) @fujitsu_tcs.delete_job(id.to_s) rescue Batch::Error => e # assume successful job deletion if can't find job id raise JobAdapterError, e. unless /\[ERR\.\] PJM .+ Job .+ does not exist/ =~ e. end |
#directive_prefix ⇒ Object
364 365 366 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 364 def directive_prefix '#PJM' end |
#hold(id) ⇒ void
This method returns an undefined value.
Put the submitted job on hold
333 334 335 336 337 338 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 333 def hold(id) @fujitsu_tcs.hold_job(id.to_s) rescue Batch::Error => e # assume successful job hold if can't find job id raise JobAdapterError, e. unless /\[ERR\.\] PJM .+ Job .+ does not exist/ =~ e. end |
#info(id) ⇒ Info
Retrieve job info from the resource manager
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 270 def info(id) id = id.to_s info_ary = @fujitsu_tcs.get_jobs(id: id).map do |v| parse_job_info(v) end # If no job was found we assume that it has completed info_ary.empty? ? Info.new(id: id, status: :completed) : info_ary.first # @fujitsu_tcs.get_jobs() must return only one element. rescue Batch::Error => e # set completed status if can't find job id if /\[ERR\.\] PJM .+ Job .+ does not exist/ =~ e. Info.new( id: id, status: :completed ) else raise JobAdapterError, e. end end |
#info_all(attrs: nil) ⇒ Array<Info>
Retrieve info for all jobs from the resource manager
257 258 259 260 261 262 263 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 257 def info_all(attrs: nil) @fujitsu_tcs.get_jobs().map do |v| parse_job_info(v) end rescue Batch::Error => e raise JobAdapterError, e. end |
#info_where_owner(owner, attrs: nil) ⇒ Array<Info>
Retrieve info for all jobs for a given owner or owners from the resource manager
295 296 297 298 299 300 301 302 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 295 def info_where_owner(owner, attrs: nil) owner = Array.wrap(owner).map(&:to_s).join('+') @fujitsu_tcs.get_jobs(owner: owner).map do |v| parse_job_info(v) end rescue Batch::Error => e raise JobAdapterError, e. end |
#release(id) ⇒ void
This method returns an undefined value.
Release the job that is on hold
345 346 347 348 349 350 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 345 def release(id) @fujitsu_tcs.release_job(id.to_s) rescue Batch::Error => e # assume successful job release if can't find job id raise JobAdapterError, e. unless /\[ERR\.\] PJM .+ Job .+ does not exist/ =~ e. end |
#status(id) ⇒ Status
Retrieve job status from resource manager
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 309 def status(id) id = id.to_s jobs = @fujitsu_tcs.get_jobs(id: id) if job = jobs.detect { |j| j[:JOB_ID] == id } Status.new(state: get_state(job[:ST])) else # set completed status if can't find job id Status.new(state: :completed) end rescue Batch::Error => e # set completed status if can't find job id if /\[ERR\.\] PJM .+ Job .+ does not exist/ =~ e. Status.new(state: :completed) else raise JobAdapterError, e. end end |
#submit(script, after: [], afterok: [], afternotok: [], afterany: []) ⇒ String
Submit a job with the attributes defined in the job template instance
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 196 def submit(script, after: [], afterok: [], afternotok: [], afterany: []) #after = Array(after).map(&:to_s) #afterok = Array(afterok).map(&:to_s) #afternotok = Array(afternotok).map(&:to_s) #afterany = Array(afterany).map(&:to_s) if !after.empty? || !afterok.empty? || !afternotok.empty? || !afterany.empty? raise JobAdapterError, "Dependency between jobs has not implemented yet." end # Set pjsub options args = [] args.concat (script.rerunnable ? ["--restart"] : ["--norestart"]) unless script.rerunnable.nil? args.concat ["--mail-list", script.email.join(",")] unless script.email.nil? if script.email_on_started && script.email_on_terminated args.concat ["-m", "b,e"] elsif script.email_on_started args.concat ["-m", "b"] elsif script.email_on_terminated args.concat ["-m", "e"] end args.concat ["-N", script.job_name] unless script.job_name.nil? args.concat ["-o", script.output_path] unless script.output_path.nil? if script.error_path.nil? args.concat ["-j"] else args.concat ["-e", script.error_path] end args.concat ["-L rscgrp=" + script.queue_name] unless script.queue_name.nil? args.concat ["-p", script.priority] unless script.priority.nil? # start_time: <%= Time.local(2023,11,22,13,4).to_i %> in form.yml.erb args.concat ["--at", script.start_time.localtime.strftime("%C%y%m%d%H%M")] unless script.start_time.nil? args.concat ["-L elapse=" + seconds_to_duration(script.wall_time)] unless script.wall_time.nil? args.concat ["--bulk", "--sparam", script.job_array_request] unless script.job_array_request.nil? # Set environment variables envvars = script.job_environment.to_h args.concat ["-x", envvars.map{|k,v| "#{k}=#{v}"}.join(",")] unless envvars.empty? args.concat ["-X"] if script.copy_environment? # Set native options args.concat script.native if script.native # Set content content = if script.shell_path.nil? script.content else "#!#{script.shell_path}\n#{script.content}" end # Submit job @fujitsu_tcs.submit_string(content, args: args) rescue Batch::Error => e raise JobAdapterError, e. end |