Class: OodCore::Job::Adapters::Torque::FFI

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/ood_core/job/adapters/torque/ffi.rb,
lib/ood_core/job/adapters/torque/error.rb

Overview

FFI errors for the Torque adapter.

Defined Under Namespace

Classes: AlrdyexitError, Attrl, Attropl, AttrroError, AttrtypeError, AuthInvalidError, BadArrayDataError, BadArrayReqError, BadParameterError, BadacctError, BadaclhostError, BadatlstError, BadatvalError, BadcredError, BaddependError, BaddisallowtypeError, BadgrpError, BadhostError, BadmomstateError, BadndatvalError, BadscriptError, BadstateError, BaduserError, BatchStatus, CanNotMoveFileError, CanNotOpenFileError, CanNotSaveFileError, CanNotWriteFileError, CantcontactsistersError, CantcreatetmpdirError, CantopensocketError, CkpbsyError, CkpshortError, CleanedoutError, ClientInvalidError, ConnectError, ContinueError, DisprotoError, DuplistError, Error, ExcqrescError, ExecthereError, ExlimitError, ExpiredError, GmoderrError, HopcountError, IffNotFoundError, InternalError, InvalidMutexError, InvalidSyntaxError, IvalreqError, JobAlreadyInQueueError, JobFileCorruptError, JobRecycledError, JobRerunError, JobexistError, JobnotfoundError, JobsubstateError, JobtypeError, JobworkdelayError, MaxquedError, MaxuserquedError, MemMallocError, ModatrrunError, MomrejectError, MungeNotFoundError, MutexAlreadyLockedError, MutexAlreadyUnlockedError, MutexError, MutualexError, NoattrError, NobatchError, NoconnectsError, NocopyfileError, NodeDownError, NodeexistError, NodenbigError, NofaultintolerantError, NofaulttolerantError, NointeractiveError, NojobarraysError, NonodesError, NononrerunableError, NorelymomError, NorerunError, NorerunableError, NoserverError, NosupError, NosyncmstrError, NotImplementedError, NotsnodeError, PermError, PrematureEofError, ProtocolError, QacessError, QuebusyError, QueexistError, QuenbigError, QuenodfltError, QuenoenError, QuenotavailableError, QunoenbError, RegrouteError, RelayedToMomError, RescunavError, RouteexpdError, RouterejError, SelectError, ServerBusyError, ServerNotFoundError, SiscommError, SisrejectError, SocketCloseError, SocketDataError, SocketFaultError, SocketInformationError, SocketListenError, SocketReadError, SocketWriteError, StageinError, SvrdownError, SystemError, ThreadError, ThreadattrError, TimeoutError, TmpdiffownerError, TmpnonameError, TmpnotdirError, ToomanyError, UnkarrayidError, UnkjobidError, UnknodeError, UnknodeatrError, UnkqueError, UnkreqError, UnkrescError, UnksigError

Constant Summary collapse

BatchOp =

Enum for Batch Operation

enum(:set, :unset, :incr, :decr, :eq, :ne, :ge, :gt, :le, :lt, :dflt, :merge, :incr_old)
ERROR_CODES =

Defined error codes, valid as of Torque >=4.2.10

{
  15001 =>   UnkjobidError,
  15002 =>   NoattrError,
  15003 =>   AttrroError,
  15004 =>   IvalreqError,
  15005 =>   UnkreqError,
  15006 =>   ToomanyError,
  15007 =>   PermError,
  15008 =>   IffNotFoundError,
  15009 =>   MungeNotFoundError,
  15010 =>   BadhostError,
  15011 =>   JobexistError,
  15012 =>   SystemError,
  15013 =>   InternalError,
  15014 =>   RegrouteError,
  15015 =>   UnksigError,
  15016 =>   BadatvalError,
  15017 =>   ModatrrunError,
  15018 =>   BadstateError,
  15020 =>   UnkqueError,
  15021 =>   BadcredError,
  15022 =>   ExpiredError,
  15023 =>   QunoenbError,
  15024 =>   QacessError,
  15025 =>   BaduserError,
  15026 =>   HopcountError,
  15027 =>   QueexistError,
  15028 =>   AttrtypeError,
  15029 =>   QuebusyError,
  15030 =>   QuenbigError,
  15031 =>   NosupError,
  15032 =>   QuenoenError,
  15033 =>   ProtocolError,
  15034 =>   BadatlstError,
  15035 =>   NoconnectsError,
  15036 =>   NoserverError,
  15037 =>   UnkrescError,
  15038 =>   ExcqrescError,
  15039 =>   QuenodfltError,
  15040 =>   NorerunError,
  15041 =>   RouterejError,
  15042 =>   RouteexpdError,
  15043 =>   MomrejectError,
  15044 =>   BadscriptError,
  15045 =>   StageinError,
  15046 =>   RescunavError,
  15047 =>   BadgrpError,
  15048 =>   MaxquedError,
  15049 =>   CkpbsyError,
  15050 =>   ExlimitError,
  15051 =>   BadacctError,
  15052 =>   AlrdyexitError,
  15053 =>   NocopyfileError,
  15054 =>   CleanedoutError,
  15055 =>   NosyncmstrError,
  15056 =>   BaddependError,
  15057 =>   DuplistError,
  15058 =>   DisprotoError,
  15059 =>   ExecthereError,
  15060 =>   SisrejectError,
  15061 =>   SiscommError,
  15062 =>   SvrdownError,
  15063 =>   CkpshortError,
  15064 =>   UnknodeError,
  15065 =>   UnknodeatrError,
  15066 =>   NonodesError,
  15067 =>   NodenbigError,
  15068 =>   NodeexistError,
  15069 =>   BadndatvalError,
  15070 =>   MutualexError,
  15071 =>   GmoderrError,
  15072 =>   NorelymomError,
  15073 =>   NotsnodeError,
  15074 =>   JobtypeError,
  15075 =>   BadaclhostError,
  15076 =>   MaxuserquedError,
  15077 =>   BaddisallowtypeError,
  15078 =>   NointeractiveError,
  15079 =>   NobatchError,
  15080 =>   NorerunableError,
  15081 =>   NononrerunableError,
  15082 =>   UnkarrayidError,
  15083 =>   BadArrayReqError,
  15084 =>   BadArrayDataError,
  15085 =>   TimeoutError,
  15086 =>   JobnotfoundError,
  15087 =>   NofaulttolerantError,
  15088 =>   NofaultintolerantError,
  15089 =>   NojobarraysError,
  15090 =>   RelayedToMomError,
  15091 =>   MemMallocError,
  15092 =>   MutexError,
  15093 =>   ThreadattrError,
  15094 =>   ThreadError,
  15095 =>   SelectError,
  15096 =>   SocketFaultError,
  15097 =>   SocketWriteError,
  15098 =>   SocketReadError,
  15099 =>   SocketCloseError,
  15100 =>   SocketListenError,
  15101 =>   AuthInvalidError,
  15102 =>   NotImplementedError,
  15103 =>   QuenotavailableError,
  15104 =>   TmpdiffownerError,
  15105 =>   TmpnotdirError,
  15106 =>   TmpnonameError,
  15107 =>   CantopensocketError,
  15108 =>   CantcontactsistersError,
  15109 =>   CantcreatetmpdirError,
  15110 =>   BadmomstateError,
  15111 =>   SocketInformationError,
  15112 =>   SocketDataError,
  15113 =>   ClientInvalidError,
  15114 =>   PrematureEofError,
  15115 =>   CanNotSaveFileError,
  15116 =>   CanNotOpenFileError,
  15117 =>   CanNotWriteFileError,
  15118 =>   JobFileCorruptError,
  15119 =>   JobRerunError,
  15120 =>   ConnectError,
  15121 =>   JobworkdelayError,
  15122 =>   BadParameterError,
  15123 =>   ContinueError,
  15124 =>   JobsubstateError,
  15125 =>   CanNotMoveFileError,
  15126 =>   JobRecycledError,
  15127 =>   JobAlreadyInQueueError,
  15128 =>   InvalidMutexError,
  15129 =>   MutexAlreadyLockedError,
  15130 =>   MutexAlreadyUnlockedError,
  15131 =>   InvalidSyntaxError,
  15132 =>   NodeDownError,
  15133 =>   ServerNotFoundError,
  15134 =>   ServerBusyError,
}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.pbs_errnoFixnum

The internal PBS error number

int pbs_errno

Returns:

  • (Fixnum)

    pbs error number



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 8

.pbs_serverString (readonly)

The PBS server name

char *pbs_server

Returns:

  • (String)

    pbs server name



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 13

Class Method Details

.check_for_errorvoid

This method returns an undefined value.

Check for any errors set in the errno



182
183
184
185
186
# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 182

def self.check_for_error
  errno = pbs_errno
  self.pbs_errno = 0  # reset error number
  raise_error(errno) if errno > 0
end

.libString

The path to the torque library file

Returns:

  • (String)

    path to torque library



145
146
147
# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 145

def self.lib
  @lib
end

.lib=(lib) ⇒ void

This method returns an undefined value.

Define torque methods using a supplied library

Parameters:

  • lib (#to_s, nil)

    path to library file



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 152

def self.lib=(lib)
  @lib = lib ? lib.to_s : 'torque'

  # Set up FFI to use this library
  ffi_lib @lib

  attach_variable :pbs_errno, :int
  attach_variable :pbs_server, :string
  attach_function :pbs_strerror, [ :int ], :string
  attach_function :pbs_default, [], :string
  attach_function :pbs_connect, [ :string ], :int
  attach_function :pbs_disconnect, [ :int ], :int
  attach_function :pbs_deljob, [ :int, :string, :string ], :int
  attach_function :pbs_holdjob, [ :int, :string, :string, :string ], :int
  attach_function :pbs_rlsjob, [ :int, :string, :string, :string ], :int
  attach_function :pbs_statfree, [ BatchStatus.ptr ], :void
  attach_function :pbs_statjob, [ :int, :string, Attrl.ptr, :string ], BatchStatus.ptr
  attach_function :pbs_statnode, [ :int, :string, Attrl.ptr, :string ], BatchStatus.ptr
  attach_function :pbs_statque, [ :int, :string, Attrl.ptr, :string ], BatchStatus.ptr
  attach_function :pbs_statserver, [ :int, Attrl.ptr, :string ], BatchStatus.ptr
  attach_function :pbs_selstat, [ :int, Attropl.ptr, :string ], BatchStatus.ptr

  # FIXME: The space for the job_identifier string is allocated by
  # pbs_submit() and should be released via a call to free() when no longer
  # needed
  attach_function :pbs_submit, [ :int, Attropl.ptr, :string, :string, :string ], :string
end

.pbs_connect(server) ⇒ Fixnum

Connect to PBS batch server

int pbs_connect(char *server)

Parameters:

  • server (String)

    name of pbs server

Returns:

  • (Fixnum)

    connection identifier

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 30

.pbs_defaultString

Default PBS server name

char *pbs_default(void)

Returns:

  • (String)

    default pbs server name

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 24

.pbs_deljob(connect, job_id, extend) ⇒ Fixnum

Delete a PBS batch job

int pbs_deljob(int connect, char *job_id, char *extend)

Parameters:

  • connect (Fixnum)

    connection identifier

  • job_id (String)

    the job id

  • extend (String)

    implementation defined extensions

Returns:

  • (Fixnum)

    exit status code

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 44

.pbs_disconnect(connect) ⇒ Fixnum

Disconnect from a PBS batch server

int pbs_disconnect(int connect)

Parameters:

  • connect (Fixnum)

    connection identifier

Returns:

  • (Fixnum)

    exit status code

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 37

.pbs_holdjob(connect, job_id, hold_type, extend) ⇒ Fixnum

Place a hold on a PBS batch job

int pbs_holdjob(int connect, char *job_id, char *hold_type, char *extend)

Parameters:

  • connect (Fixnum)

    connection identifier

  • job_id (String)

    the job id

  • hold_type (String)

    type of hold to be applied

  • extend (String)

    implementation defined extensions

Returns:

  • (Fixnum)

    exit status code

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 53

.pbs_rlsjob(connect, job_id, hold_type, extend) ⇒ Fixnum

Release a hold on a PBS batch job

int pbs_rlsjob(int connect, char *job_id, char *hold_type, char *extend)

Parameters:

  • connect (Fixnum)

    connection identifier

  • job_id (String)

    the job id

  • hold_type (String)

    type of hold to be released

  • extend (String)

    implementation defined extensions

Returns:

  • (Fixnum)

    exit status code

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 63

.pbs_selstat(connect, attrib, extend) ⇒ BatchStatus

Note:

It is up to the user to free the space of the batch status objects

Obtain status of selected PBS batch jobs

batch_status * pbs_selstat(int connect, struct attropl *sel_list, char *extend)

Parameters:

  • connect (Fixnum)

    connection identifier

  • attrib (Attropl)

    the attribute operation c-linked list object

  • extend (String)

    implementation defined extensions

Returns:

  • (BatchStatus)

    c-linked list of batch status objects

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 122

.pbs_statfree(stat) ⇒ void

This method returns an undefined value.

Free the memory allocated by BatchStatus object

void pbs_statfree(struct batch_status *stat)

Parameters:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 73

.pbs_statjob(connect, id, attrib, extend) ⇒ BatchStatus

Note:

It is up to the user to free the space of the batch status objects

Obtain status of PBS batch jobs

batch_status * pbs_statjob(int connect, char *id, struct attrl *attrib, char *extend)

Parameters:

  • connect (Fixnum)

    connection identifier

  • id (String)

    job or destination identifier

  • attrib (Attrl)

    the attribute c-linked list object

  • extend (String)

    implementation defined extensions

Returns:

  • (BatchStatus)

    c-linked list of batch status objects

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 79

.pbs_statnode(connect, id, attrib, extend) ⇒ BatchStatus

Note:

It is up to the user to free the space of the batch status objects

Obtain status of PBS nodes

batch_status * pbs_statnode(int connect, char *id, struct attrl *attrib, char *extend)

Parameters:

  • connect (Fixnum)

    connection identifier

  • id (String)

    name of a node or null string

  • attrib (Attrl)

    the attribute c-linked list object

  • extend (String)

    implementation defined extensions

Returns:

  • (BatchStatus)

    c-linked list of batch status objects

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 90

.pbs_statque(connect, id, attrib, extend) ⇒ BatchStatus

Note:

It is up to the user to free the space of the batch status objects

Obtain status of PBS batch queues

batch_status * pbs_statque(int connect, char *id, struct attrl *attrib, char *extend)

Parameters:

  • connect (Fixnum)

    connection identifier

  • id (String)

    name of a queue or null string

  • attrib (Attrl)

    the attribute c-linked list object

  • extend (String)

    implementation defined extensions

Returns:

  • (BatchStatus)

    c-linked list of batch status objects

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 101

.pbs_statserver(connect, attrib, extend) ⇒ BatchStatus

Note:

It is up to the user to free the space of the batch status objects

Obtain status of a PBS batch server

batch_status * pbs_statserver(int connect, struct attrl *attrib, char *extend)

Parameters:

  • connect (Fixnum)

    connection identifier

  • attrib (Attrl)

    the attribute c-linked list object

  • extend (String)

    implementation defined extensions

Returns:

  • (BatchStatus)

    c-linked list of batch status objects

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 112

.pbs_strerror(errno) ⇒ String

Generates PBS error string from given error number

char *pbs_strerror(int errno)

Parameters:

  • errno (Fixnum)

    pbs error number

Returns:

  • (String)

    pbs error string



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 18

.pbs_submit(connect, attrib, script, destination, extend) ⇒ String

Submit a PBS batch job

char *pbs_submit(int connect, struct attropl *attrib, char *script, char *destination, char *extend)

Parameters:

  • connect (Fixnum)

    connection identifier

  • attrib (Attropl)

    the attribute operation c-linked list object

  • script (String)

    the path to the script

  • destination (String)

    the queue to send job to

  • extend (String)

    implementation defined extensions

Returns:

  • (String)

    the job id

See Also:



# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 132

.raise_error(errno) ⇒ void

This method returns an undefined value.

For a given errno, raise the corresponding error with error message

Parameters:

  • errno (Fixnum)

    the error number

Raises:

  • (Error)

    if errno is not 0



192
193
194
# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 192

def self.raise_error(errno)
  raise (ERROR_CODES[errno] || PBS::Error), "#{pbs_strerror(errno)}"
end