Presentation is loading. Please wait.

Presentation is loading. Please wait.

Service Data in Grid Services  Service Data allows us to easily include a set of structured data to any service, which can then be processed directly.

Similar presentations


Presentation on theme: "Service Data in Grid Services  Service Data allows us to easily include a set of structured data to any service, which can then be processed directly."— Presentation transcript:

1 Service Data in Grid Services  Service Data allows us to easily include a set of structured data to any service, which can then be processed directly through its interface.  State information: operation results, intermediate results…  Service metadata: system data, cost of using the service…

2 How to implement Service Data in Grid Services

3  First, undeploy your previous Grid service.  cd $HOME/gt3  ant undeploy -Dgar.id=mathtutorial  Create a new directory called “servicedata” under $HOME/gt3/samples/.  cd $HOME/gt3/samples  mkdir servicedata

4 How to implement Service Data in Grid Services  Create the package directory structure:

5 How to implement Service Data in Grid Services  We require the following files:  Implementation file  Web service deployment descriptor that tells the web server how it should publish our Grid service.  Grid web service description language (GWSDL) file  Mappings file, which map GWSDL namespaces to Java packages  XML schema file (extension XSD) which specifies the complex data type of service data.  Client file to run the service.

6 How to implement Service Data in Grid Services  MathSDE.xsd: Create this file under mathtutorial/core/factory/schema directory.

7 How to implement Service Data in Grid Services  Service interface: Math.gwsdl which will be saved mathtutorial/core/factory/schema directory.

8 How to implement Service Data in Grid Services  Namespace file: namespace2package.mappings file to be saved under servicedata directory. http\://www.globus.org/namespaces/2004/02/MathSDE=mathtutorial.core.factory http\://www.globus.org/namespaces/2004/02/bindings=mathtutorial.core.factory.bindings http\://www.globus.org/namespaces/2004/02/service=mathtutorial.core.factory.service http\://www.globus.org/namespaces/2004/02=mathtutorial.core.factory.Math http\://www.gridforum.org/namespaces/2003/03/OGSI=org.gridforum.ogsi

9 How to implement Service Data in Grid Services  Implementation file: MathImpl.java file to be saved under mathtutorial/core/factory/ directory. package mathtutorial.core.factory.impl; import org.globus.ogsa.ServiceData; import org.globus.ogsa.impl.ogsi.GridServiceImpl; import org.globus.ogsa.GridContext; import org.globus.ogsa.GridServiceException; import mathtutorial.core.factory.Math.MathPortType; import mathtutorial.core.factory.MathDataType; import mathtutorial.core.factory.Math.*; import mathtutorial.core.factory.bindings.*; import mathtutorial.core.factory.service.*; import java.rmi.RemoteException;

10 How to implement Service Data in Grid Services  Implementation file: MathImpl.java file to be saved under mathtutorial/core/factory/impl directory. public class MathImpl extends GridServiceImpl implements MathPortType { private ServiceData mathDataSDE; private MathDataType mathDataValue; public MathImpl() { super("Simple MathService with Service Data");} public void postCreate(GridContext context) throws GridServiceException { super.postCreate(context); mathDataSDE = this.getServiceDataSet().create("MathData"); mathDataValue = new MathDataType(); mathDataValue.setLastOp("NONE"); mathDataValue.setNumOps(0); mathDataValue.setValue(0); mathDataSDE.setValue(mathDataValue); this.getServiceDataSet().add(mathDataSDE); }

11 How to implement Service Data in Grid Services  Implementation file: MathImpl.java file to be saved under mathtutorial/core/factory/impl directory. private void incrementOps() {int numOps = mathDataValue.getNumOps(); mathDataValue.setNumOps(numOps + 1); } public void add(int a) throws RemoteException {mathDataValue.setLastOp("Addition"); incrementOps(); mathDataValue.setValue(mathDataValue.getValue() + a); } public void subtract(int a) throws RemoteException {mathDataValue.setLastOp("Subtraction"); incrementOps(); mathDataValue.setValue(mathDataValue.getValue() - a); }

12 How to implement Service Data in Grid Services  WSDD file: Math. wsdd file to be saved under mathtutorial/core/factory/ directory. c

13 How to implement Service Data in Grid Services  Build.properties file: build.properties file to be saved under servicedata directory. ogsa.root=../.. interface.name=Math package.dir=./mathtutorial/core/factory package=mathtutorial.core.factory Copy build.xml file to be saved under servicedata directory.

14 How to implement Service Data in Grid Services  Client file: client.java to be saved under mathtutorial/core/factory/client directory. package mathtutorial.core.factory.client; import org.gridforum.ogsi.ExtensibilityType; import org.gridforum.ogsi.ServiceDataValuesType; import org.globus.ogsa.utils.AnyHelper; import org.globus.ogsa.utils.QueryHelper; import mathtutorial.core.factory.service.MathServiceGridLocator; import mathtutorial.core.factory.Math.MathPortType; import mathtutorial.core.factory.MathDataType; import java.net.URL;

15 How to implement Service Data in Grid Services  Client file: client.java to be saved under mathtutorial/core/factory/client directory. URL GSH = new java.net.URL(args[0]); int a = Integer.parseInt(args[1]); // Get a reference to the Math PortType MathServiceGridLocator mathServiceLocator = new MathServiceGridLocator(); MathPortType math = mathServiceLocator.getMathServicePort(GSH); // Get Service Data Element "MathData" ExtensibilityType extensibility = math.findServiceData(QueryHelper.getNamesQuery("MathData")); ServiceDataValuesType serviceData = AnyHelper.getAsServiceDataValues(extensibility); MathDataType mathData = (MathDataType) AnyHelper.getAsSingleObject(serviceData, MathDataType.class); // Write service data System.out.println("Value: " + mathData.getValue()); System.out.println("Previous operation: " + mathData.getLastOp()); System.out.println("# of operations: " + mathData.getNumOps()); // Call remote method math.add(a);

16 How to implement Service Data in Grid Services  Deployment:  Set the TUTORIAL_DIR environment variable to $HOME/gt3/samples/servicedata  setenv TUTORIAL_DIR $HOME/gt3/samples/servicedata  Deploy your service (Directory = $TUTORIAL_DIR)  ant -Dgwsdl.interface=true -Dpackage=mathtutorial.core.factory - Dinterface.name=Math -Dpackage.dir=mathtutorial/core/factory/ - Dgwsdl.interface=Math.gwsdl -Dsde.schema.file=MathSDE.xsd  Deploy in GT3 directory.  ant deploy - Dgar.name=$TUTORIAL_DIR/build/lib/mathtutorial.core.factory.Mat h.gar  Run your Grid service container:  globus-start-container –p $MYPORT

17 How to implement Service Data in Grid Services  Client Side:  Open another terminal.  Compile the Client.java:  javac -classpath./build/classes/:$CLASSPATH mathtutorial/core/factory/client/Client.java  Create an instance from your service.  ogsi-create-service /MathFactoryService math1  Run your client.  java -classpath./build/classes/:$CLASSPATH mathtutorial/core/factory/client/Client /MathFactoryService/math1 5


Download ppt "Service Data in Grid Services  Service Data allows us to easily include a set of structured data to any service, which can then be processed directly."

Similar presentations


Ads by Google