GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

job.c

Go to the documentation of this file.
00001 /** @file job.c
00002  *  Source file for the sample Job CPI provider.
00003  *
00004  *  @date Sat Oct 25 2003
00005  *
00006  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/adaptors/resourcebroker/job.c,v 1.12 2004/04/26 15:45:00 hartmutkaiser Exp $
00007  *
00008  *  Copyright (C) Hartmut Kaiser
00009  *  This file is part of the GAT Engine.
00010  *  Contributed by Hartmut Kaiser <hartm  utkaiser [at] t-online [dot] de>.
00011  *
00012  *  Use, modification and distribution is subject to the Gridlab Software
00013  *  License. (See accompanying file GLlicense.txt or copy at
00014  *  http://www.gridlab.org/GLlicense.txt)
00015  */
00016  
00017 static const char *rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/adaptors/resourcebroker/job.c,v 1.12 2004/04/26 15:45:00 hartmutkaiser Exp $";
00018  
00019 /* System Header Files */
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 #include <string.h>
00023 
00024 /* GAT Header Files */
00025 #include "GATCPI.h"
00026 #include "GATJobCPIInstanceData.h"
00027 
00028 /* Macros */
00029 #define __countof(x) (sizeof(x)/sizeof(x[0]))
00030 
00031 /* Structures, unions and enums */
00032 
00033 /* Static function prototypes */
00034 static void
00035 resourcebroker_adaptor_GATJobCPI_Destroy(void *data);
00036 
00037 /* instance specific functions */
00038 static GATResult
00039   resourcebroker_adaptor_GATJobCPI_ServiceActions(void *data, 
00040     GATJobCPI_Instance *instance_data, GATTimePeriod_const timeout /* = 0 */);
00041   
00042 static GATResult 
00043   resourcebroker_adaptor_GATJobCPI_CreateInstance(
00044     void *data, GATJobCPI_Instance *instance_data, void *initialisation_data);
00045 
00046 static void 
00047   resourcebroker_adaptor_GATJobCPI_DestroyInstance(
00048     void *data, GATJobCPI_Instance *instance_data);
00049 
00050 static GATResult 
00051   resourcebroker_adaptor_GATJobCPI_CloneInstance(
00052     void *data, GATJobCPI_Instance const *instance_data, 
00053     GATJobCPI_Instance *new_instance_data);
00054 
00055 static GATResult 
00056   resourcebroker_adaptor_GATJobCPI_EqualsInstance(
00057     void *data, GATJobCPI_Instance const *lhs, 
00058     GATJobCPI_Instance const *rhs, GATBool *isequal);
00059 
00060 /* Monitoring support */
00061 static GATResult 
00062   resourcebroker_adaptor_GATJobCPI_GetMetrics(
00063     void *data, GATJobCPI_Instance const *instance_data, 
00064     GATList_GATMetric *metrics);
00065 static GATResult 
00066   resourcebroker_adaptor_GATJobCPI_GetMetricEvent(
00067     void *data, GATJobCPI_Instance const *instance_data, 
00068     GATMetric metric, GATMetricEvent *event);
00069 
00070 /* Serialisation support */
00071 static GATResult 
00072 resourcebroker_adaptor_GATJobCPI_Serialise(
00073   void *data, GATJobCPI_Instance const *instance_data, 
00074   GATObject stream, GATBool clear_dirty);
00075 static GATResult 
00076 resourcebroker_adaptor_GATJobCPI_DeSerialise(
00077   void *data, GATObject stream, 
00078   GATJobCPI_Instance *instance_data);
00079 
00080 /* CPI API functionality */
00081 static GATResult
00082 resourcebroker_adaptor_GATJobCPI_UnSchedule(void *data, 
00083   GATJobCPI_Instance const *instance_data);
00084 
00085 static GATResult 
00086 resourcebroker_adaptor_GATJobCPI_Checkpoint(void *data, 
00087   GATJobCPI_Instance const *instance_data);
00088 
00089 static GATResult 
00090 resourcebroker_adaptor_GATJobCPI_CloneJob(void *data, 
00091   GATJobCPI_Instance const *instance_data, GATHardwareResource_const hr, 
00092   GATJob *cloned_job);
00093 
00094 static GATResult 
00095 resourcebroker_adaptor_GATJobCPI_Migrate(void *data, 
00096   GATJobCPI_Instance const *instance_data, GATHardwareResource_const hr, 
00097   GATJob *migrated_job);
00098 
00099 static GATResult 
00100 resourcebroker_adaptor_GATJobCPI_Stop(void *data, 
00101   GATJobCPI_Instance const *instance_data);
00102 
00103 static GATResult 
00104 resourcebroker_adaptor_GATJobCPI_GetJobDescription(void *data, 
00105   GATJobCPI_Instance const *instance_data, GATJobDescription_const *jd);
00106   
00107 static GATResult 
00108 resourcebroker_adaptor_GATJobCPI_GetInfo(void *data, 
00109   GATJobCPI_Instance const *instance_data, GATTable_const *jobinfo);
00110   
00111 static GATResult 
00112 resourcebroker_adaptor_GATJobCPI_GetJobID(void *data, 
00113   GATJobCPI_Instance const *instance_data, GATJobID_const *jobid);
00114   
00115 static GATResult 
00116 resourcebroker_adaptor_GATJobCPI_GetStatus(void *data, 
00117   GATJobCPI_Instance const *instance_data, GATStatus_const *jobstatus);
00118 
00119 /* File scope variables */
00120 
00121 /* supported metrics */
00122 static GATStaticMetric metric_data[] = {
00123   /* job.status_changed event */
00124   { 
00125     "job.status_changed",           /* name */
00126     GATMeasurementType_EventLike,   /* type */
00127     GATType_GATuint32,              /* data type (actually a GATJobState) */
00128     "",                             /* unit */
00129     0,                              /* parameter count */
00130     0                               /* parameters */
00131   },
00132 };
00133 
00134 /* symbolic constants for the metric positions inside the metric_data array */
00135 #define METRIC_STATUS_CHANGED  0
00136 
00137 /* External functions */
00138 
00139 /* Register the CPI to implement */
00140 GATResult resourcebroker_adaptor_Register_GATJobCPI(
00141   GATContext error_context, GATRegistry registry, 
00142   GATTable_const system_config, GATTable_const instance_config, void *token)
00143 {
00144   GAT_USES_STATUS(error_context, "resourcebroker_adaptor_Register_GATJobCPI");
00145   
00146   GATJobCPI cpi = NULL;
00147   GATJobCPI_Data cpidata;
00148 
00149   {
00150     memset(&cpidata, 0, sizeof(GATJobCPI_Data));
00151       
00152     /*
00153      *  provide the appropriate callback functions
00154      */
00155     cpidata.data = NULL;   /* no adaptor instance data */
00156     cpidata.destroy = resourcebroker_adaptor_GATJobCPI_Destroy;
00157     
00158     /* instance data handling */
00159     cpidata.service_actions = resourcebroker_adaptor_GATJobCPI_ServiceActions;
00160     cpidata.create_instance = resourcebroker_adaptor_GATJobCPI_CreateInstance;
00161     cpidata.destroy_instance = resourcebroker_adaptor_GATJobCPI_DestroyInstance;
00162     cpidata.clone_instance = resourcebroker_adaptor_GATJobCPI_CloneInstance;
00163     cpidata.equals_instance = resourcebroker_adaptor_GATJobCPI_EqualsInstance;
00164 
00165     /* monitoring support functions */
00166     cpidata.get_metrics = resourcebroker_adaptor_GATJobCPI_GetMetrics;
00167     cpidata.get_metric_event = resourcebroker_adaptor_GATJobCPI_GetMetricEvent;
00168     
00169     /* serialisation support functions */
00170     cpidata.serialise = resourcebroker_adaptor_GATJobCPI_Serialise;
00171     cpidata.deserialise = resourcebroker_adaptor_GATJobCPI_DeSerialise;
00172     
00173     
00174     /* CPI specific API functions */
00175     cpidata.unschedule = resourcebroker_adaptor_GATJobCPI_UnSchedule;
00176     cpidata.checkpoint = resourcebroker_adaptor_GATJobCPI_Checkpoint;
00177     cpidata.clonejob = resourcebroker_adaptor_GATJobCPI_CloneJob;
00178     cpidata.migratejob = resourcebroker_adaptor_GATJobCPI_Migrate;
00179     cpidata.stopjob = resourcebroker_adaptor_GATJobCPI_Stop;
00180     cpidata.get_jobdescription = resourcebroker_adaptor_GATJobCPI_GetJobDescription;
00181     cpidata.get_jobinfo = resourcebroker_adaptor_GATJobCPI_GetInfo;
00182     cpidata.get_jobid = resourcebroker_adaptor_GATJobCPI_GetJobID;
00183     cpidata.get_status = resourcebroker_adaptor_GATJobCPI_GetStatus;
00184   
00185     /* Create a GATJobCPI object. */
00186     cpi = GATJobCPI_Create(GATJOBCPI_VERSION, &cpidata);
00187     if(NULL != cpi)
00188     {
00189       /* Need to pass preferences to allow matching
00190        * of a user's preferences with what this adaptor does.
00191        */
00192       GATPreferences preferences = GATPreferences_Create();
00193       if(NULL != preferences)
00194       {
00195         GAT_CREATE_STATUS(GATPreferences_Add(preferences, "Name", 
00196           "resourcebroker_adaptor"));
00197         GAT_CREATE_STATUS(GATPreferences_Add(preferences, "Security", "none"));
00198         GAT_CREATE_STATUS(GATPreferences_Add(preferences, "Local", "true"));
00199         
00200         GAT_CREATE_STATUS(GATRegistry_AddGATJobCPI(registry, cpi, token, 
00201           preferences));
00202         
00203         GATPreferences_Destroy(&preferences);
00204       }
00205     }
00206   }
00207 
00208   if (GAT_FAILED(GAT_CURRENT_STATUS()))
00209   {
00210     GATJobCPI_Destroy(&cpi);
00211   }
00212 
00213   return GAT_RETURN_STATUS();
00214 }
00215 
00216 /* Local functions */
00217 
00218 static void
00219 resourcebroker_adaptor_GATJobCPI_Destroy(void *data)
00220 {
00221   /* nothing to do here (no internal data allocated) */
00222   assert(NULL == data);
00223 }
00224 
00225 
00226 /* instance specific functions */
00227 
00228 /** resourcebroker_adaptor_GATJobCPI_ServiceActions
00229  *  
00230  *  The function resourcebroker_adaptor_GATJobCPI_ServiceActions is called, whenever
00231  *  the client calls GATContext_ServiceActions. This function is called for 
00232  *  every created object.
00233  *  This function should be used to update all instance specific data, which 
00234  *  may have been changed asynchronously or to fire pending events.
00235  *
00236  *  @param data Adaptor-provided data object.
00237  *  @param instance_data The instance data of this CPI object
00238  *  @param timeout This may be a 0 timeout to indicate no timeout at all, or
00239  *        a specific time length.
00240  *
00241  *  @return An error code.
00242  */
00243 static GATResult
00244 resourcebroker_adaptor_GATJobCPI_ServiceActions(void *data, 
00245   GATJobCPI_Instance *instance_data, GATTimePeriod_const timeout)
00246 {
00247   return GAT_NOTIMPL;
00248 }
00249 
00250 /** resourcebroker_adaptor_GATJobCPI_CreateInstance
00251  *  Create a new CPI object instance.
00252  *  Adaptor implementation of create instance capability.
00253  *
00254  * @param data Adaptor-provided data object.
00255  * @param context The GATContext for this CPI instance
00256  * @param target The location of the file in question.
00257  * @param new_instance_data The pointer to the variable, where the instance 
00258  *      data of this CPI object is to be returned to.
00259  * 
00260  * @return An error code.
00261  */
00262 static GATResult 
00263 resourcebroker_adaptor_GATJobCPI_CreateInstance(void *data, 
00264   GATJobCPI_Instance *new_instance_data, void *initialisation_data)
00265 {
00266   GAT_USES_STATUS(new_instance_data->context, 
00267     "resourcebroker_adaptor_GATJobCPI_CreateInstance");
00268 
00269   if (NULL != new_instance_data)
00270   {
00271     GAT_CREATE_STATUS(GATJobCPIInstance_Data_Clone(
00272       (GATJobCPIInstance_Data *) initialisation_data,
00273       (GATJobCPIInstance_Data **) &new_instance_data->instance_data));
00274   }
00275 
00276   return GAT_RETURN_STATUS();
00277 }
00278 
00279 /** resourcebroker_adaptor_GATJobCPI_DestroyInstance
00280  *  Destroy a CPI object instance.
00281  *  Adaptor implementation of destroy instance capability.
00282  *
00283  * @param data Adaptor-provided data object.
00284  * @param instance_data The instance data of the CPI object to destroy.
00285  */
00286 static void
00287 resourcebroker_adaptor_GATJobCPI_DestroyInstance(void *data, 
00288   GATJobCPI_Instance *instance_data)
00289 {
00290   GATJobCPIInstance_Data_Destroy(
00291     (GATJobCPIInstance_Data **) &instance_data->instance_data);
00292 }
00293 
00294 /** resourcebroker_adaptor_GATJobCPI_CloneInstance
00295  *  Clone a CPI object instance.
00296  *  Adaptor implementation of the clone instance capability.
00297  *
00298  * @param data Adaptor-provided data object.
00299  * @param instance_data The instance data of this CPI object
00300  * @param new_instance_data The pointer to the variable, where the instance 
00301  *      data of the cloned CPI object is to be returned to.
00302  * 
00303  * @return An error code.
00304  */
00305 static GATResult 
00306 resourcebroker_adaptor_GATJobCPI_CloneInstance(
00307   void *data, GATJobCPI_Instance const *instance_data, 
00308   GATJobCPI_Instance *new_instance_data)
00309 {
00310   GAT_USES_STATUS(instance_data->context, 
00311     "resourcebroker_adaptor_GATJobCPI_CloneInstance");
00312 
00313   if (NULL != instance_data && NULL != new_instance_data)
00314   {
00315     GAT_CREATE_STATUS(GATJobCPIInstance_Data_Clone(
00316       (GATJobCPIInstance_Data *) instance_data->instance_data, 
00317       (GATJobCPIInstance_Data **) &new_instance_data->instance_data));
00318   }
00319   else
00320   {
00321     GAT_CREATE_STATUS(GAT_INVALID_PARAMETER);
00322   }
00323 
00324   return GAT_RETURN_STATUS();
00325 }
00326 
00327 /** resourcebroker_adaptor_GATJobCPI_EqualsInstance
00328  *  Clone a CPI object instance.
00329  *  Adaptor implementation of the clone instance capability.
00330  *
00331  * @param data Adaptor-provided data object.
00332  * @param lhs The instance data of the left CPI object.
00333  * @param lhs The instance data of the right CPI object.
00334  * @param isequal The pointer to the variable, where the result is to be 
00335  *        returned to.
00336  *
00337  * @return An error code.
00338  */
00339 static GATResult 
00340 resourcebroker_adaptor_GATJobCPI_EqualsInstance(
00341   void *data, GATJobCPI_Instance const *lhs, 
00342   GATJobCPI_Instance const *rhs, GATBool *isequal)
00343 {
00344   GAT_USES_STATUS(lhs->context, 
00345     "resourcebroker_adaptor_GATResourceCPI_CloneInstance");
00346 
00347   if (NULL != lhs && NULL != rhs)
00348   {
00349     GAT_CREATE_STATUS(GATJobCPIInstance_Data_Equals(
00350       (GATJobCPIInstance_Data *) lhs->instance_data,
00351       (GATJobCPIInstance_Data *) rhs->instance_data, isequal));
00352   }
00353   else
00354   {
00355     GAT_CREATE_STATUS(GAT_INVALID_HANDLE);
00356   }
00357 
00358   return GAT_RETURN_STATUS();
00359 }
00360 
00361 
00362 /* Monitoring support */
00363 
00364 /** resourcebroker_adaptor_GATJobCPI_GetMetrics
00365  *
00366  *  The function resourcebroker_adaptor_GATJobCPI_GetMetrics should return a 
00367  *  list of GATMetric objects supported by this adaptor. I.e. the adaptor is 
00368  *  capable to fire GATMetricEvents for the returned metrics. This list should 
00369  *  include all the supported metrics, event like and continuous ones.
00370  *
00371  *  @param data Adaptor-provided data object.
00372  *  @param instance_data Instance data for the CPI provider object.
00373  *  @param metrics The pointer to the variable, which receives the returned 
00374  *        list of metrics.
00375  *
00376  *  @return An error code.
00377  */
00378 static GATResult 
00379 resourcebroker_adaptor_GATJobCPI_GetMetrics(void *data, 
00380   GATJobCPI_Instance const *instance_data, GATList_GATMetric *metrics)
00381 {
00382   return GATMetric_CreateListOfMetrics(metric_data, __countof(metric_data), 
00383     metrics);
00384 }
00385 
00386 /** resourcebroker_adaptor_GATJobCPI_GetMetricEvent
00387  *
00388  *  The function resourcebroker_adaptor_GATJobCPI_GetMetricEvent should 
00389  *  return the GATMetricEvent associated with the given continuous metric. This 
00390  *  function gets called for continuous metrics only, since returning the 
00391  *  metric event object to the caller is th only way for the client to get 
00392  *  access to it.
00393  *
00394  *  @param data Adaptor-provided data object.
00395  *  @param instance_data Instance data for the CPI provider object.
00396  *  @param metric The metric instance describing the metric event to return.
00397  *        This metric should be equivalent to one of the metrics returned by
00398  *        our own GetMetrics CPI function (see above). If this is another
00399  *        (not known to us metric), an error should be returned.
00400  *  @param event The pointer to the variable, which receives the metric event 
00401  *        to return.
00402  *
00403  *  @return An error code.
00404  */
00405 static GATResult 
00406 resourcebroker_adaptor_GATJobCPI_GetMetricEvent(void *data, 
00407   GATJobCPI_Instance const *instance_data, GATMetric metric, 
00408   GATMetricEvent *event)
00409 {
00410   return GAT_NOTIMPL;
00411 }
00412 
00413 /* Serialisation support */
00414 
00415 /** resourcebroker_adaptor_GATJobCPI_Serialise
00416  *
00417  *  The function resourcebroker_adaptor_GATJobCPI_Serialise is called by the 
00418  *  GAT engine, whenever the client requested a Serialise operation on the 
00419  *  corresponding object. The function should serialise into the given stream 
00420  *  all the instance specific data of the object.
00421  *
00422  *  @param data Adaptor-provided data object.
00423  *  @param instance_data The instance data of this CPI object.
00424  *  @param stream The GATSTream object to use for serialisation of the instance 
00425  *        data.
00426  *  @param clear_dirty If the clear_dirty parameter is set to GATTrue, the 
00427  *        internal dirty flag of this object is to be reset.
00428  *
00429  *  @return An error code
00430  */
00431 static GATResult 
00432 resourcebroker_adaptor_GATJobCPI_Serialise(void *data, 
00433   GATJobCPI_Instance const *instance_data, GATObject stream,
00434   GATBool clear_dirty)
00435 {
00436   GAT_USES_STATUS(instance_data->context, 
00437     "resourcebroker_adaptor_GATJobCPI_Serialise");
00438 
00439   GAT_CREATE_STATUS(GATJobCPIInstance_Data_Serialize(
00440     (GATJobCPIInstance_Data const *) instance_data->instance_data, stream,
00441     clear_dirty));
00442 
00443   return GAT_RETURN_STATUS();
00444 }
00445 
00446 /** resourcebroker_adaptor_GATJobCPI_DeSerialise
00447  *
00448  *  The function resourcebroker_adaptor_GATJobCPI_DeSerialise is called by 
00449  *  the GATEngine, whenever the client requested a DeSerialise operation for
00450  *  a corresponding object. The function should deserialise all the instance 
00451  *  specific data of the object from the given stream.
00452  *
00453  *  @param data Adaptor-provided data object.
00454  *  @param stream The GATSTream object to use for de-serialisation of the 
00455  *        instance data.
00456  *  @param instance_data The instance data of this CPI object.
00457  *
00458  *  @return An error code
00459  */
00460 static GATResult 
00461 resourcebroker_adaptor_GATJobCPI_DeSerialise(void *data, 
00462   GATObject stream, GATJobCPI_Instance *instance_data)
00463 {
00464   GAT_USES_STATUS(instance_data->context, 
00465     "resourcebroker_adaptor_GATJobCPI_DeSerialise");
00466 
00467   GAT_CREATE_STATUS(GATJobCPIInstance_Data_DeSerialize(
00468     instance_data->context, stream,
00469     (GATJobCPIInstance_Data **) &instance_data->instance_data));
00470 
00471   return GAT_RETURN_STATUS();
00472 }
00473 
00474 
00475 /* CPI specific API functions */
00476 
00477 /** resourcebroker_adaptor_GATJobCPI_UnSchedule
00478  *
00479  *  The function resourcebroker_adaptor_GATJobCPI_UnSchedule guarantees that 
00480  *  the GATJob corresponding to this GATJobCPI is not scheduled to a job queue, 
00481  *  its state is GAT Initial. This operation can only be called 
00482  *  on a GATJob in the GAT Scheduled state, otherwise an error will is issued.
00483  *
00484  *  @param data Adaptor-provided data object.
00485  *  @param instance_data The instance data of this CPI object.
00486  *
00487  *  @return An error code.
00488  */
00489 static GATResult
00490 resourcebroker_adaptor_GATJobCPI_UnSchedule(void *data, 
00491   GATJobCPI_Instance const *instance_data)
00492 {
00493   return GAT_NOTIMPL;
00494 }
00495 
00496 /** resourcebroker_adaptor_GATJobCPI_Checkpoint
00497  *
00498  *  The function resourcebroker_adaptor_GATJobCPI_Checkpoint triggers a 
00499  *  checkpoint operation for the given GATJob. The call can only succeed on 
00500  *  processes which support application level checkpointing, or on resources 
00501  *  which provide system level checkpointing.
00502  *  The call returns immediately after delivering the checkpointing request to 
00503  *  the job or to the resource the job is running on; the actual checkpoint 
00504  *  may happen some time after this return.
00505  *
00506  *  @param data Adaptor-provided data object.
00507  *  @param instance_data The instance data of this CPI object.
00508  *
00509  *  @return An error code.
00510  */
00511 static GATResult 
00512 resourcebroker_adaptor_GATJobCPI_Checkpoint(void *data, 
00513   GATJobCPI_Instance const *instance_data)
00514 {
00515   return GAT_NOTIMPL;
00516 }
00517 
00518 /** resourcebroker_adaptor_GATJobCPI_CloneJob
00519  *
00520  *  The function resourcebroker_adaptor_GATJobCPI_CloneJob creates a copy of 
00521  *  the GATJob. The resulting GATJob has the same GATSoftwareDescription in its 
00522  *  GATJobDescription, but the GATResourceDescriptions or GATResources of its 
00523  *  GATJobDescription may be altered.
00524  *
00525  *  @param data Adaptor-provided data object.
00526  *  @param instance_data The instance data of this CPI object.
00527  *  @param hr (optional) The GATHardwareResource to use to schedule the clones 
00528  *        job. If this parameter is not given (zero) the GATHardwareResource is 
00529  *        used, which was used to create the current GATJob.
00530  *  @param cloned_job The pointer to a variable receiving the cloned job object.
00531  *
00532  *  @return An error code.
00533  */
00534 static GATResult 
00535 resourcebroker_adaptor_GATJobCPI_CloneJob(void *data, 
00536   GATJobCPI_Instance const *instance_data, GATHardwareResource_const hr, 
00537   GATJob *cloned_job)
00538 {
00539   return GAT_NOTIMPL;
00540 }
00541 
00542 /** resourcebroker_adaptor_GATJobCPI_Migrate
00543  *
00544  *  The function resourcebroker_adaptor_GATJobCPI_Migrate provides similar 
00545  *  functionality as the resourcebroker_adaptor_GATJobCPI_CloneJob operation. 
00546  *  The only difference is that the calling GATJob instance is discontinued 
00547  *  after the new job is spawned off successfully — its state is 
00548  *  #GATJobState_Stopped then.
00549  *
00550  *  @param data Adaptor-provided data object.
00551  *  @param instance_data The instance data of this CPI object.
00552  *  @param hr (optional) The GATHardwareResource to use to schedule the clones 
00553  *        job. If this parameter is not given (zero) the GATHardwareResource is 
00554  *        used, which was used to create the current GATJob.
00555  *  @param migrated_job The pointer to a variable receiving the cloned job 
00556  *        object.
00557  *
00558  *  @return An error code.
00559  */
00560 static GATResult 
00561 resourcebroker_adaptor_GATJobCPI_Migrate(void *data, 
00562   GATJobCPI_Instance const *instance_data, GATHardwareResource_const hr, 
00563   GATJob *migrated_job)
00564 {
00565   return GAT_NOTIMPL;
00566 }
00567 
00568 /** resourcebroker_adaptor_GATJobCPI_Stop
00569  *
00570  *  The function resourcebroker_adaptor_GATJobCPI_Stop stops the GATJob. Upon a 
00571  *  successful call to this operation, the processes associated with the GATJob 
00572  *  are forcibly terminated. This operation can only be called on a GATJob in 
00573  *  the #GATJobState_Running state.
00574  *
00575  *  @param data Adaptor-provided data object.
00576  *  @param instance_data The instance data of this CPI object.
00577  *
00578  *  @return An error code.
00579  */
00580 static GATResult 
00581 resourcebroker_adaptor_GATJobCPI_Stop(void *data, 
00582   GATJobCPI_Instance const *instance_data)
00583 {
00584   return GAT_NOTIMPL;
00585 }
00586 
00587 /** resourcebroker_adaptor_GATJobCPI_GetJobDescription
00588  *
00589  *  The function resourcebroker_adaptor_GATJobCPI_GetJobDescription returns the 
00590  *  GATJobDescription instance used to create that GATJob instance.
00591  *
00592  *  @param data Adaptor-provided data object.
00593  *  @param instance_data The instance data of this CPI object.
00594  *  @param jd The pointer to a variable, which should receive the associated 
00595  *        job description.
00596  *
00597  *  @return An error code.
00598  */
00599 static GATResult 
00600 resourcebroker_adaptor_GATJobCPI_GetJobDescription(void *data, 
00601   GATJobCPI_Instance const *instance_data, GATJobDescription_const *jd)
00602 {
00603   GAT_USES_STATUS(instance_data->context, 
00604     "resourcebroker_adaptor_GATJobCPI_GetJobDescription");
00605 
00606   if (NULL != jd)
00607   {
00608     *jd = ((GATJobCPIInstance_Data *)instance_data->instance_data)->description;
00609   }
00610   else
00611   {
00612     GAT_CREATE_STATUS(GAT_INVALID_PARAMETER);
00613   }
00614   return GAT_RETURN_STATUS();
00615 }
00616   
00617 /** resourcebroker_adaptor_GATJobCPI_GetInfo
00618  *
00619  *  The function resourcebroker_adaptor_GATJobCPI_GetInfo returns an instance 
00620  *  of the class GATTable, which contains the essential information about the 
00621  *  GATJob object, such as the host name, the schedule time, the start time, 
00622  *  the stop time, whether the GATJob is checkpointable etc.
00623  *
00624  *  @param data Adaptor-provided data object.
00625  *  @param instance_data The instance data of this CPI object.
00626  *  @param jobinfo The pointer to a variable, which should receive the returned
00627  *        GATTable containing the job information.
00628  *
00629  *  @return An error code.
00630  */
00631 static GATResult 
00632 resourcebroker_adaptor_GATJobCPI_GetInfo(void *data, 
00633   GATJobCPI_Instance const *instance_data, GATTable_const *jobinfo)
00634 {
00635   GAT_USES_STATUS(instance_data->context, 
00636     "resourcebroker_adaptor_GATJobCPI_GetInfo");
00637 
00638   if (NULL != jobinfo)
00639   {
00640     *jobinfo = ((GATJobCPIInstance_Data *)instance_data->instance_data)->parameters;
00641   }
00642   else
00643   {
00644     GAT_CREATE_STATUS(GAT_INVALID_PARAMETER);
00645   }
00646   return GAT_RETURN_STATUS();
00647 }
00648   
00649 /** resourcebroker_adaptor_GATJobCPI_GetJobID
00650  *
00651  *  The function resourcebroker_adaptor_GATJobCPI_GetJobID returns the job id, 
00652  *  a globally unique identifier for the represented process corresponding to 
00653  *  this instance. This operation SHOULD be called on a GATJob instance only 
00654  *  when the instance is in a GAT Running or GAT Scheduled state, otherwise 
00655  *  an error will be issued.
00656  *
00657  *  @param data Adaptor-provided data object.
00658  *  @param instance_data The instance data of this CPI object.
00659  *  @param jobid The pointer to a variable, which should receive the resulting 
00660  *        job id.
00661  *
00662  *  @return An error code.
00663  */
00664 static GATResult 
00665 resourcebroker_adaptor_GATJobCPI_GetJobID(void *data, 
00666   GATJobCPI_Instance const *instance_data, GATJobID_const *jobid)
00667 {
00668   GAT_USES_STATUS(instance_data->context, 
00669     "resourcebroker_adaptor_GATJobCPI_GetJobID");
00670 
00671   if (NULL != jobid)
00672   {
00673     *jobid = instance_data->jobid;
00674   }
00675   else
00676   {
00677     GAT_CREATE_STATUS(GAT_INVALID_PARAMETER);
00678   }
00679   return GAT_RETURN_STATUS();
00680 }
00681   
00682 /** resourcebroker_adaptor_GATJobCPI_GetStatus
00683  *
00684  *  The function resourcebroker_adaptor_GATJobCPI_GetStatus SHOULD provide a 
00685  *  GATStatus instance which gives further information as to the cause of the 
00686  *  error, if the job is in the GAT SubmissionError state.
00687  *
00688  *  @param data Adaptor-provided data object.
00689  *  @param instance_data The instance data of this CPI object.
00690  *  @param status The variable, which should receive the associated GATStatus
00691  *        object.
00692  *
00693  *  @return An error code.
00694  */
00695 static GATResult 
00696 resourcebroker_adaptor_GATJobCPI_GetStatus(void *data, 
00697   GATJobCPI_Instance const *instance_data, GATStatus_const *jobstatus)
00698 {
00699   GAT_USES_STATUS(instance_data->context, 
00700     "resourcebroker_adaptor_GATJobCPI_GetStatus");
00701 
00702   if (NULL != jobstatus)
00703   {
00704     *jobstatus = ((GATJobCPIInstance_Data *)instance_data->instance_data)->status;
00705   }
00706   else
00707   {
00708     GAT_CREATE_STATUS(GAT_INVALID_PARAMETER);
00709   }
00710   return GAT_RETURN_STATUS();
00711 }