Writing Perform Documents EPCC, University of Edinburgh Amy Krause a.krause@epcc.ed.ac.uk OGSA-DAI Training Workshop - April 2003 Release: P2R2 Talk Outline Writing GDS perform documents 4General structure of perform documents 4Database statements: – – – – – SQL queries and updates Relational Database Management XPath queries XUpdate statements XML:DB Collection Management 4Delivery 4Execute and Terminate 2 OGSA-DAI Training Workshop, Release: P2R2 Structure 4Interface to GDS is documentbased 4GridDataService::perform takes an XML document as input parameter 4GDS perform document allow the user to specify operations/activities 3 OGSA-DAI Training Workshop, Release: P2R2 Content GDS Perform document can contain: 4Named request element: contains the activities AND 4Named execute element: asks to execute a named request OR 4terminate element: asks to terminate a named execute request BUT NOT request without execute 4 OGSA-DAI Training Workshop, Release: P2R2 Example <gridDataServicePerform xmlns="http://ogsadai.org.uk/P2R2/schemas/gds"> <request name="requestsynch"> <documentation> <!-- human readable documentation --> </documentation> <parameter name="textParameter“/> <!-- query statement --> <sqlQueryStatement name="statement"> . . . <!-- delivery instructions --> <deliverToResponse name="d1"> . . . </request> <execute name="execute1" requestName="requestsynch"> <withParametername="textParameter">20</withParameter> </execute> </gridDataServicePerform> 5 OGSA-DAI Training Workshop, Release: P2R2 Perform Documents 6 Request Request Execute Execute Terminate Terminate OGSA-DAI Training Workshop, Release: P2R2 Requests Can contain 4Parameter Definitions/Declarations 4Database Query Statement 4Database Update Statement 4Database Management Statement 4Delivery Statement 7 OGSA-DAI Training Workshop, Release: P2R2 Requests Request - Update Request - Query Delivery data Para meter Para meter data data Query 8 Para meter Para meter data Para meter data Para meter data Update data data Delivery Delivery OGSA-DAI Training Workshop, Release: P2R2 Parameters 4Currently only supported within JDBC query / update activities – sqlQueryStatement – sqlUpdateStatement 4Parameter activity can define a default value 4Values can be (re-)defined within an execute element 4Or can be streamed in from a delivery 9 OGSA-DAI Training Workshop, Release: P2R2 Parameter Activity 4Parameter activities have one output stream 4Using the name of the value element, this output is referenced by other activities 4Optional: value contains a default value <parameter name="textParameter"> <value name="datatoinsert">10</value> </parameter> 10 OGSA-DAI Training Workshop, Release: P2R2 Using Parameters 4 sqlParameter references the output stream of another activity – output from a parameter definition – or output from delivery 4 references the position of an SQL parameter <sqlUpdateStatement name="statement"> <sqlParameter position="1" from="datatoinsert"/> <dataResource>dr1</dataResource> <expression> insert into myimages values ? </expression> </sqlUpdateStatement> 11 OGSA-DAI Training Workshop, Release: P2R2 Using Parameters 4Parameter values can be overwritten within execute statements 4The withParameter element references the parameter name <execute name="execute1" requestName="request1"> <withParameter name="textParameter"> myimages </withParameter> </execute> 12 OGSA-DAI Training Workshop, Release: P2R2 Other Supported Activities 4Relational Type Activities: – – – – sqlQueryStatement sqlUpdateStatement sqlStoredProcedure relationalResourceManagement 4XML Type Activities: – – – – 13 xPathStatement xUpdateStatement xmlCollectionManagement xmlResourceManagement OGSA-DAI Training Workshop, Release: P2R2 Example: sqlQueryStatement <sqlQueryStatement name="statement"> <dataResource> SQLQueryStatementResource </dataResource> <expression> select * from largedata where datagroup = 10 </expression> <webRowSetStream name="statementresult"/> </sqlQueryStatement> 14 OGSA-DAI Training Workshop, Release: P2R2 sqlQueryStatment with Parameters <parameter name="textParameter"> <value name=“tablename">largedata</value> </parameter> <sqlQueryStatement name="statement"> <sqlParameter position="1" from=“tablename"/> <dataResource>SQLQueryStatementResource </dataResource> <expression> select * from ? where datagroup = 10 </expression> <webRowSetStream name="statementresult" /> </sqlQueryStatement> 15 OGSA-DAI Training Workshop, Release: P2R2 Example: xPathStatement <xPathStatement name="statement"> <dataResource> myXMLDBDataResource </dataResource> <expression> /entry[@id&lt;100] </expression> <sequenceStream name="statementresult"/> </xPathStatement> 16 OGSA-DAI Training Workshop, Release: P2R2 XML:DB Collection Management <xmlCollectionManagement name="statement"> <dataResource> myXMLDBDataResource </dataResource> <createCollection name="musicians"/> <createCollection name="writers"/> <sequenceStream name="statementOutput"/> </xmlCollectionManagement> 17 OGSA-DAI Training Workshop, Release: P2R2 Delivery Synchronous delivery 4toResponse Asynchronous delivery 4toURL / fromURL: ftp, http, https, file 4toGFTP / fromGFTP: by GridFTP 4toGDT / fromGDT: GridDataTransport portType 18 OGSA-DAI Training Workshop, Release: P2R2 Delivery Structure Delivery - Push 4Input Stream: fromLocal – references the name of another activity 4Output Stream: toURL, toGFTP, toGDT – where to push the data to Delivery – Pull 4Input Stream: fromURL, fromGFTP, fromGDT – where to pull the data from 4OutputStream: fromLocal – references the name of another activity 19 OGSA-DAI Training Workshop, Release: P2R2 Example Query with Synchronous Delivery <request name="myRequest"> <xPathStatement name="statement"> <dataResource>dr1</dataResource> <expression>/entry[@id&lt;100]</expression> <sequenceStream name="statementOutput"/> </xPathStatement> <deliverToResponse name="d1"> <fromLocal from="statementOutput" /> </deliverToResponse> </request> 20 OGSA-DAI Training Workshop, Release: P2R2 Example Query with Asynchronous Delivery to URL <request name="myRequest"> <xPathStatement name="statement"> <dataResource>dr1</dataResource> <expression>/entry[@id&lt;100]</expression> <sequenceStream name="statementOutput"/> </xPathStatement> <deliverToURL name="d1"> <fromLocal from="statementOutput" /> <toURL> ftp://ogsadai.org.uk/resultsets/newresultset.txt </toURL> </deliverToURL> </request> 21 OGSA-DAI Training Workshop, Release: P2R2 Example Query with Asynchronous Delivery to URL <request name="myRequest"> <xPathStatement name="statement"> <dataResource>dr1</dataResource> <expression>/entry[@id&lt;100]</expression> <sequenceStream name="statementOutput"/> </xPathStatement> <deliverToURL name="d1"> <fromLocal from="statementOutput" /> <toURL> file://c:/ogsadai/resultsets/newresultset.txt </toURL> </deliverToURL> </request> 22 OGSA-DAI Training Workshop, Release: P2R2 Execute 4References the name of a request in the requestName attribute <execute name="execute1" requestName="request1"/> 4Can contain a parameter value <execute name="execute1" requestName="request1"> <withParameter name="tablename"> myimages </withParameter> </execute> 23 OGSA-DAI Training Workshop, Release: P2R2 Terminate 4Terminates a running request 4References the name of an execute element <terminate name="terminate1" executeName="execute1"> 24 OGSA-DAI Training Workshop, Release: P2R2 Exercises 4A GridDataServiceRegistry is running on http://?????????/ogsa/services/ogsadai/ GridDataServiceRegistry 4MySQL Database: myDataResource 4Xindice Database: myXMLDataResource 25 OGSA-DAI Training Workshop, Release: P2R2