GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATResourceBrokerCPI.h

Go to the documentation of this file.
00001 /** @file GATResourceBrokerCPI.h
00002  *  Header file for the GATResourceBrokerCPI class.
00003  *
00004  *  A GATResourcebrokerCPI encapsulates all the methods that a 
00005  *  GATResourceBroker capability provider provides.
00006  *
00007  *  @date Thu Oct 23 2003
00008  *
00009  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATResourceBrokerCPI.h,v 1.11 2004/03/24 19:30:58 hartmutkaiser Exp $
00010  *
00011  *  Copyright (C) Hartmut Kaiser
00012  *  This file is part of the GAT Engine.
00013  *  Contributed by Hartmut Kaiser <hartmutkaiser [at] t-online [dot] de>.
00014  *
00015  *  Use, modification and distribution is subject to the Gridlab Software
00016  *  License. (See accompanying file GLlicense.txt or copy at
00017  *  http://www.gridlab.org/GLlicense.txt)
00018  */
00019 
00020 #if !defined(_GATRESOURCEBROKERCPI_H_)
00021 #define _GATRESOURCEBROKERCPI_H_
00022 
00023 typedef struct GATResourceBrokerCPI_S *GATResourceBrokerCPI;
00024 
00025 #include "GATContext.h"
00026 #include "GATPreferences.h"
00027 #include "GATResource.h"
00028 #include "GATResourceDescription.h"
00029 #include "GATReservation.h"
00030 #include "GATTime.h"
00031 #include "GATTimePeriod.h"
00032 #include "GATJob.h"
00033 #include "GATJobDescription.h"
00034 #include "GATResourceBroker.h"
00035 
00036 /* Versioning constants for the GATResourceBrokerCPI_Data struct */
00037 #define GATRESOURCEBROKERCPI_VERSION1 1 
00038 
00039 /* the newest version we know of */
00040 #define GATRESOURCEBROKERCPI_VERSION  GATRESOURCEBROKERCPI_VERSION1
00041 
00042 /**
00043  *  The @c #GATResourceBrokerCPI_Instance structure holds all data items supplied 
00044  *  by the client during the construction of the corresponding GAT object.
00045  */
00046 typedef struct 
00047 {
00048   GATContext context;   /* the GAT context to use for all GATFile operations */
00049   GATString vo_name;    /* of the virtual organisation to use */
00050 
00051   void *instance_data;    /* eventually supplied CPI provider instance data */
00052 } GATResourceBrokerCPI_Instance;
00053 
00054 
00055 /* prototypes for the adapter callback functions */
00056 typedef void (*GATResourceBrokerCPI_Adaptor_Destroy)(void *);
00057 
00058 typedef GATResult (*GATResourceBrokerCPI_Adaptor_ServiceActions)(void *, 
00059   GATResourceBrokerCPI_Instance *, GATTimePeriod_const);
00060 
00061 /* instance specific functions */
00062 typedef void (*GATResourceBrokerCPI_Adaptor_DestroyInstance)(void *, 
00063   GATResourceBrokerCPI_Instance *);
00064 
00065 typedef GATResult (*GATResourceBrokerCPI_Adaptor_CreateInstance)(void *, 
00066   GATResourceBrokerCPI_Instance *);
00067 
00068 typedef GATResult (*GATResourceBrokerCPI_Adaptor_CloneInstance)(void *, 
00069   GATResourceBrokerCPI_Instance const *, GATResourceBrokerCPI_Instance *);
00070 
00071 typedef GATResult (*GATResourceBrokerCPI_Adaptor_EqualsInstance)(void *, 
00072   GATResourceBrokerCPI_Instance const *, GATResourceBrokerCPI_Instance const *, 
00073   GATBool *);
00074 
00075 
00076 /* CPI specific API */
00077 typedef GATResult (*GATResourceBrokerCPI_Adaptor_ReserveResource_Description)(
00078   void *, GATResourceBrokerCPI_Instance const *, GATResourceDescription_const, 
00079   GATTime_const, GATTimePeriod_const, GATReservation *);
00080 
00081 typedef GATResult (*GATResourceBrokerCPI_Adaptor_ReserveResource)(
00082   void *,  GATResourceBrokerCPI_Instance const *, GATResource_const, 
00083   GATTime_const, GATTimePeriod_const, GATReservation *);
00084 
00085 typedef GATResult (*GATResourceBrokerCPI_Adaptor_FindResources)(
00086   void *, GATResourceBrokerCPI_Instance const *, GATResourceDescription_const, 
00087   GATList_GATResource *);
00088 
00089 typedef GATResult (*GATResourceBrokerCPI_Adaptor_SubmitJob)(
00090   void *,  GATResourceBrokerCPI_Instance const *, GATJobDescription_const, 
00091   GATJob *);
00092 
00093 
00094 /* CPI data passed from the adaptor while registering the CPI */
00095 typedef struct
00096 {
00097   /* CPI data (type local data) */
00098   void *data;
00099   GATResourceBrokerCPI_Adaptor_Destroy destroy;
00100   GATResourceBrokerCPI_Adaptor_ServiceActions service_actions;
00101   
00102   /* CPI instance data */
00103   GATResourceBrokerCPI_Adaptor_CreateInstance create_instance;
00104   GATResourceBrokerCPI_Adaptor_DestroyInstance destroy_instance;
00105   GATResourceBrokerCPI_Adaptor_CloneInstance clone_instance;
00106   GATResourceBrokerCPI_Adaptor_EqualsInstance equals_instance;
00107 
00108   /* CPI functionality */
00109   GATResourceBrokerCPI_Adaptor_ReserveResource_Description reserve_description;
00110   GATResourceBrokerCPI_Adaptor_ReserveResource reserve;
00111   GATResourceBrokerCPI_Adaptor_FindResources find_resources;
00112   GATResourceBrokerCPI_Adaptor_SubmitJob submit_job;
00113 } GATResourceBrokerCPI_Data;
00114 
00115 #ifdef __cplusplus
00116 extern "C" {
00117 #endif
00118 
00119 /* Adaptor API */
00120 
00121 /** GATResourceBrokerCPI_Create
00122  *  The  GATResourceBrokerCPI constructor.
00123  *  new_cpi is the constructor for GATResourceBrokerCPI objects.
00124  *  
00125  *  @param version Version of the GATResourceBrokerCPI_Data structure
00126  *  @param data Pointer to adaptor CPI instance data structure.
00127  *
00128  * @return A new GATResourceBrokerCPI
00129  */
00130 GATResourceBrokerCPI GATResourceBrokerCPI_Create(unsigned long int version,
00131   GATResourceBrokerCPI_Data *data);
00132 
00133 
00134 /* API internal to the GAT engine */
00135 
00136 /** GATResourceBrokerCPI_Destroy
00137  *  @brief The GATResourceBrokerCPI destructor.
00138  *
00139  *  This is the destructor for GATResourceBrokerCPI objects.
00140  *
00141  *  @param this An old GATResourceBrokerCPI
00142  */
00143 void GATResourceBrokerCPI_Destroy(GATResourceBrokerCPI *cpi);
00144 
00145 /* CPI instance specific functions */
00146 
00147 /** GATResourceBrokerCPI_CreateInstance
00148  *  @brief Create a new CPI object instance
00149  *
00150  *  Calls the adaptor to create a new CPI object instance.
00151  *
00152  *  @param this The CPI object.
00153  *  @param context a GATContext
00154  *  @param instance_data The instance data of the attached CPI object
00155  *
00156  *  @return An error code.
00157  */
00158 GATResult GATResourceBrokerCPI_CreateInstance(GATResourceBrokerCPI cpi, 
00159   GATResourceBrokerCPI_Instance *instance_data);
00160   
00161 /** GATResourceBrokerCPI_DestroyInstance
00162  *  @brief Create a new CPI object instance
00163  *
00164  *  Calls the adaptor to destroy a CPI object instance.
00165  *
00166  *  @param this The CPI object.
00167  *  @param instance_data The instance data of the attached CPI object
00168  */
00169 void GATResourceBrokerCPI_DestroyInstance(GATResourceBrokerCPI cpi, 
00170   GATResourceBrokerCPI_Instance *instance_data);
00171 
00172 /** GATResourceBrokerCPI_CloneInstance
00173  *  @brief Clones a CPI object instance.
00174  *
00175  *  Calls the adaptor to clone a CPI object instance.
00176  *
00177  *  @param this The CPI object.
00178  *  @param instance_data The instance data of the CPI object to clone.
00179  *  @param new_instance_data The new instance data is to be returned here.
00180  *
00181  *  @return An error code.
00182  */
00183 GATResult GATResourceBrokerCPI_CloneInstance(GATResourceBrokerCPI cpi, 
00184   GATResourceBrokerCPI_Instance const *instance_data,
00185   GATResourceBrokerCPI_Instance *new_instance_data);
00186 
00187 /** GATResourceBrokerCPI_EqualsInstance
00188  *  @brief Compares two CPI object instances.
00189  *
00190  *  Calls the adaptor to compare two CPI object instances.
00191  *
00192  *  @param this The CPI object.
00193  *  @param lhs The instance data of the left CPI object
00194  *  @param rhs The instance data of the right CPI object
00195  *  @param isequal The pointer to the variable, where the result is to be 
00196  *        returned to.
00197  *
00198  *  @return An error code.
00199  */
00200 GATResult GATResourceBrokerCPI_EqualsInstance(GATResourceBrokerCPI cpi, 
00201   GATResourceBrokerCPI_Instance const *lhs, 
00202   GATResourceBrokerCPI_Instance const *rhs, GATBool *isequal);
00203 
00204 
00205 /* CPI specific API */
00206 
00207 /** GATResourceBrokerCPI_ReserveResource_Description
00208  *  @brief Reserve a resource, which mets the description.
00209  *
00210  *  Call the adaptor to allocate a reservation
00211  *
00212  *  @param broker The ResourceBroker CPI object.
00213  *  @param instance_data The instance data of the CPI object to clone.
00214  *  @param description The ResourceDescription to use to select the appropriate
00215  *        resource.
00216  *  @param time The (optional) time, when the reservation has to start
00217  *  @param duration The (optional) time period for which to reserve the 
00218  *        resource.
00219  *  @param reservation The pointer to the GATReservation variable to use to 
00220  *        return the resulting reservation.
00221  *
00222  *  @return An error value.
00223  */
00224 GATResult 
00225 GATResourceBrokerCPI_ReserveResource_Description(GATResourceBrokerCPI broker, 
00226   GATResourceBrokerCPI_Instance const *instance_data, 
00227   GATResourceDescription_const description, GATTime_const zeit, 
00228   GATTimePeriod_const duration, GATReservation *reservation);
00229 
00230 /** GATResourceBrokerCPI_ReserveResource
00231  *  @brief Reserve a given resource.
00232  *
00233  *  Call the adaptor to allocate a reservation
00234  *
00235  *  @param broker The ResourceBroker CPI object.
00236  *  @param instance_data The instance data of the CPI object to clone.
00237  *  @param resource The resource to reserve.
00238  *  @param time The (optional) time, when the reservation has to start
00239  *  @param duration The (optional) time period for which to reserve the 
00240  *        resource.
00241  *  @param reservation The pointer to the GATReservation variable to use to 
00242  *        return the resulting reservation.
00243  *
00244  *  @return An error value.
00245  */
00246 GATResult 
00247 GATResourceBrokerCPI_ReserveResource(GATResourceBrokerCPI broker, 
00248   GATResourceBrokerCPI_Instance const *instance_data, 
00249   GATResource_const resource, GATTime_const zeit, 
00250   GATTimePeriod_const duration, GATReservation *reservation);
00251 
00252 /** GATResourceBrokerCPI_FindResources
00253  *  @brief Find a list of matching resources.
00254  *
00255  *  Call the adaptor to find a list of resources matching the given resource 
00256  *  description.
00257  *
00258  *  @param broker The ResourceBroker CPI object.
00259  *  @param instance_data The instance data of the CPI object to clone.
00260  *  @param description The resource description to match.
00261  *  @param resources The pointer to the GATList_GATResource variable to use to 
00262  *        return the resulting list of resources.
00263  *
00264  *  @return An error value.
00265  */
00266 GATResult
00267 GATResourceBrokerCPI_FindResources(GATResourceBrokerCPI broker,
00268   GATResourceBrokerCPI_Instance const *instance_data, 
00269   GATResourceDescription_const description, GATList_GATResource *resources);
00270 
00271 /** GATResourceBrokerCPI_SubmitJob
00272  *  @brief Submit a new job.
00273  *
00274  *  Call the adaptor to submit a new job to a resource.
00275  *
00276  *  @param broker The ResourceBroker CPI object.
00277  *  @param instance_data The instance data of the CPI object to clone.
00278  *  @param description The resource description to match.
00279  *  @param resources The pointer to the GATJob variable to use to 
00280  *        return the resulting job.
00281  *
00282  *  @return An error value.
00283  */
00284 GATResult 
00285 GATResourceBrokerCPI_SubmitJob(GATResourceBrokerCPI broker,
00286   GATResourceBrokerCPI_Instance const *instance_data, 
00287   GATJobDescription_const description, GATJob *job);
00288   
00289 #ifdef __cplusplus
00290 } /* extern "C" */
00291 #endif
00292 
00293 #endif /* !defined(_GATRESOURCEBROKERCPI_H_) */
00294