Presentation is loading. Please wait.

Presentation is loading. Please wait.

GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon

Similar presentations


Presentation on theme: "GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon"— Presentation transcript:

1 GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon http://csce.uark.edu/~aapon/courses/gridcomputing/index.html from http://www.casa-sotomayor.net/gt3-tutorial/

2 Chapter 5: Service Data Service Data is one of the main improvements of Grid Services with respect to plain Web Services Can be used to classify and index services –To help advertise and then find services Is a structured collection of information that is associated to a Grid Service

3 Service Data is an essential part of service discovery

4 The logic behind Service Data Service data must be easy to query The client can choose an appropriate service by querying the Service Data associated with each Math Service Service Data and notifications are closely related

5 Service Data in Grid Services Any Grid Service can have any number of Service Data Elements (SDEs) associated to it Each SDE must have a name that is unique within that particular type of Grid Service An SDE is represented in XML and the structure is defined in the GWSDL file An SDE can have any number of values

6 Example with the MathService Two SDEs: SystemInfo and LastResults The collection of SDEs is called a ServiceData set

7 Example: SystemInfo SDE Could be used to store information about the system where MathService is running SystemInfo is a structure with fields –numberOfCPUs: integer –systemLoad: float –CPUBrand: string This particular SDE will have a cardinality of 1..1 (min of 1, max of 1)

8 LastResults SDE Could be used to store the last N internal values that have been returned by MathService The datatype would be integer The cardinality could be 0..10

9 At some point in time:

10 A slightly less simple example

11 SDE with complex data type  a Java bean is created See the $TUTORIAL_DIR for the complete code

12 Adding a single SDE to the MathService See $TUTORIAL_DIR/schema/progtutorial/MathService_sd/MathSDE.xsd for the complete definition

13 public class MathDataType implements java.io.Serializable { private int value; // attribute private java.lang.String lastOp; // attribute private int numOps; // attribute public MathDataType() { } public int getValue() { return value; } public void setValue(int value) { this.value = value; } public java.lang.String getLastOp() { return lastOp; } public void setLastOp(java.lang.String lastOp) { this.lastOp = lastOp; } Part of the code generated

14 Adding Service Data to a service is an interface issue Need to modify the GWSDL interface from $TUTORIAL_DIR/schema/progtutorial/MathService_sd/Math.gwsdl Need to specify a new target namespace –This is a Math Service with service data, so we’ll use a name that shows this for convenience We will also include two new namespaces, one for the SDE type and one for the service data-related definitions The next three slides show pieces of Math.gwsdl

15

16 Import the schema file

17 Add a new tag to portType s --> <sd:serviceData name="MathData“ type="data:MathDataType" minOccurs="1" maxOccurs="1" mutability="mutable" modifiable="false" nillable="false">

18 Attributes of the SDE minOccurs : The minimum number of values that this SDE can have. maxOccurs : The maximum number of values that this SDE can have. The value of this attribute can be unbounded, which indicates an array with no size limit. modifiable : True or false. Specifies if the value of this SDE can be changed by a client. nillable : True or false. Specifies if the value of this SDE can be NULL. mutability : This attribute can have the following values: –static: The value of the SDE is provided in the GWSDL description. –constant: The value of the SDE is set when the Grid Service is created, but remains constant after that. –extendable: New elements can be added to the SDE, but not removed. –mutable: New elements can be added and removed.

19 Modify namespace2package.mappings http\://www.globus.org/namespaces/2004/02/progtutorial/MathService_sd = org.globus.progtutorial.stubs.MathService_sd http\://www.globus.org/namespaces/2004/02/progtutorial/MathService_sd /bindings= org.globus.progtutorial.stubs.MathService_sd.bindings http\://www.globus.org/namespaces/2004/02/progtutorial/MathService_sd /service= org.globus.progtutorial.stubs.MathService_sd.service http\://www.globus.org/namespaces/2004/02/progtutorial/MathServic e_sd/MathSDE= org.globus.progtutorial.stubs.MathService_sd.servicedata

20 Service Implementation Class declaration is the same Need to add two private attributes: private ServiceData mathDataSDE; private MathDataType mathDataValue; The creation of the SDEs takes place in a special method called the postCreate method. This code is executed right after the service has been created.

21 public void postCreate(GridContext context) throws GridServiceException { // Call base class's postCreate super.postCreate(context); // Create Service Data Element mathDataSDE = this.getServiceDataSet().create("MathData"); // Create a MathDataType instance and set initial values mathDataValue = new MathDataType(); mathDataValue.setLastOp("NONE"); mathDataValue.setNumOps(0); mathDataValue.setValue(0); // Set the value of the SDE to the MathDataType instance mathDataSDE.setValue(mathDataValue); // Add SDE to Service Data Set this.getServiceDataSet().add(mathDataSDE); }

22 The steps to create an SDE 1.Create a new SDE. Notice how we don't create it directly: we have to call the create method of the Service Data Set. This SDE is initially empty, it has no value. Also, the name of the SDE will be MathData 2.Set a value for the SDE. The value of the SDE will be a MathDataType that we create ourselves. 3.Set the initial values of MathDataType. In our example, the last operation is "NONE" and the number of operations done is zero. 4.Add the SDE to the Service Data Set

23 Need to modify methods 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); } The modification of the subtract method is similar.

24 Deployment Descriptor The deployment descriptor only changes a little to list the new class, new baseClass, and new schemaPath to correspond to the files that we just created See $TUTORIAL_DIR/org/globus/progtutorial/servic es/core/servicedata/server-deploy.wsdd

25 Compile and deploy Use the new GWSDL file with the build script to build the MathService_sd Deploy with ant as before, from the GT3 installation directory.

26 A client that accesses Service Data // 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());

27 findServiceData Invoke the findServiceData directly on math (which is a MathPortType). –Doesn't that portType only have an add and a subtract method? But Math portType extends from a standard portType called GridService. We can also use our math portType to invoke GridService methods (such as findServiceData).

28 Using an ExtensbilityType Need to cast it into a MathDataType using helper classes ServiceDataValuesType serviceData = AnyHelper.getAsServiceDataValues(extensibility) ; MathDataType mathData = (MathDataType) AnyHelper.getAsSingleObject(serviceData, MathDataType.class);

29 Finally, for Math portType SDE Use the MathDataType object like any other local object Compile and run the client as before

30 GridService Service Data There are a set of common Service Data Elements for every grid service –If portType is a grid service is must extend from the GridService portType Some examples include –gridServiceHandle –terminationTime –serviceDataNames –interfaces

31 Some cool things with SDEs Notifications (Chapter 6 in the tutorial) GT3 Service Data Browser http://www.globus.org/ogsa/releases/final/docs/in fosvcs/sdbquickstart.html Monitoring and Discovery Service (MDS3) –a broad framework that includes any part of GT3 that generates, registers, indexes, aggregates, subscribes, monitors, queries, or displays Service Data in some way.

32 Chapter 6: Notifications A feature that is closely related to service data Allow clients to be notified of changes that occur in a Grid Service

33 Polling – the old-fashioned approach

34 Notification approach This is the pull approach – each observer gets the data after notify Alternatively, use the push approach – send the data with the notify

35 Notifications in GT3 Each client subscribes to be notified of a change to a particular SDE in a service Whenever a change happens the service will ask the SDE to notify its subscribers The SDE notifies the subscribers that a change has happened

36 Change to service implementation public void add(int a) throws RemoteException { mathDataValue.setLastOp("Addition"); incrementOps(); mathDataValue.setValue(mathDataValue.getValue() + a); mathDataSDE.notifyChange(); } Plus changes to the interface definition, mapping, …

37 Notification Client This is more complex Must implement a deliverNotification method

38 Chapter 7: Transient Services Turning a service into a factory of services is one of the easiest things to do in GT3 Is already in the server-deploy.wsdd file and gets deployed anyway


Download ppt "GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon"

Similar presentations


Ads by Google