Class: OodCore::Job::Adapters::LinuxHost
- Inherits:
-
OodCore::Job::Adapter
- Object
- OodCore::Job::Adapter
- OodCore::Job::Adapters::LinuxHost
- Defined in:
- lib/ood_core/job/adapters/linux_host.rb
Overview
An adapter object that describes the communication with a remote host for job management.
Defined Under Namespace
Classes: Launcher
Instance Method Summary collapse
-
#delete(id) ⇒ void
abstract
Delete the submitted job.
- #directive_prefix ⇒ Object
-
#hold(id) ⇒ void
abstract
Put the submitted job on hold.
-
#info(id) ⇒ Info
Retrieve job info from the SSH host.
-
#info_all(attrs: nil, host: nil) ⇒ Array<Info>
Retrieve info for all jobs from the resource manager.
-
#info_all_each(attrs: nil) {|Info| ... } ⇒ Enumerator
Iterate over each job Info object.
-
#info_where_owner(_, attrs: nil) ⇒ Array<Info>
Retrieve info for all jobs for a given owner or owners from the resource manager Note: owner and attrs are present only to complete the interface and are ignored Note: since this API is used in production no errors or warnings are thrown / issued.
-
#info_where_owner_each(owner, attrs: nil) {|Info| ... } ⇒ Enumerator
Iterate over each job Info object.
-
#initialize(ssh_hosts:, launcher:) ⇒ LinuxHost
constructor
A new instance of LinuxHost.
-
#release(id) ⇒ void
abstract
Release the job that is on hold.
-
#status(id) ⇒ Status
abstract
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.
-
#supports_job_arrays? ⇒ Boolean
Whether the adapter supports job arrays.
Methods inherited from OodCore::Job::Adapter
#accounts, #cluster_info, #info_historic, #job_name_illegal_chars, #nodes, #queues, #sanitize_job_name, #supports_job_dependencies?
Constructor Details
#initialize(ssh_hosts:, launcher:) ⇒ LinuxHost
Returns a new instance of LinuxHost.
62 63 64 65 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 62 def initialize(ssh_hosts:, launcher:) @launcher = launcher @ssh_hosts = Set.new(ssh_hosts) end |
Instance Method Details
#delete(id) ⇒ void
Subclass is expected to implement #delete
This method returns an undefined value.
Delete the submitted job
198 199 200 201 202 203 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 198 def delete(id) session_name, destination_host = parse_job_id(id) @launcher.stop_remote_session(session_name, destination_host) rescue Launcher::Error => e raise JobAdapterError, e. end |
#directive_prefix ⇒ Object
205 206 207 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 205 def directive_prefix nil end |
#hold(id) ⇒ void
Subclass is expected to implement #hold
This method returns an undefined value.
Put the submitted job on hold
178 179 180 181 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 178 def hold(id) # Consider sending SIGSTOP? raise NotImplementedError, "subclass did not define #hold" end |
#info(id) ⇒ Info
Retrieve job info from the SSH host
150 151 152 153 154 155 156 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 150 def info(id) _, host = parse_job_id(id) job = info_all(host: host).select{|info| info.id == id}.first (job) ? job : Info.new(id: id, status: :completed) rescue Launcher::Error => e raise JobAdapterError, e. end |
#info_all(attrs: nil, host: nil) ⇒ Array<Info>
Retrieve info for all jobs from the resource manager
93 94 95 96 97 98 99 100 101 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 93 def info_all(attrs: nil, host: nil) host_permitted?(host) if host @launcher.list_remote_sessions(host: host).map{ |ls_output| ls_to_info(ls_output) } rescue Launcher::Error => e raise JobAdapterError, e. end |
#info_all_each(attrs: nil) {|Info| ... } ⇒ Enumerator
Iterate over each job Info object
118 119 120 121 122 123 124 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 118 def info_all_each(attrs: nil) return to_enum(:info_all_each, attrs: attrs) unless block_given? info_all(attrs: attrs).each do |job| yield job end end |
#info_where_owner(_, attrs: nil) ⇒ Array<Info>
Retrieve info for all jobs for a given owner or owners from the resource manager Note: owner and attrs are present only to complete the interface and are ignored Note: since this API is used in production no errors or warnings are thrown / issued
110 111 112 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 110 def info_where_owner(_, attrs: nil) info_all end |
#info_where_owner_each(owner, attrs: nil) {|Info| ... } ⇒ Enumerator
Iterate over each job Info object
131 132 133 134 135 136 137 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 131 def info_where_owner_each(owner, attrs: nil) return to_enum(:info_where_owner_each, owner, attrs: attrs) unless block_given? info_where_owner(owner, attrs: attrs).each do |job| yield job end end |
#release(id) ⇒ void
Subclass is expected to implement #release
This method returns an undefined value.
Release the job that is on hold
188 189 190 191 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 188 def release(id) # Consider sending SIGCONT raise NotImplementedError, "subclass did not define #release" end |
#status(id) ⇒ Status
Subclass is expected to implement #status
Optimized slightly over retrieving complete job information from server
Retrieve job status from resource manager
164 165 166 167 168 169 170 171 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 164 def status(id) _, host = parse_job_id(id) job = info_all(host: host).select{|info| info.id == id}.first Status.new(state: (job) ? :running : :completed) rescue Launcher::Error => e raise JobAdapterError, e. end |
#submit(script, after: [], afterok: [], afternotok: [], afterany: []) ⇒ String
Submit a job with the attributes defined in the job template instance
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 78 def submit(script, after: [], afterok: [], afternotok: [], afterany: []) validate_native(script, Hash) unless (after.empty? && afterok.empty? && afternotok.empty? && afterany.empty?) raise JobAdapterError, 'Scheduling subsequent jobs is not available.' end @launcher.start_remote_session(script) rescue Launcher::Error => e raise JobAdapterError, e. end |
#supports_job_arrays? ⇒ Boolean
Whether the adapter supports job arrays
141 142 143 |
# File 'lib/ood_core/job/adapters/linux_host.rb', line 141 def supports_job_arrays? false end |