GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



next up previous contents
Next: Reserving Resources Up: The Resource Management Package Previous: Constructing and Destroying ResourceBroker   Contents

Finding Resources

As we now have constructed the foundation required to build anything of use with the resource management package, we can move on to the process of actually building on this foundation. The first brick that we will lay in this vein will teach us how to find resources fitting a particular resource description.

To find resources depicted through a particular resource description we use the following function

GATResult
  GATResourceBroker_FindResources(GATResourceBroker broker,
    GATResourceDescription_const description, GATList_GATResource *resources)

The initial argument to this function is a GATResourceBroker identifying the GATResourceBroker which is going to be used to carry-out the search. The second argument is a GATResource Description which describes the resource(s) to be found. The final argument is a pointer to a list of GATResource instances. It is through this pointer that this call returns to the caller a list of the resources found. Finally this function returns a GATResult, covered in Appendix [*], which indicates the completion status of this function.

As a quick example, we can consider using this function to create a function that returns a list of all hardware resources a within a specified virtual organization. A code snippet which works this magic is as follows

GATResult GiveMeItAll( GATString virtualOrg )
{
  GATResult result;
  GATTable table;
  GATContext context;
  GATList_GATResource resources;
  GATResourceBroker resourceBroker;
  GATHardwareResourceDescription hardwareResourceDescription;
  
  result = GAT_MEMORYFAILURE;
  
  context = GATContext_Create();
  if( NULL != context )
  {
    resourceBroker = GATResourceBroker_Create( context, NULL, virtualOrg );
    if( NULL != resourceBroker )
    {
      table = GATTable_Create();
      if( NULL != table )
      {
        hardwareResourceDescription = GATHardwareResourceDescription_Create( table );
        if( NULL != hardwareResourceDescription )
        {
          result = 
            GATResourceBroker_FindResources( resourceBroker, 
                                             hardwareResourceDescription, 
                                             &resources );
          if( GAT_SUCCEEDED( result ) )
          {
            /* Do something with resources! */
          
            GATList_GATResource_Destroy( &resources );
          }
        
          GATHardwareResourceDescription_Destroy( &hardwareResourceDescription );
        }
      
        GATTable_Destroy( &table );
      }
    
      GATResourceBroker_Destroy( &resourceBroker );
    }
  
    GATContext_Destroy( &context );
  }
  
  return result;
}


next up previous contents
Next: Reserving Resources Up: The Resource Management Package Previous: Constructing and Destroying ResourceBroker   Contents
Andre Merzky 2004-05-13