Module: PBS::Torque

Extended by:
FFI::Library
Defined in:
lib/pbs/torque.rb

Overview

An interface to the C-library of Torque

Defined Under Namespace

Classes: Attrl, Attropl, BatchStatus

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.pbs_errnoFixnum

The internal PBS error number

int pbs_errno


# File 'lib/pbs/torque.rb', line 8


.pbs_serverString (readonly)

The PBS server name

char *pbs_server


# File 'lib/pbs/torque.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/pbs/torque.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



145
146
147
# File 'lib/pbs/torque.rb', line 145

def self.lib
  @lib
end

.lib=(lib) ⇒ void

This method returns an undefined value.

Define torque methods using a supplied library



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/pbs/torque.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)


# File 'lib/pbs/torque.rb', line 30


.pbs_defaultString

Default PBS server name

char *pbs_default(void)


# File 'lib/pbs/torque.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)


# File 'lib/pbs/torque.rb', line 44


.pbs_disconnect(connect) ⇒ Fixnum

Disconnect from a PBS batch server

int pbs_disconnect(int connect)


# File 'lib/pbs/torque.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)


# File 'lib/pbs/torque.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)


# File 'lib/pbs/torque.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)


# File 'lib/pbs/torque.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)


# File 'lib/pbs/torque.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)


# File 'lib/pbs/torque.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)


# File 'lib/pbs/torque.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)


# File 'lib/pbs/torque.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)


# File 'lib/pbs/torque.rb', line 112


.pbs_strerror(errno) ⇒ String

Generates PBS error string from given error number

char *pbs_strerror(int errno)


# File 'lib/pbs/torque.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)


# File 'lib/pbs/torque.rb', line 132


.raise_error(errno) ⇒ void

This method returns an undefined value.

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

Raises:

  • (Error)

    if errno is not 0



192
193
194
# File 'lib/pbs/torque.rb', line 192

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