# Presentation: 423179

## G-API BoF (APME Area)Grid Application Programming Interface 

- Ian Taylor (U-Cardiff)
- Stephen Pickles (U-Manchester)
- Tom Goodale (LSU)
- Andre Merzky (ZIB)

## Outline

- Motivation
- Present / Discuss Charter Draft
- The Seven Questions...
- Organization of WG
- Organization of Doc writing

## Motivation

- Application Programmer Scenario (Ian Taylor)

## Pseudo Code

- Target Languages:
- Fortran
- C
- C++
- Java

## Copy a File  --  Globus / Gass

- int CopyFile (const char* source,
-               const char* target)
- {
-   globus_result_t                    result;
-   globus_url_t                       source_url;
-   globus_io_handle_t                 dest_io_handle;
-   globus_ftp_client_operationattr_t  source_ftp_attr;
-   globus_gass_transfer_requestattr_t source_gass_attr;
-   globus_gass_copy_attr_t            source_gass_copy_attr;
-   globus_gass_copy_handle_t          gass_copy_handle;
-   globus_gass_copy_handleattr_t      gass_copy_handleattr;
-   globus_ftp_client_handleattr_t     ftp_handleattr;
-   globus_io_attr_t                   io_attr;
-   int                                output_file = -1;
-   if ( globus_url_parse (source_URL, &source_url) != GLOBUS_SUCCESS )
-   {
-     printf ("can not parse source_URL \"%s\"\n", source_URL);
-     return (-1);
-   }

##   if ( source_url.scheme_type != GLOBUS_URL_SCHEME_GSIFTP &&

-        source_url.scheme_type != GLOBUS_URL_SCHEME_FTP    &&
-        source_url.scheme_type != GLOBUS_URL_SCHEME_HTTP   &&
-        source_url.scheme_type != GLOBUS_URL_SCHEME_HTTPS  )
-   {
-     printf ("can not copy from %s - unsupported protocol\n", source_URL);
-     return (-1);
-   }
-   globus_gass_copy_handleattr_init  (&gass_copy_handleattr);
-   globus_gass_copy_attr_init        (&source_gass_copy_attr);
-   globus_ftp_client_handleattr_init (&ftp_handleattr);
-   globus_io_fileattr_init           (&io_attr);
-   globus_gass_copy_attr_set_io      (&source_gass_copy_attr, &io_attr);
-   globus_gass_copy_handleattr_set_ftp_attr
-                                     (&gass_copy_handleattr, &ftp_handleattr);
-   globus_gass_copy_handle_init      (&gass_copy_handle, &gass_copy_handleattr);
-   if (source_url.scheme_type == GLOBUS_URL_SCHEME_GSIFTP ||
-       source_url.scheme_type == GLOBUS_URL_SCHEME_FTP    )
-   {
-     globus_ftp_client_operationattr_init  (&source_ftp_attr);
-     globus_gass_copy_attr_set_ftp         (&source_gass_copy_attr,
-                                            &source_ftp_attr);
-   }
-   else
-   {
-     globus_gass_transfer_requestattr_init (&source_gass_attr, source_url.scheme);
-     globus_gass_copy_attr_set_gass        (&source_gass_copy_attr,
-                                            &source_gass_attr);
-   }

##   output_file = globus_libc_open ((char*) target, O_WRONLY | O_TRUNC | O_CREAT,

-   output_file = globus_libc_open ((char*) target, O_WRONLY | O_TRUNC | O_CREAT,
-                                         S_IRUSR  | S_IWUSR | S_IRGRP | S_IWGRP);
-   if ( output_file == -1 )
-   {
-     printf ("could not open the destination file \"%s\"\n", target);
-     return (-1);
-   }
-   if ( globus_io_file_posix_convert (output_file, GLOBUS_NULL, &dest_io_handle)
-        != GLOBUS_SUCCESS)
-   {
-     printf ("Error converting the file handle\n");
-     return (-1);
-   }
-   result = globus_gass_copy_register_url_to_handle (
-                &gass_copy_handle,
-                (char*)source_URL,
-                &source_gass_copy_attr,
-                &dest_io_handle,
-                my_callback,
-                NULL);
-   if ( result != GLOBUS_SUCCESS )
-   {
-     printf ("error: %s\n", globus_object_printable_to_string (globus_error_get (result)));
-     return (-1);
-   }
-   globus_url_destroy  (&source_url);
-   return (0);
- }

## Copy a File  –  OGSA

- Package org.globus.ogsa.gui;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.net.URL;
- import java.util.Date;
- import java.util.Vector;
- import javax.xml.rpc.Stub;
- import org.apache.axis.message.MessageElement;
- import org.apache.axis.utils.XMLUtils;
- import org.globus.axis.gsi.GSIConstants;
- import org.globus.ogsa.ServiceProperties;
- import org.globus.ogsa.base.multirft.MultiFileRFTDefinitionServiceGridLocator;
- import org.globus.ogsa.base.multirft.RFTOptionsType;
- import org.globus.ogsa.base.multirft.RFTPortType;
- import org.globus.ogsa.base.multirft.TransferRequestElement;
- import org.globus.ogsa.base.multirft.TransferRequestType;
- import org.globus.ogsa.base.multirft.TransferType;

## import org.globus.ogsa.impl.security.authentication.Constants;

- import org.globus.ogsa.impl.security.authorization.NoAuthorization;
- import org.globus.ogsa.utils.AnyHelper;
- import org.globus.ogsa.utils.GetOpts;
- import org.globus.ogsa.utils.GridServiceFactory;
- import org.globus.ogsa.utils.MessageUtils;
- import org.gridforum.ogsi.ExtendedDateTimeType;
- import org.gridforum.ogsi.ExtensibilityNotSupportedFaultType;
- import org.gridforum.ogsi.ExtensibilityType;
- import org.gridforum.ogsi.ExtensibilityTypeFaultType;
- import org.gridforum.ogsi.Factory;
- import org.gridforum.ogsi.HandleType;
- import org.gridforum.ogsi.InfinityType;
- import org.gridforum.ogsi.LocatorType;
- import org.gridforum.ogsi.OGSIServiceGridLocator;
- import org.gridforum.ogsi.ServiceAlreadyExistsFaultType;
- import org.gridforum.ogsi.TerminationTimeType;
- import org.gridforum.ogsi.WSDLReferenceType;
- import org.gridforum.ogsi.holders.ExtensibilityTypeHolder;
- import org.gridforum.ogsi.holders.LocatorTypeHolder;
- import org.gridforum.ogsi.holders.TerminationTimeTypeHolder;
- import org.globus.gsi.proxy.IgnoreProxyPolicyHandler;
- import org.w3c.dom.Document;
- import org.w3c.dom.Element;

## public class RFTClient {

-   public static void copy (String source_url, String target_url)
-   {
-     try {
-       File requestFile      = new File (source_url);
-       BufferedReader reader = null;
-       try  {
-         reader = new BufferedReader (new FileReader (requestFile));
-       }  catch (java.io.FileNotFoundException fnfe) { }
-       Vector requestData = new Vector ();
-       requestData.add (target_url);
-       TransferType[] transfers1           = new TransferType[transferCount];
-       RFTOptionsType multirftOptions = new RFTOptionsType ();
-       multirftOptions.setBinary           (Boolean.valueOf  (
-             (String)requestData.elementAt (0)).booleanValue ());
-       multirftOptions.setBlockSize        (Integer.valueOf  (
-             (String)requestData.elementAt (1)).intValue     ());
-       multirftOptions.setTcpBufferSize    (Integer.valueOf  (
-             (String)requestData.elementAt (2)).intValue     ());
-       multirftOptions.setNotpt            (Boolean.valueOf  (
-             (String)requestData.elementAt (3)).booleanValue ());
-       multirftOptions.setParallelStreams  (Integer.valueOf  (
-             (String)requestData.elementAt (4)).intValue     ());
-       multirftOptions.setDcau(Boolean.valueOf(
-             (String)requestData.elementAt (5)).booleanValue ());

##       int i = 7;

-       for (int j = 0; j < transfers1.length; j++)
-       {
-         transfers1[j] = new TransferType ();
-         transfers1[j].setTransferId       (j);
-         transfers1[j].setSourceUrl        ((String)requestData.elementAt (i++));
-         transfers1[j].setDestinationUrl ((String)requestData.elementAt (i++));
-         transfers1[j].setRftOptions       (multirftOptions);
-       }
-       TransferRequestType transferRequest = new TransferRequestType ();
-       transferRequest.setTransferArray (transfers1);
-       int concurrency = Integer.valueOf
-                        ((String)requestData.elementAt(6)).intValue();
-       if (concurrency > transfers1.length)
-       {
-         System.out.println ("Concurrency should be less than the number"
-                                       "of transfers in the request");
-         System.exit (0);
-       }

##       transferRequest.setConcurrency (concurrency);

-       TransferRequestElement requestElement = new TransferRequestElement ();
-       requestElement.setTransferRequest (transferRequest);
-       ExtensibilityType extension = new ExtensibilityType ();
-       extension = AnyHelper.getExtensibility (requestElement);
-       OGSIServiceGridLocator factoryService = new OGSIServiceGridLocator ();
-       Factory factory = factoryService.getFactoryPort (new URL (source_url));
-       GridServiceFactory gridFactory = new GridServiceFactory (factory);
-       LocatorType locator = gridFactory.createService (extension);
-       System.out.println ("Created an instance of Multi-RFT");
-       MultiFileRFTDefinitionServiceGridLocator loc
-                           = new MultiFileRFTDefinitionServiceGridLocator ();
-       RFTPortType rftPort = loc.getMultiFileRFTDefinitionPort  (locator);
-       ((Stub)rftPort)._setProperty (Constants.AUTHORIZATION,
-                                     NoAuthorization.getInstance());
-       ((Stub)rftPort)._setProperty (GSIConstants.GSI_MODE,
-                                     GSIConstants.GSI_MODE_FULL_DELEG);
-       ((Stub)rftPort)._setProperty (Constants.GSI_SEC_CONV,
-                                     Constants.SIGNATURE);
-       ((Stub)rftPort)._setProperty (Constants.GRIM_POLICY_HANDLER,
-                                     new IgnoreProxyPolicyHandler ());
-     } catch (Exception e)  { System.err.println (MessageUtils.toString (e)); } } }

## Copy a File  –  G-API

- #include <GAPI.h>
- int CopyFile (const char* source_url,
-               const char* target_url)
- {
-   try
-   {
-     GAPI_File *file = new GAPI_File (source_url);
-     file->copy (target_url);
-   }
-   catch (GATException e)
-   {
-     printf  (e.ErrorString ());
-     return  (e.ErrorCode   ());
-   }
-   return (0);
- }

## Coverage of API

- What Aspects covered
- Files and Streams
- Job submission
- Monitoring
- Steering
- ...
- What Aspects NOT covered
- MPI
- RPC
- ...

## Draft Charter

***Draft Charter***

## In the Grid community the demand for real applications using the emerging Grid infrastructure is steadily increasing. Over the last years much of the Grid middleware advanced from a purely experimental and research state to mature and widely supported software systems. The complexity of these systems, both in terms of administration and application usability, remains high. One of these aspects, the usability for application programmers, is the focus of this WG.

## The G-API will lower the barrier for scientific application developers to make use of the grid by providing a small, consistent API for the operations of interest.

**It is not, however, a goal of the G-API to cover the full range of interactions of applications with the Grid, or to cover all types of applications using Grids.**

## The G-API aims to simplify the utilisation of Grids for those applications which require a limited subset of Grid capabilities, and whose developers do not want to get involved with Grid technologies in great detail. We believe that this is a common characteristic of a significant fraction of scientific applications.

## The general aim is to free application pro-grammers from the need to directly code against lower level Grid Services or libraries, and the need to integrate complicated and redundant software components reacting on the dynamic nature of Grid environments. With an abstract, application focused Grid API, application programmers will be able to develop portable software which can be effectively deployed in both Grid and traditional environments, and which will be able to take advantage of different middleware and services easily.

## The goals of the group are to specify the needs of application programmers in Grid environments, and hence derive an abstract API specification, and a set of language specific APIs derived from this. The group will promote these APIs as GGF recommendations.

- Typical operations an application developer wants to invoke should be enabled with a minimum of API calls, by hiding complexities such as, for example,
-           -  service discovery and utilisation
-           -  resource management
-           -  QoS issues
-           -  authorisation
-           -  authentication
-           -  ...

## For example, the process of copying of a remote file may involve interaction with a replica location service, a data transport service, a resource management service, and a security service. It may involve communication via LDAP/LDIF, GRAM, HTTP, and GSI, as protocols or protocol extensions. All the application programmer should see are calls very much like:

-           fileCopy (source, destination);
- Although this example is simplified, it illustrates the motivation for our work.

## The APIs specified by this WG will deliver a similar level of abstraction for a range of basic operations which need to be grid aware, such as

- 	- file access
- 	- communication primitives
- 	- process management
- 	- monitoring
- 	- steering
- 	- ...

## Specific Goals

- The WG will work with the application groups to identify these operations, and the languages which should be supported.

***Specific Goals***

## Milestones

- - Use cases and application scenarios survey
- - Requirements document:
-       		- operations which should be supported
-       		- programming languages
-       		- organisation of API documents
-       		       (e.g. one per subsystem, or one complete document)
- - Draft abstract API document(s)
- - Final abstract API document(s)
- - Draft language-specific API document(s)
- - Final language-specific API document(s)

## The Seven Questions

- Focus
- Clarity/Relevance
- Necessity
- Appropriateness
- Overlap
- List of groups
- Critical Mass
- Demand

## Focus

- See Charter:application oriented API for scientific applications

***Clarity / Relevance***

- Simplify development and deployment of scientific applications on the Grid

## Necessity

- We do not know of similar efforts.
- We do know application groups with demand.
- Groups are already working on this.

***Appropriateness******	***

- Clearly Grid-related API.
- Leverages GGF results to End-Users.

## Overlap

- No overlap in Scope !!
- Common aspects with many GGF APIs.
- Need coordination with various GGF groups:
- APPS
- ACE
- Life-Sciences
- Astronomy
- UPDT
- DRMAA
- Grid-RPC
- Grid-CPR
- ...

## Critical Mass

- GridStart: strong support at GS meeting
- RealityGrid: eScience project in UK.
- GridLab: 14 Institutions/Companies all over Europe.
- Support from individuals and projects.
- Support from the APPS-RG in GGF.

***Demand***

- Strong feedback from other EU projects.
- Strong feedback from related apps groups (Environmental, Physics, Biochemistry, Astronomy, ...).
- Gets developed anyway – lets make it Standard!

## Organization of WG

- Charter
- Milestones
- Chair(s)
- Secretar [y,ies]
- Mailing List _[majordomo@ggf.org](mailto:majordomo@ggf.org)_Subscribe gapi-wg
- Web Page
- Next Meeting

## Name of Group

- Grid Application Programming Interface (G-API)
- Grid-Lite
- Application Level Grid Programming Interface
- Grid Capability Abstraction API
- Computational Science API
- ???

## Organization of Doc Writing

- Use Cases and Application Scenario Survey
- G-API requirement specification
- G-API specification