OGSA-DAI Usage

In this discussion we shall have a look at the very basic usage of OGSA-DAI R2 to work with a Relational Database like MySQL.

This discussion assumes that you have already installed MySQL Database Server and OGSA-DAI R2. Installation guides for each of these applications are available here.

For accessing and manipulating the database, an end-to-end client is provided in OGSA-DAI R2. It's source code is available in <ogsadai-src>/src/java/uk/org/ogsadai/client/Client.java. The end-to-end client performs the following operations:

  1. A Grid Data Service Registry (GDSR) is queried to access a list of registered Grid Data Service Factories (GDSFs).
  2. The first GDSF in the list is selected.
  3. The GDSF is called to create a Grid Data Service (GDS) using a GDSF create document provided by the user.
  4. The GDS is passed a GDS Perform document – provided by the user – to perform a database operation and a GDS Response document is received and printed on screen.

Example 1: A simple SQL Query

The following GDS Perform document provides an example of requesting a synchronous retrieve via a JDBC driver.

<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) International Business Machines Corporation, 2002, 2003. (c) University of Edinburgh 2002, 2003.-->
<!-- See OGSA-DAI-Licence.txt for licencing information.-->
 
<gridDataServicePerform xmlns="http://ogsadai.org.uk/P2R2/schemas/gds" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogsadai.org.uk/P2R2/schemas/gds ../../../../src/xsdR2/activities/activities.xsd">

<request name="requestsynch">
    <documentation>Select with data delivered with the response - request stored</documentation>

    <parameter name="tablename">
        <value name="idvalue">MainMemory</value>
    </parameter>
 
    <sqlQueryStatement name="statement">
        <sqlParameter position="1">sharkestra01</sqlParameter>
        <sqlParameter position="2">sharkestra12</sqlParameter>
        <dataResource>Grid_DataResource</dataResource>
        <expression>select * from MainMemory where SubClusterId&gt;? and SubClusterId&lt;? </expression>
        <webRowSetStream name="statementresult"/>
    </sqlQueryStatement>

    <deliverToResponse name="d1">
        <fromLocal from="statementresult"/>
    </deliverToResponse>
</request>

<execute name="executerequestsynch" requestName="requestsynch">
    <withParameter name="tablename">MainMemory</withParameter>
</execute>
</gridDataServicePerform>
 

The end-to-end client is executed as follows:

[12:35] palomar: /u/globus/OGSA_DAI/ogsadai-src % source setenv.csh
[13:32] palomar: /u/globus/OGSA_DAI/ogsadai-src % java uk.org.ogsadai.client.Client -demo http://localhost:8080/ogsa/services/ogsadai/GridDataServiceRegistry /u/globus/OGSA_DAI/ogsadai-src/doc/examples/GDSFCreateService/gdsfCreateExample.xml /u/globus/OGSA_DAI/ogsadai-src/doc/examples/GDSPerform/JDBC/query/request_synch.xml

In the above command,
http://localhost:8080/ogsa/services/ogsadai/GridDataServiceRegistry is the Registry URL
/u/globus/OGSA_DAI/ogsadai-src/doc/examples/GDSFCreateService/gdsfCreateExample.xml is the GDSF Create Document Filename
/u/globus/OGSA_DAI/ogsadai-src/doc/examples/GDSPerform/JDBC/query/request_synch.xml is the GDS Perform Document Filename

Please note that the user has to create the GDS Perform document. Sample GDS Perform documents are provided in the distribution at <ogsadai-src>/doc/examples/GDSPerform.

The corresponding output is shown in output1.txt. Note that the response of the query is in XML format.

Example 2: A simple SQL Update

The following GDS Perform document provides an example of requesting a synchronous update via a JDBC driver.

<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) International Business Machines Corporation, 2002, 2003. (c) University of Edinburgh 2002, 2003.-->
<!-- See OGSA-DAI-Licence.txt for licencing information.-->
<gridDataServicePerform xmlns="http://ogsadai.org.uk/P2R2/schemas/gds"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogsadai.org.uk/P2R2/schemas/gds
./schema/ogsadai/xsdR2/activities/activities.xsd">

    <request name="requestsynch">
        <documentation>SQL Easy Update 1 (for scenario) </documentation>
        <parameter name="tablename">
            <value name="idvalue">Application</value>
        </parameter>

        <sqlUpdateStatement name="statement">
            <sqlParameter position="1">'sparc'</sqlParameter>
            <dataResource>Grid_DataResource</dataResource>
            <expression>update Application set Minosv = Minosv + 1 where Arch=?</expression>
            <resultStream name="statementresult"/>
        </sqlUpdateStatement>

        <deliverToResponse name="d1">
            <fromLocal from="statementresult"/>
        </deliverToResponse>
    </request>

    <execute name="executerequestsynch" requestName="requestsynch">
        <withParameter name="tablename">Application</withParameter>
    </execute>

</gridDataServicePerform>

The end-to-end client is executed as follows:

[12:35] palomar: /u/globus/OGSA_DAI/ogsadai-src % source setenv.csh
[13:32] palomar: /u/globus/OGSA_DAI/ogsadai-src % java uk.org.ogsadai.client.Client -demo http://localhost:8080/ogsa/services/ogsadai/GridDataServiceRegistry /u/globus/OGSA_DAI/ogsadai-src/doc/examples/GDSFCreateService/gdsfCreateExample.xml /u/globus/OGSA_DAI/ogsadai-src/doc/examples/GDSPerform/JDBC/update/request_synch.xml

In the above command,
http://localhost:8080/ogsa/services/ogsadai/GridDataServiceRegistry is the Registry URL
/u/globus/OGSA_DAI/ogsadai-src/doc/examples/GDSFCreateService/gdsfCreateExample.xml is the GDSF Create Document Filename
/u/globus/OGSA_DAI/ogsadai-src/doc/examples/GDSPerform/JDBC/update/request_synch.xml is the GDS Perform Document Filename

Please note that the user has to create the GDS Perform document. Sample GDS Perform documents are provided in the distribution at <ogsadai-src>/doc/examples/GDSPerform.

The corresponding output is shown in output2.txt. Note that the response of the query is in XML format.

 

For more details please refer the official Grid Data Service document provided at the OGSA-DAI website.