GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

resourcebroker_adaptor.c

Go to the documentation of this file.
00001 /** @file resourcebroker_adaptor.c
00002  *  Source file for the resourcebroker_adaptor class.
00003  *
00004  *  @date Thu Oct 23 2003
00005  *
00006  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/adaptors/resourcebroker/resourcebroker_adaptor.c,v 1.7 2004/04/26 12:29:57 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 static const char *rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/adaptors/resourcebroker/resourcebroker_adaptor.c,v 1.7 2004/04/26 12:29:57 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 
00027 #include "resourcebroker.h"
00028 #include "reservation.h"
00029 #include "resource.h"
00030 #include "job.h"
00031 #include "self.h"
00032 #include "request.h"
00033 
00034 /* Macros */
00035 
00036 /* Structures, unions and enums */
00037 
00038 /* Static function prototypes */
00039 
00040 /* File scope variables */
00041 
00042 /* External functions */
00043 /** resourcebroker_adaptor_register
00044  *  Registers all CPIs this adaptor provides.
00045  *  This function is invoked by the loader in the GATEngine when
00046  *  an instance of this adaptor is loaded.  Each instance has its
00047  *  own private configuration table.
00048  *
00049  *  @param registry The registry the adaptor should register its CPIs with.
00050  *  @param system_config The system configuration table.
00051  *  @param instance_config The configuration table for this instance.
00052  *  @param token An arbitrary token used by the loader to identify this adaptor 
00053  *        instance
00054  *
00055  *  @return An error code.
00056  */
00057 GATResult 
00058 resourcebroker_adaptor_register(GATContext error_context, GATRegistry registry, 
00059   GATTable_const system_config, GATTable_const instance_config, void *token)
00060 {
00061   GAT_USES_STATUS(error_context, "resourcebroker_adaptor_register");
00062 
00063   if (!GATVERSION_ISCOMPATIBLE())
00064   {
00065     GAT_CREATE_STATUS(GAT_UNKNOWN_VERSION);
00066   }
00067   else
00068   {
00069     int load_resourcebroker_cpi = 0;
00070     int load_reservation_cpi = 0;
00071     int load_resource_cpi = 0;
00072     int load_job_cpi = 0;
00073     int load_self_cpi = 0;
00074     int load_request_cpi = 0;
00075     
00076     /* Check if the user has disabled the creation of a ResourceBrokerCPI */
00077     GATResult retval = GATTable_Get_int(instance_config, "ResourceBroker", 
00078       &load_resourcebroker_cpi);
00079     if (GAT_SUCCESS != retval)
00080     {
00081       load_resourcebroker_cpi = 1;
00082     }
00083 
00084     /* Check if the user has disabled the creation of a ReservationCPI */
00085     retval = GATTable_Get_int(instance_config, "Reservation", 
00086       &load_reservation_cpi);
00087     if (GAT_SUCCESS != retval)
00088     {
00089       load_reservation_cpi = 1;
00090     }
00091 
00092     /* Check if the user has disabled the creation of a ResourceCPI */
00093     retval = GATTable_Get_int(instance_config, "Resource", &load_resource_cpi);
00094     if (GAT_SUCCESS != retval)
00095     {
00096       load_resource_cpi = 1;
00097     }
00098 
00099     /* Check if the user has disabled the creation of a JobCPI */
00100     retval = GATTable_Get_int(instance_config, "Job", &load_job_cpi);
00101     if (GAT_SUCCESS != retval)
00102     {
00103       load_job_cpi = 1;
00104     }
00105 
00106     /* Check if the user has disabled the creation of a SelfCPI */
00107     retval = GATTable_Get_int(instance_config, "Self", &load_self_cpi);
00108     if (GAT_SUCCESS != retval)
00109     {
00110       load_self_cpi = 1;
00111     }
00112 
00113     /* Check if the user has disabled the creation of a SelfCPI */
00114     retval = GATTable_Get_int(instance_config, "Request", &load_request_cpi);
00115     if (GAT_SUCCESS != retval)
00116     {
00117       load_request_cpi = 1;
00118     }
00119 
00120     /* load CPI's if appropriate */
00121     retval = GAT_SUCCESS;
00122     if (load_resourcebroker_cpi)
00123     {
00124       GAT_CREATE_STATUS(resourcebroker_adaptor_Register_GATResourceBrokerCPI(
00125         error_context, registry, system_config, instance_config, token));
00126     }
00127     if (GAT_SUCCEEDED(GAT_CURRENT_STATUS()) && load_reservation_cpi)
00128     {
00129       GAT_CREATE_STATUS(resourcebroker_adaptor_Register_GATReservationCPI(
00130         error_context, registry, system_config, instance_config, token));
00131     }
00132     if (GAT_SUCCEEDED(GAT_CURRENT_STATUS()) && load_resource_cpi)
00133     {
00134       GAT_CREATE_STATUS(resourcebroker_adaptor_Register_GATResourceCPI(
00135         error_context, registry, system_config, instance_config, token));
00136     }
00137     if (GAT_SUCCEEDED(GAT_CURRENT_STATUS()) && load_job_cpi)
00138     {
00139       GAT_CREATE_STATUS(resourcebroker_adaptor_Register_GATJobCPI(
00140         error_context, registry, system_config, instance_config, token));
00141     }
00142     if (GAT_SUCCEEDED(GAT_CURRENT_STATUS()) && load_self_cpi)
00143     {
00144       GAT_CREATE_STATUS(resourcebroker_adaptor_Register_GATSelfCPI(
00145         error_context, registry, system_config, instance_config, token));
00146     }
00147     if (GAT_SUCCEEDED(GAT_CURRENT_STATUS()) && load_request_cpi)
00148     {
00149       GAT_CREATE_STATUS(resourcebroker_adaptor_Register_GATRequestCPI(
00150         error_context, registry, system_config, instance_config, token));
00151     }
00152   }
00153   return GAT_RETURN_STATUS();
00154 }
00155 
00156 
00157 /* Local functions */