Class: OodCore::Job::Adapters::Fujitsu_TCS::Batch Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ood_core/job/adapters/fujitsu_tcs.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Object used for simplified communication with a Fujitsu TCS batch server

Defined Under Namespace

Classes: Error, Fujitsu_TCS_TimeoutError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bin: nil, bin_overrides: {}, working_dir: nil) ⇒ Batch

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 Batch.

Parameters:

  • bin (#to_s) (defaults to: nil)

    path to Fujitsu TCS installation binaries

  • bin_overrides (#to_h) (defaults to: {})

    a hash of bin ovverides to be used in job

  • working_dir (defaults to: nil)

    Working directory for submitting a batch script



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 63

def initialize(bin: nil, bin_overrides: {}, working_dir: nil)
  @bin           = Pathname.new(bin.to_s)
  @bin_overrides = bin_overrides
  if working_dir == nil
    @working_dir = Dir.pwd
  elsif working_dir == "HOME"
    @working_dir   = Dir.home
  else
    raise(StandardError, "Unknown working_dir")
  end
end

Instance Attribute Details

#binPathname (readonly)

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.

The path to the Fujitsu TCS binaries

Examples:

my_batch.bin.to_s #=> "/usr/local/fujitsu_tcs/10.0.0/bin"

Returns:

  • (Pathname)

    path to Fujitsu TCS binaries



40
41
42
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 40

def bin
  @bin
end

#bin_overridesObject (readonly)

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.

Optional overrides for Fujitsu TCS executables

Examples:

{'pjsub' => '/usr/local/bin/pjsub'}


46
47
48
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 46

def bin_overrides
  @bin_overrides
end

#working_dirObject (readonly)

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.

Working directory for submitting a batch script

Examples:

my_batch.working_dir #=> "HOME" or Dir.pwd


51
52
53
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 51

def working_dir
  @working_dir
end

Instance Method Details

#delete_job(id) ⇒ void

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.

This method returns an undefined value.

Delete a specified job from batch server

Examples:

Delete job “1234”

my_batch.delete_job("1234")

Parameters:

  • id (#to_s)

    the id of the job

Raises:

  • (Error)

    if ‘pjdel` command exited unsuccessfully



143
144
145
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 143

def delete_job(id)
  call("pjdel", id.to_s)
end

#get_jobs(id: "", owner: nil) ⇒ Array<Hash>

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.

Get a list of hashes detailing each of the jobs on the batch server

Examples:

Status info for all jobs

my_batch.get_jobs
#=>
#[
#  {
#    :JOB_ID => "123",
#    :JOB_NAME => "my_job",
#    ...
#  },
#  {
#    :JOB_ID => "125",
#    :JOB_NAME => "my_other_job",
#    ...
#  },
#  ...
#]

Parameters:

  • id (#to_s) (defaults to: "")

    the id of the job

  • owner (String) (defaults to: nil)

    the owner(s) of the job

Returns:

  • (Array<Hash>)

    list of details for jobs

Raises:

  • (Error)

    if ‘pjstat` command exited unsuccessfully



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 96

def get_jobs(id: "", owner: nil)
  args = ["-A", "-s", "--data", "--choose=jid,jnam,rscg,st,std,stde,adt,sdt,nnumr,usr,elpl,elp"]
  args.concat ["--filter", "jid=" + id.to_s] unless id.to_s.empty?
  args.concat ["--filter", "usr=" + owner.to_s] unless owner.to_s.empty?
  
  StringIO.open(call("pjstat", *args)) do |output|
    output.gets() # Skip header
    jobs = []
    output.each_line do |line|
      l = line.split(",")
      jobs << {:JOB_ID => l[1],  :JOB_NAME   => l[2],  :RSC_GRP    => l[3].split[0],
               :ST     => l[4],  :STD        => l[5],  :STDE       => l[6],
               :ACCEPT => l[7],  :START_DATE => l[8],  :NODES      => l[9].split(":")[0],
               :USER   => l[10], :ELAPSE_LIM => l[11], :ELAPSE_TIM => l[12].split[0] }
    end
    jobs
  end
rescue Fujitsu_TCS_TimeoutError
  return [{ JOB_ID: id, ST: 'undetermined' }]
end

#hold_job(id) ⇒ void

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.

This method returns an undefined value.

Put a specified job on hold

Examples:

Put job “1234” on hold

my_batch.hold_job("1234")

Parameters:

  • id (#to_s)

    the id of the job

Raises:

  • (Error)

    if ‘pjhold` command exited unsuccessfully



123
124
125
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 123

def hold_job(id)
  call("pjhold", id.to_s)
end

#release_job(id) ⇒ void

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.

This method returns an undefined value.

Release a specified job that is on hold

Examples:

Release job “1234” from on hold

my_batch.release_job("1234")

Parameters:

  • id (#to_s)

    the id of the job

Raises:

  • (Error)

    if ‘pjrls` command exited unsuccessfully



133
134
135
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 133

def release_job(id)
  call("pjrls", id.to_s)
end

#submit_string(str, args: []) ⇒ String

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.

Submit a script expanded as a string to the batch server

Parameters:

  • str (#to_s)

    script as a string

  • args (Array<#to_s>) (defaults to: [])

    arguments passed to ‘pjsub` command

Returns:

  • (String)

    the id of the job that was created

Raises:

  • (Error)

    if ‘pjsub` command exited unsuccessfully



152
153
154
155
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 152

def submit_string(str, args: [])
  args = args.map(&:to_s)
  call("pjsub", *args, stdin: str.to_s).split[5]
end