1 / 17

Service Data in Grid Services

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….

mervin
Download Presentation

Service Data in Grid Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. How to implement Service Data in Grid Services • 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. <sd:serviceData name="MathData" type="data:MathDataType" minOccurs="1" maxOccurs="1" mutability="mutable" modifiable="false" nillable="false"> </sd:serviceData>

  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 <?xml version="1.0"?> <deployment name="defaultServerConfig" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="mathtutorial/core/factory/MathFactoryService" provider="Handler" style="wrapped"> <parameter name="name" value="MathService Factory"/> <parameter name="instance-name" value="MathService Instance"/> <parameter name="instance-schemaPath" value="schema/mathtutorial.core.factory/Math/MathService.wsdl"/> <parameter name="instance-baseClassName" value="mathtutorial.core.factory.impl.MathImpl"/> <!-- Start common parameters --> <parameter name="allowedMethods" value="*"/> <parameter name="persistent" value="true"/> <parameter name="className" value="org.gridforum.ogsi.Factory"/> <parameter name="baseClassName" value="org.globus.ogsa.impl.ogsi.PersistentGridServiceImpl"/> <parameter name="schemaPath" value="schema/ogsi/ogsi_factory_service.wsdl"/> <parameter name="handlerClass" value="org.globus.ogsa.handlers.RPCURIProvider"/> <parameter name="factoryCallback" value="org.globus.ogsa.impl.ogsi.DynamicFactoryCallbackImpl"/> <parameter name="operationProviders" value="org.globus.ogsa.impl.ogsi.FactoryProvider"/> </service> </deployment>

  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.Math.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 http://131.227.74.147:28161/ogsa/services/mathtutorial/core/factory/MathFactoryService math1 • Run your client. • java -classpath ./build/classes/:$CLASSPATH mathtutorial/core/factory/client/Client http://131.227.74.147:28161/ogsa/services/mathtutorial/core/factory/MathFactoryService/math1 5

More Related