GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

GATJob.h

Go to the documentation of this file.
00001 /** @file GATJob.h
00002  * Header file for the GATJob class.
00003  * 
00004  *  A GATJob represents one or more processes which are running or may be 
00005  *  submitted to a resource management system, e.g. by a globusrun command.
00006  * 
00007  *  @date Wed Sep 3 2003
00008  * 
00009  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATJob.h,v 1.21 2004/03/24 19:30:58 hartmutkaiser Exp $
00010  *
00011  *  Copyright (C) Tom Goodale
00012  *  Copyright (C) Hartmut Kaiser
00013  *  This file is part of the GAT Engine.
00014  *  Contributed by 
00015  *    Tom Goodale <goodale@aei.mpg.de> and 
00016  *    Hartmut Kaiser <hartmutkaiser [at] t-online [dot] de>.
00017  *
00018  *  Use, modification and distribution is subject to the Gridlab Software
00019  *  License. (See accompanying file GLlicense.txt or copy at
00020  *  http://www.gridlab.org/GLlicense.txt)
00021  */
00022 
00023 #if !defined(_GATJOB_H_)
00024 #define  _GATJOB_H_
00025 
00026 /* GAT Header Files */
00027 #include "GAT.h"
00028 #include "GATInternal.h"
00029 #include "GATMonitorable.h"
00030 
00031 /* Structures, unions and enums */
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 /* Declare the converters to/from GATObject */
00038 GATOBJECT_DECLARE_CONVERTERS(GATJob);
00039 
00040 /** GATJob_Create
00041  *  @brief Create a new GATJob object
00042  *
00043  *  The function @c GATJob_Create creates a new 
00044  *  GATJob object
00045  *
00046  *  @param context The GAT context to use while thie initialisation of the 
00047  *        new object.
00048  *  @param preferences The preferences to use wile selecting the adaptor for 
00049  *        the corresponding CPI.
00050  *  @param jobid The job id of the job to create.
00051  *  @param initialisation_data Additional initialisation data for the job to 
00052  +        create. 
00053  *
00054  *  @return Returns a handle to the newly created GATJob object.
00055  *        Returns 0 (zero) if an error occurs.
00056  */
00057 GATJob 
00058   GATJob_Create(GATContext context, GATPreferences_const preferences, 
00059     GATJobID jobid, void *initialisation_data);
00060 
00061 /** void GATJob_Destroy(GATJob *resource)
00062  *
00063  *  The function GATJob_Destroy is the destructor used to
00064  *  free all the memory allocated by an GATJob instance.
00065  *
00066  *  @param description The pointer to the GATJob to destroy
00067  */
00068 void
00069   GATJob_Destroy(GATJob *object);
00070 
00071 /** GATJob_Equals
00072  *  @brief Compare two GATJob objects
00073  *
00074  *  The function @c GATJob_Equals compares two objects of the
00075  *  @c GATJob type.
00076  *
00077  *  @param lhs The first list to compare
00078  *  @param rhs The second list to compare
00079  *  @param isequal The pointer to the location, where the outcome of the 
00080  *        function has to be stored.
00081  *
00082  *  @return An error code.
00083  */
00084 GATResult 
00085   GATJob_Equals(GATJob_const lhs,
00086     GATJob_const rhs, GATBool *isequal);
00087 
00088 /** GATJob_Clone
00089  *  @brief Clone the given GATJob
00090  *
00091  *  The function @c GATJob_Clone generates a (deep) copy of 
00092  *  the given GATJob. 
00093  *
00094  *  @param description The object to clone
00095  *  @param new_object The pointer, through which the result is to be 
00096  *        returned.
00097  *
00098  *  @return An error type.
00099  */
00100 GATResult 
00101   GATJob_Clone(GATJob_const object, 
00102     GATJob *new_object);
00103 
00104 /** GATType GATJob_GetType(GATJob_const resource)
00105  *  @brief Return the type of the GATJob
00106  *
00107  *  The function @c GATJob_GetType always returns 
00108  *  @c #GATType_GATJob. 
00109  *
00110  *  @param object The object to inspect
00111  *
00112  *  @return Returns always @c #GATType_GATJob. 
00113  */
00114 GATType
00115   GATJob_GetType(GATJob_const object);
00116 
00117 /** GATResult GATJob_GetInterface(GATJob_const file, GATInterface iftype, void const **ifp)
00118  *  @brief Get an interface supported by a GATObject
00119  *
00120  *  The function GATJob_GetInterface allows to get a pointer to an 
00121  *  additional interface supported by this GATJob.
00122  *
00123  *  @param object The object to be asked for the new interface.
00124  *  @param iftype The interface the object is to be asked for.
00125  *  @param ifp The pointer, through which the result is to be returned.
00126  *
00127  *  @return An error type.
00128  */
00129 GATResult  
00130   GATJob_GetInterface(GATJob_const object, 
00131     GATInterface iftype, void const **ifp);
00132 
00133 
00134 /* GATMonitorable API */
00135 
00136 /** GATJob_AddMetricListener
00137  *
00138  *  The function GATJob_AddMetricListener adds the passed instance of a 
00139  *  GATMetricListener to the list of GATMetricListeners which are notified of 
00140  *  fired GATMetricEvents of the type described by the provided GATMetric 
00141  *  instance.
00142  *
00143  *  @param object The GATJob instance to add the GATMetricListener to.
00144  *  @param listener The GTAMetricListener to call, when the corresponding 
00145  *        GATMetricEvent is fired.
00146  *  @param listener_data The client supplied data, which will be passed through
00147  *        to the GATMetricListener.
00148  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00149  *        to the GATMetricListener.
00150  *  @param cookie The returned value should be used to remove the 
00151  *        GATMetricListener from this GATMonitorable.
00152  *
00153  *  @return An error code.
00154  */ 
00155 GATResult  
00156   GATJob_AddMetricListener(GATJob object, 
00157     GATMetricListener listener, void *listener_data, GATMetric metric,
00158     GATuint32 *cookie);
00159 
00160 /** GATJob_RegisterPolling
00161  *
00162  *  The function GATJob_RegisterPolling registers a continuous 
00163  *  metric with the given GATJob instance.
00164  *
00165  *  @param object The GATJob instance to register the metric with.
00166  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00167  *        to the GATMetricListener. This metric instance must be of type
00168  *        GATMeasurementType_Continuous, otherwise an error is returned.
00169  *  @param event The pointer to a variable, which should receive the resulting
00170  *        GATMetricEvent. The GATMetricEvent instance should be freed by the 
00171  *        caller when it isn't used anymore.
00172  *  @param cookie The returned value should be used to remove the 
00173  *        GATMetricListener from this GATJob.
00174  *
00175  *  @return An error code.
00176  */ 
00177 GATResult  
00178   GATJob_RegisterPolling(GATJob object, GATMetric metric, 
00179     GATMetricEvent *event, GATuint32 *cookie);
00180 
00181 /** GATJob_RemoveRegisteredMetric
00182  *
00183  *  The function GATJob_RemoveRegisteredMetric removes a GATMetricListener, 
00184  *  which was previously registered with GATJob_AddMetricListener.
00185  *
00186  *  @param object The GATJob instance to remove the GATMetricListener from.
00187  *  @param listener The GATMetricListener to call, when the corresponding 
00188  *        GATMetricEvent is fired.
00189  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00190  *        to the GATMetricListener.
00191  *  @param cookie This value identifies the GATMetricListener to remove, it 
00192  *        was returned from the corresponding GATMonitorable_AddMetricListener 
00193  *        or GATMonitorable_MetricRegisterPolling functions.
00194  *  
00195  *  @return An error code.
00196  */
00197 GATResult  
00198   GATJob_RemoveRegisteredMetric(GATJob object, 
00199     GATMetric metric, GATuint32 cookie);
00200 
00201 /** GATJob_GetMetrics
00202  *
00203  *  The function GATJob_GetMetrics returns a list of metrics supported 
00204  *  by this GATJob.
00205  *
00206  *  @param object The GATJob instance, for which the supported metrics 
00207  *        should be returned.
00208  *  @param metrics The pointer to the variable, which receives the resulting 
00209  *        list of metrics.
00210  *
00211  *  @return An error code.
00212  */
00213 GATResult  
00214   GATJob_GetMetrics(GATJob_const object, GATList_GATMetric *metrics);
00215 
00216 
00217 /* GATAdvertiseable API */
00218 #define GATJOB_VERSION1    0x0100
00219 #define GATJOB_LASTVERSION GATJOB_VERSION1
00220 #define GATJOB_MINOR_MASK  0x00ff
00221 
00222 /** GATResult  GATJob_Serialise(GATJob file, GATObject stream, GATBool clear_dirty)
00223  *  @brief Serialise a GATJob object
00224  *
00225  *  The function GATJob_Serialise serialises the given GATFIle object into the
00226  *  given stream. 
00227  *
00228  *  @param object The GATJob object to serialise.
00229  *  @param stream The stream interface to use for the serialisation.
00230  *  @param clear_dirty If the clear_dirty parameter is set to GATTrue, the 
00231  *        internal dirty flag of this object is to be reset (no used here)
00232  *
00233  *  @return An error code.
00234  */
00235 GATResult  
00236   GATJob_Serialise(GATJob object, GATObject stream, 
00237     GATBool clear_dirty);
00238 
00239 /** GATJob GATJob_DeSerialise(GATContext context, GATObject stream, GATBool clear_dirty)
00240  *  @brief De-serialise a GATJob object
00241  *
00242  *  The function GATJob_DeSerialise de-serialises a streamed GATJob object  
00243  *  from the given stream  It constructs a new instance of the de-serialised 
00244  *  object.
00245  *
00246  *  @param context The GAT context to be used for object construction.
00247  *  @param stream The stream interface to use for the serialisation.
00248  *  @param result The pointer to a variable, which receives the status code of
00249  *        the operation.
00250  *
00251  *  @return The newly constructed GATJob object.
00252  */
00253 GATJob 
00254   GATJob_DeSerialise(GATContext context, GATObject stream, 
00255     GATResult *result);
00256 
00257 /** GATJob_GetIsDirty
00258  *  
00259  *  The function GATJob_GetIsDirty retrieves the status of the dirty flag of 
00260  *  this GATJob object.
00261  *
00262  *  @param object The GATJob object to inspect for its dirty status.
00263  *  @param isdirty The pointer to a variable, which receives the dirty status.
00264  *
00265  *  @return An error code.
00266  */
00267 GATResult  
00268   GATJob_GetIsDirty(GATJob_const object, GATBool *isdirty);
00269 
00270 /** GATJob_UnSchedule
00271  *
00272  *  The function GATJob_UnSchedule guarantees that this GATJob is not scheduled 
00273  *  to a job queue, its state is GAT Initial. This operation can only be called 
00274  *  on a GATJob in the GAT Scheduled state, otherwise an error will is issued.
00275  *
00276  *  @param object The job to unschedule.
00277  *
00278  *  @return An error code.
00279  */
00280 GATResult GATJob_UnSchedule(GATJob_const object);
00281 
00282 /** GATJob_Checkpoint
00283  *
00284  *  The function GATJob_Checkpoint triggers a checkpoint operation for the 
00285  *  GATJob. The call can only succeed on processes which support application 
00286  *  level checkpointing, or on resources which provide system level 
00287  *  checkpointing.
00288  *  The call returns immediately after delivering the checkpointing request to 
00289  *  the job or to the resource the job is running on; the actual checkpoint 
00290  *  may happen some time after this return.
00291  *
00292  *  @param object The job to checkpoint.
00293  *
00294  *  @return An error code.
00295  */
00296 GATResult GATJob_Checkpoint(GATJob_const object);
00297 
00298 /** GATJob_CloneJob
00299  *
00300  *  The function GATJob_CloneJob creates a copy of the GATJob. The resulting 
00301  *  GATJob has the same GATSoftwareDescription in its GATJobDescription, but 
00302  *  the GATResourceDescriptions or GATResources of its GATJobDescription may be 
00303  *  altered.
00304  *
00305  *  @param object The job to clone to a new hardware.
00306  *  @param hr (optional) The GATHardwareResource to use to schedule the clones 
00307  *        job. If this parameter is not given (zero) the GATHardwareResource is 
00308  *        used, which was used to create the current GATJob.
00309  *  @param cloned_job The pointer to a variable receiving the cloned job object.
00310  *
00311  *  @return An error code.
00312  */
00313 GATResult GATJob_CloneJob(GATJob_const object, GATHardwareResource_const hr,
00314   GATJob *cloned_job);
00315 
00316 /** GATJob_Migrate
00317  *
00318  *  The function GATJob_Migrate provides similar functionality as the 
00319  *  #GATJob_CloneJob operation. The only difference is that the calling GATJob 
00320  *  instance is discontinued after the new job is spawned off successfully — 
00321  *  its state is #GATJobState_Stopped then.
00322  *
00323  *  @param object The job to migrate to a new hardware.
00324  *  @param hr (optional) The GATHardwareResource to use to schedule the clones 
00325  *        job. If this parameter is not given (zero) the GATHardwareResource is 
00326  *        used, which was used to create the current GATJob.
00327  *  @param migrated_job The pointer to a variable receiving the cloned job 
00328  *        object.
00329  *
00330  *  @return An error code.
00331  */
00332 GATResult GATJob_Migrate(GATJob_const object, GATHardwareResource_const hr,
00333   GATJob *migrated_job);
00334 
00335 /** GATJob_Stop
00336  *
00337  *  The function GATJob_Stop stops the GATJob. Upon a successful call to this 
00338  *  operation, the processes associated with the GATJob are forcibly 
00339  *  terminated. This operation can only be called on a GATJob in the 
00340  *  #GATJobState_Running state.
00341  *
00342  *  @param object The job to stop.
00343  *
00344  *  @return An error code.
00345  */
00346 GATResult GATJob_Stop(GATJob object);
00347 
00348 /** GATJob_GetJobDescription
00349  *
00350  *  The function GATJob_GetJobDescription returns the GATJobDescription 
00351  *  instance used to create that GATJob instance.
00352  *
00353  *  @param object The job for which the associated GATJobDescription should be
00354  *        returned.
00355  *  @param jd The pointer to a variable, which should receive the associated 
00356  *        job description.
00357  *
00358  *  @return An error code.
00359  */
00360 GATResult GATJob_GetJobDescription(GATJob_const object, 
00361   GATJobDescription_const *jd);
00362 
00363 /** GATJob_GetState
00364  *
00365  *  The function GATJob_GetState returns the state of the represented process. 
00366  *  This is one of the associated public class constants #GATJobState_Initial, 
00367  *  #GATJobState_Scheduled, #GATJobState_Running, or #GATJobState_Stopped.
00368  *
00369  *  @param object The job The job for which the associated GATJobState should be
00370  *        returned.
00371  *  @param state The pointer to a variable, which should receive the resulting
00372  *        GATJobState.
00373  *
00374  *  @return An error code.
00375  */
00376 GATResult GATJob_GetState(GATJob_const object, GATJobState *state);
00377 
00378 /** GATJob_GetInfo
00379  *
00380  *  The function GATJob_GetInfo returns an instance of the class GATTable, 
00381  *  which contains the essential information about the GATJob object, such as
00382  *  the host name, the schedule time, the start time, the stop time, whether 
00383  *  the GATJob is checkpointable etc.
00384  *
00385  *  @param object The job to ask for its parameter info.
00386  *  @param jobinfo The pointer to a variable, which should receive the returned
00387  *        GATTable containing the job information.
00388  *
00389  *  @return An error code.
00390  */
00391 GATResult GATJob_GetInfo(GATJob_const object, GATTable_const *jobinfo);
00392 
00393 /** GATJob_GetJobID
00394  *
00395  *  The function GATJob_GetJobID returns the job id, a globally unique 
00396  *  identifier for the represented process corresponding to this instance. This 
00397  *  operation SHOULD be called on a GATJob instance only when the instance is 
00398  *  in a GAT Running or GAT Scheduled state, otherwise an error will be issued.
00399  *
00400  *  An exception to this rule is the GATJob object returned from the 
00401  *  GATSelf_GetJob function, which represents the current job.
00402  *
00403  *  @param object The job to get the job id for.
00404  *  @param jobid The pointer to a variable, which should receive the resulting 
00405  *        GAT job id.
00406  *
00407  *  @return An error code.
00408  */
00409 GATResult GATJob_GetJobID(GATJob_const object, GATJobID_const *jobid);
00410 
00411 /** GATJob_GetNativeID
00412  *
00413  *  The function GATJob_GetNativeID returns the job id, which was assigned to 
00414  *  this job by the resource management service starting this job. If no such
00415  *  native id exists, this function will fail.
00416  *
00417  *  @param object The job to get the job id for.
00418  *  @param jobid The pointer to a variable, which should receive the resulting 
00419  *        GRMS job id.
00420  *
00421  *  @return An error code.
00422  */
00423 GATResult GATJob_GetNativeID(GATJob_const object, GATJobID_const *jobid);
00424 
00425 /** GATJob_GetStatus
00426  *
00427  *  The function GATJob_GetStatus SHOULD provide a GATStatus instance which 
00428  *  gives further information as to the cause of the error, if the job is in 
00429  *  the GAT SubmissionError state.
00430  *
00431  *  @param object The job to ask for the associated GATStatus object.
00432  *  @param status The variable, which should receive the associated GATStatus
00433  *        object.
00434  *
00435  *  @return An error code.
00436  */
00437 GATResult GATJob_GetStatus(GATJob_const object, GATStatus_const *jobstatus);
00438 
00439 #ifdef __cplusplus
00440 } /* extern "C" */
00441 #endif
00442 
00443 #endif /* !defined(_GATJOB_H_) */