GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATJobCPI.h

Go to the documentation of this file.
00001 /** @file GATJobCPI.h
00002  *  Header file for the GATJobCPI class.
00003  *
00004  *  @date Sat Oct 25 2003
00005  *
00006  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATJobCPI.h,v 1.12 2004/03/24 19:30:58 hartmutkaiser Exp $
00007  *
00008  *  Copyright (C) Hartmut Kaiser
00009  *  This file is part of the GAT Engine.
00010  *  Contributed by Hartmut Kaiser <hartmutkaiser [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 #if !defined(_GATJOBCPI_H_)
00018 #define _GATJOBCPI_H_
00019 
00020 typedef struct GATJobCPI_S *GATJobCPI;
00021 
00022 #include "GATContext.h"
00023 #include "GATPreferences.h"
00024 #include "GATMonitorable.h"
00025 
00026 /* Versioning constants for the GATJobCPI_Data struct */
00027 #define GATJOBCPI_VERSION1 1 
00028 
00029 /* the newest version we know of */
00030 #define GATJOBCPI_VERSION  GATJOBCPI_VERSION1
00031 
00032 /**
00033  *  The @c #GATJobCPI_Instance structure holds all data items supplied 
00034  *  by the client during the construction of the corresponding GAT object.
00035  */
00036 typedef struct 
00037 {
00038   GATContext context;   /* the GAT context to use for all GATFile operations */
00039   GATJobState state;      /* the state of this job */
00040   GATJobID jobid;         /* the job id */
00041   GATBool isdirty;        /* dirty status for the whole object */
00042   GATMonitorable_Impl monitorable;  /* monitoring support */
00043   GATObject_const source; /* the object this CPI is associated with */
00044   void *instance_data;    /* eventually supplied CPI provider instance data */
00045 } GATJobCPI_Instance;
00046 
00047 
00048 /* prototypes for the adapter callback functions */
00049 typedef void (*GATJobCPI_Adaptor_Destroy)(void *);
00050 
00051 typedef GATResult (*GATJobCPI_Adaptor_ServiceActions)(void *, 
00052   GATJobCPI_Instance *, GATTimePeriod_const);
00053 
00054 /* instance specific functions */
00055 typedef void (*GATJobCPI_Adaptor_DestroyInstance)(void *, 
00056   GATJobCPI_Instance *);
00057 
00058 typedef GATResult (*GATJobCPI_Adaptor_CreateInstance)(void *, 
00059   GATJobCPI_Instance *, void *);
00060 
00061 typedef GATResult (*GATJobCPI_Adaptor_CloneInstance)(void *, 
00062   GATJobCPI_Instance const *, GATJobCPI_Instance *);
00063 
00064 typedef GATResult (*GATJobCPI_Adaptor_EqualsInstance)(void *, 
00065   GATJobCPI_Instance const *, GATJobCPI_Instance const *, 
00066   GATBool *);
00067 
00068 
00069 /* CPI specific API */
00070 typedef GATResult (*GATJobCPI_Adaptor_UnSchedule)(void *,
00071   GATJobCPI_Instance const *);
00072 
00073 typedef GATResult (*GATJobCPI_Adaptor_Checkpoint)(void *,
00074   GATJobCPI_Instance const *);
00075 
00076 typedef GATResult (*GATJobCPI_Adaptor_CloneJob)(void *,
00077   GATJobCPI_Instance const *, GATHardwareResource_const, GATJob *);
00078 
00079 typedef GATResult (*GATJobCPI_Adaptor_Migrate)(void *,
00080   GATJobCPI_Instance const *, GATHardwareResource_const, GATJob *);
00081 
00082 typedef GATResult (*GATJobCPI_Adaptor_Stop)(void *,
00083   GATJobCPI_Instance const *);
00084 
00085 typedef GATResult (*GATJobCPI_Adaptor_GetJobDescription)(void *,
00086   GATJobCPI_Instance const *, GATJobDescription_const *jd);
00087 
00088 typedef GATResult (*GATJobCPI_Adaptor_GetInfo)(void *,
00089   GATJobCPI_Instance const *, GATTable_const *jobinfo);
00090 
00091 typedef GATResult (*GATJobCPI_Adaptor_GetJobID)(void *,
00092   GATJobCPI_Instance const *, GATJobID_const *jobid);
00093 
00094 typedef GATResult (*GATJobCPI_Adaptor_GetStatus)(void *,
00095   GATJobCPI_Instance const *, GATStatus_const *jobstatus);
00096 
00097 
00098 /* callback function prototypes for the GATMonitorable interface support */
00099 typedef GATResult (* GATJobCPI_Adaptor_GetMetrics)(void *, 
00100   GATJobCPI_Instance const *, GATList_GATMetric *);
00101 
00102 typedef GATResult (* GATJobCPI_Adaptor_GetMetricEvent)(void *, 
00103   GATJobCPI_Instance const *, GATMetric, GATMetricEvent *); 
00104 
00105 
00106 /* Serialisation API */
00107 typedef GATResult (*GATJobCPI_Adaptor_Serialise)(void *, 
00108   GATJobCPI_Instance const *, GATObject, GATBool);
00109 
00110 typedef GATResult (*GATJobCPI_Adaptor_DeSerialise)(void *, GATObject,
00111   GATJobCPI_Instance *);
00112 
00113 
00114 /* CPI data passed from the adaptor while registering the CPI */
00115 typedef struct
00116 {
00117   /* CPI data (type local data) */
00118   void *data;
00119   GATJobCPI_Adaptor_Destroy destroy;
00120   GATJobCPI_Adaptor_ServiceActions service_actions;
00121   
00122   /* CPI instance data */
00123   GATJobCPI_Adaptor_CreateInstance create_instance;
00124   GATJobCPI_Adaptor_DestroyInstance destroy_instance;
00125   GATJobCPI_Adaptor_CloneInstance clone_instance;
00126   GATJobCPI_Adaptor_EqualsInstance equals_instance;
00127 
00128   /* CPI functionality */
00129   GATJobCPI_Adaptor_UnSchedule unschedule;
00130   GATJobCPI_Adaptor_Checkpoint checkpoint;
00131   GATJobCPI_Adaptor_CloneJob clonejob;
00132   GATJobCPI_Adaptor_Migrate migratejob;
00133   GATJobCPI_Adaptor_Stop stopjob;
00134   GATJobCPI_Adaptor_GetJobDescription get_jobdescription;
00135   GATJobCPI_Adaptor_GetInfo get_jobinfo;
00136   GATJobCPI_Adaptor_GetJobID get_jobid;
00137   GATJobCPI_Adaptor_GetStatus get_status;
00138   
00139   /* CPI monitoring support */
00140   GATJobCPI_Adaptor_GetMetrics get_metrics;
00141   GATJobCPI_Adaptor_GetMetricEvent get_metric_event;
00142 
00143   /* CPI serialisation */
00144   GATJobCPI_Adaptor_Serialise serialise;
00145   GATJobCPI_Adaptor_DeSerialise deserialise;
00146 } GATJobCPI_Data;
00147 
00148 #ifdef __cplusplus
00149 extern "C" {
00150 #endif
00151 
00152 /* Adaptor API */
00153 
00154 /** GATJobCPI_Create
00155  *  The  GATJobCPI constructor.
00156  *  new_cpi is the constructor for GATJobCPI objects.
00157  *  
00158  *  @param version Version of the GATJobCPI_Data structure
00159  *  @param data Pointer to adaptor CPI instance data structure.
00160  *
00161  * @return A new GATJobCPI
00162  */
00163 GATJobCPI GATJobCPI_Create(unsigned long int version,
00164   GATJobCPI_Data *data);
00165 
00166 
00167 /* API internal to the GAT engine */
00168 
00169 /** GATJobCPI_Destroy
00170  *  @brief The GATJobCPI destructor.
00171  *
00172  *  This is the destructor for GATJobCPI objects.
00173  *
00174  *  @param this An old GATJobCPI
00175  */
00176 void GATJobCPI_Destroy(GATJobCPI *cpi);
00177 
00178 /* CPI instance specific functions */
00179 
00180 /** GATJobCPI_CreateInstance
00181  *  @brief Create a new CPI object instance
00182  *
00183  *  Calls the adaptor to create a new CPI object instance.
00184  *
00185  *  @param this The CPI object.
00186  *  @param context a GATContext
00187  *  @param instance_data The instance data of the attached CPI object
00188  *
00189  *  @return An error code.
00190  */
00191 GATResult GATJobCPI_CreateInstance(GATJobCPI cpi, 
00192   GATJobCPI_Instance *instance_data, void *initialisation_data);
00193   
00194 /** GATJobCPI_DestroyInstance
00195  *  @brief Create a new CPI object instance
00196  *
00197  *  Calls the adaptor to destroy a CPI object instance.
00198  *
00199  *  @param this The CPI object.
00200  *  @param instance_data The instance data of the attached CPI object
00201  */
00202 void GATJobCPI_DestroyInstance(GATJobCPI cpi, 
00203   GATJobCPI_Instance *instance_data);
00204 
00205 /** GATJobCPI_EqualsInstance
00206  *  @brief Compares two CPI object instances.
00207  *
00208  *  Calls the adaptor to compare two CPI object instances.
00209  *
00210  *  @param this The CPI object.
00211  *  @param lhs The instance data of the left CPI object
00212  *  @param rhs The instance data of the right CPI object
00213  *  @param isequal The pointer to the variable, where the result is to be 
00214  *        returned to.
00215  *
00216  *  @return An error code.
00217  */
00218 GATResult GATJobCPI_EqualsInstance(GATJobCPI cpi, 
00219   GATJobCPI_Instance const *lhs, GATJobCPI_Instance const *rhs, 
00220   GATBool *isequal);
00221 
00222 /** GATJobCPI_CloneInstance
00223  *  @brief Clones a CPI object instance.
00224  *
00225  *  Calls the adaptor to clone a CPI object instance.
00226  *
00227  *  @param this The CPI object.
00228  *  @param instance_data The instance data of the CPI object to clone.
00229  *  @param new_instance_data The new instance data is to be returned here.
00230  *
00231  *  @return An error code.
00232  */
00233 GATResult GATJobCPI_CloneInstance(GATJobCPI cpi, 
00234   GATJobCPI_Instance const *instance_data,
00235   GATJobCPI_Instance *new_instance_data);
00236 
00237 /* CPI specific API */
00238 
00239 /* TODO: insert the declaration of your CPI specific API functions here */
00240 
00241   
00242 /* GATMonitorable */
00243 
00244 /** GATJobCPI_GetMetrics
00245  *
00246  *  The function GATJobCPI_GetMetrics returns the list of metrics supported
00247  *  by this adaptor.
00248  *
00249  *  @param cpi The CPI object.
00250  *  @param instance_data The instance data of the attached CPI object
00251  *  @param The pointer to the variable, which receives the resulting list of
00252  *        metrics.
00253  *
00254  *  @return An error code.
00255  */
00256 GATResult GATJobCPI_GetMetrics(GATJobCPI cpi, 
00257   GATJobCPI_Instance const *data, GATList_GATMetric *metrics);
00258   
00259 /** GATJobCPI_GetMetricEvent
00260  *
00261  *  The function GATJobCPI_GetMetricEvent returns the metric event, which is 
00262  *  associated with the given metric.
00263  *
00264  *  @param cpi The CPI object.
00265  *  @param instance_data The instance data of the attached CPI object
00266  *  @param metric The continuous metric, for which the metric event is to be 
00267  *        returned. 
00268  *  @param event The pointer to the variable, which receives the resulting
00269  *        metric event.
00270  *
00271  *  @return An error code.
00272  */
00273 GATResult GATJobCPI_GetMetricEvent(GATJobCPI cpi, 
00274   GATJobCPI_Instance const *data, GATMetric metric, 
00275   GATMetricEvent *event);
00276 
00277 
00278 /* Serialisation API */
00279 
00280 /** GATJobCPI_Serialise
00281  *  @brief Serialise the instance data.
00282  *
00283  *  Calls the adaptor to serialise the instance data.
00284  *
00285  *  @param this The CPI object.
00286  *  @param instance_data The instance data of the attached CPI object
00287  *  @param stream The stream to use be used for serialisation.
00288  *  @param clear_dirty If the clear_dirty parameter is set to GATTrue, the 
00289  *        internal dirty flag of this object is to be reset.
00290  *
00291  *  @return An error code.
00292  */
00293 GATResult GATJobCPI_Serialise(GATJobCPI cpi, 
00294   GATJobCPI_Instance const *data, GATObject stream, GATBool clear_dirty);
00295   
00296 /** GATJobCPI_DeSerialise
00297  *  @brief De-serialise the instance data
00298  *
00299  *  Call the adaptor to de-serialise the instance data.
00300  *
00301  *  @param context The GAT context to be used for object construction.
00302  *  @param stream The stream interface to use for the serialisation.
00303  *  @param instance_data The pointer to a variable, which contains the client 
00304  *        data of the new object. The member instance data of this object 
00305  *        may receive the pointer to the new instance data of the CPI object.
00306  *
00307  *  @return An error code.
00308  */
00309 GATResult GATJobCPI_DeSerialise(GATJobCPI cpi, GATObject stream, 
00310   GATJobCPI_Instance *data);
00311 
00312 /* CPI specific API */
00313 GATResult GATJobCPI_UnSchedule(GATJobCPI cpi, GATJobCPI_Instance const *data);
00314 GATResult GATJobCPI_Checkpoint(GATJobCPI cpi, GATJobCPI_Instance const *data);
00315 GATResult GATJobCPI_CloneJob(GATJobCPI cpi, GATJobCPI_Instance const *data,
00316   GATHardwareResource_const hr, GATJob *cloned_job);
00317 GATResult GATJobCPI_Migrate(GATJobCPI cpi, GATJobCPI_Instance const *data,
00318   GATHardwareResource_const hr, GATJob *migrated_job);
00319 GATResult GATJobCPI_Stop(GATJobCPI cpi, GATJobCPI_Instance const *data);
00320 GATResult GATJobCPI_GetJobDescription(GATJobCPI cpi, 
00321   GATJobCPI_Instance const *data, GATJobDescription_const *jd);
00322 GATResult GATJobCPI_GetInfo(GATJobCPI cpi, 
00323   GATJobCPI_Instance const *data, GATTable_const *jobinfo);
00324 GATResult GATJobCPI_GetJobID(GATJobCPI cpi, 
00325   GATJobCPI_Instance const *data, GATJobID_const *jobid);
00326 GATResult GATJobCPI_GetStatus(GATJobCPI cpi, 
00327   GATJobCPI_Instance const *data, GATStatus_const *jobstatus);
00328 
00329 #ifdef __cplusplus
00330 } /* extern "C" */
00331 #endif
00332 
00333 #endif /* !defined(_GATJOBCPI_H_) */
00334