OGSA-DAI provides a several ways of delivering results asynchronously. This section will show you how to use this functionality.
The output from an activity can be delivered to a file on a remote site. A data service can push data to a URL or pull update or bulk load data from a URL.
http://www.ogsadai.org.uk/tutorial/transformRowSet.xsl ftp://user:password@example.com/path/filename
DeliverFromURL deliver = new DeliverFromURL( url );
myactivity.setInput( deliver.getOutput() );
Delivery to a URL works in a similar way via the deliverToURL activity and its corresponding DeliverToURL class:
DeliverToURL deliver = new DeliverToURL( url ); deliver.setInput( myactivity.getOutput() );
You can use the ftp protocol.
See examples/tutorials/clienttoolkit/XSLTransformWithDelivery.java for an example.
The output from an activity can be delivered to a file on the server file system. Like the DeliverFromURL and DeliverToURL activities, a data service can push data to a file or pull update or bulk load data from a file.
DeliverFromFile deliver = new DeliverFromFile( "C:/path/to/myfile.txt" );
myactivity.setInput( deliver.getOutput() );
Delivery to a file works in a similar way via the deliverToFile activity and its corresponding DeliverToFile class:
DeliverToFile deliver = new DeliverToFile( "C:/path/to/myfile.txt" ); deliver.setInput( myactivity.getOutput() );
Note that, by default, these activities are disabled in activity configuration documents used to configure OGSA-DAI services, due to the security issue arising from enabling access to anywhere on the GDS server file system.
The output from an activity can be delivered to a file on a remote Grid FTP server. The deliverToGFTP activity is used for this purpose.
DeliverToGFTP deliver = new DeliverToGFTP("ogsadai.org.uk", 8080, "myresults.txt" );
DeliverToGFTP deliver = new DeliverToGFTP(); deliver.setHost( host_name ); deliver.setPort( port_number ); deliver.setFile( file_name );
Using the outputStream you can open a connection to a data service and retrieve data using the DataTransport portType. This is a great way to run a query that returns a large amount of data without either the server or client failing with a java.lang.OutOfMemoryError.
SQLQuery sqlQuery = new SQLQuery( "select * from littleblackbook" ); OutputStreamActivity outputStream = new OutputStreamActivity(sqlQuery.getOutput()); ActivityRequest request = new ActivityRequest(); request.addActivity( sqlQuery ); request.addActivity( outputStream );
service.perform( request );
ResultSet rs = outputStream.getResultSet();
This will create a ResultSet object that will be of type ResultSet.TYPE_FORWARD_ONLY. When the next row is requested from the ResultSet object, the DataTransport connection to the data service will be used to retrieve the data.
See examples/tutorials/clienttoolkit/ProcessingSQLQueryLargeResults.java for an example.
Using the inputStream you can open a connection to a data service and supply data using the DataTransport portType.
InputStreamActivity inputStream = new InputStreamActivity(); SQLUpdate update = new SQLUpdate( "insert into littleblackbook values (?,?,?,?)" ); update.setParameter(1, inputStream.getOutput()); update.setParameter(2, inputStream.getOutput()); update.setParameter(3, inputStream.getOutput()); update.setParameter(4, inputStream.getOutput()); ActivityRequest request = new ActivityRequest(); request.addActivity( inputStream ); request.addActivity( update );
service.perform( request );
DataTransport putter = inputStream.getDataTransport();
putter.putBlock(new Integer(10010)); putter.putBlock("Albert Einstein"); putter.putBlock("Patent Office, Bern"); putter.putBlock("0123456789");
putter.putClosingBlock();
See OGSA-DAI/examples/tutorials/clienttoolkit/ParameterisedUpdateViaGDT.java for an example.
It is possible to configure the request to pull data from a source data service to another (sink) data service. To configure this the deliverFromDT activity (and the corresponding Java class DeliverFromDT) is used at the source data service to push the data to an outputStream activity (corresponding Java class OutputStreamActivity) at the sink data service.
In this example you will use to data services:
The deliverFromDT activity pulls data from the source data service's outputStream activity. In order to contact the source data service and pull the data to the sink data service's deliverToDT activity must know the URL of the sink and the name of the outputStream activity.
It is important that the sink data service's inputStream activity is started before the source data service's deliverToGDT activity otherwise this activity will fail.
String handle = "http://HOST:PORT/wsrf/services/ogsadai/DataService"; String resourceID = "MySQLResource"; DataService sourceService = WSRFServiceFetcher.getInstance().getWSRFDataService(handle, resourceID);
SQLQuery sqlQuery = new SQLQuery( "select * from littleblackbook where id<100" ); OutputStreamActivity outputStream = new OutputStreamActivity(); outputStream.setInput(sqlQuery.getOutput()); ActivityRequest sourceRequest = new ActivityRequest(); sourceRequest.add( sqlQuery ); sourceRequest.add( outputStream );
Response sourceResponse = sourceService.perform( sourceRequest );The sink data service will wait for data to arrive at its input stream activity and then deliver the results in the response.
String handle = "http://HOST:PORT/wsrf/services/ogsadai/DataService"; String resourceID = "MySQLResource2"; DataService sourceService = WSRFServiceFetcher.getInstance().getWSRFDataService(handle, resourceID);
DeliverFromDT deliverFromDT = new DeliverFromDT();
deliverFromDT.setDataTransportURL( sourceService.getURL() ); deliverFromDT.setDataTransportResourceID( sourceService.getResourceID() ); deliverFromDT.setDataTransportStreamID( outputStream.getName() );
deliverFromDT.setDataTransportMode( DataTransportMode.BLOCK );
ActivityRequest sinkRequest = new ActivityRequest(); sinkRequest.add( deliverFromDT );
Response sinkResponse = sinkService.perform( sinkRequest );
See examples/tutorials/clienttoolkit/GDTExample.java for an example.
Similar to pulling data to another data service, you can push data to a data service.
Back: Transforming Data | Up: Using the Client Toolkit | Next: Data Integration | |
© International Business Machines Corporation, 2004. | © The University of Edinburgh, 2004. |