38
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/

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

Embed Size (px)

Citation preview

Page 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 aapon/courses/gridcomputing/index.html

GT3 TutorialChapter 5, 6, and 7

Lecture for Cluster and Grid Computing, CSCE 490/590Fall 2004, University of Arkansas, Dr. Amy Apon

http://csce.uark.edu/~aapon/courses/gridcomputing/index.html from

http://www.casa-sotomayor.net/gt3-tutorial/

Page 2: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 3: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

Service Data is an essential part of service discovery

Page 4: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 5: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 6: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

Example with the MathService

Two SDEs: SystemInfo and LastResultsThe collection of SDEs is called a ServiceData set

Page 7: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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)

Page 8: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 9: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

At some point in time:

Page 10: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

A slightly less simpleexample

Page 11: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

SDE with complex data type a Java bean is created

See the $TUTORIAL_DIR for the complete code

Page 12: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

Adding a single SDE to the MathService

<complexType name="MathDataType">

<sequence>

<element name="value" type="int"/>

<element name="lastOp" type="string"/>

<element name="numOps" type="int"/>

</sequence>

</complexType>

See $TUTORIAL_DIR/schema/progtutorial/MathService_sd/MathSDE.xsd

for the complete definition

Page 13: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 14: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 15: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

<definitions name="MathService" targetNamespace="http://www.globus.org/namespaces/2004/02/progtutorial/MathService_sd" xmlns:tns="http://www.globus.org/namespaces/2004/02/progtutorial/MathService_sd" xmlns:data="http://www.globus.org/namespaces/2004/02/progtutorial/MathService_sd/MathSDE" xmlns:ogsi="http://www.gridforum.org/namespaces/2003/03/OGSI" xmlns:gwsdl="http://www.gridforum.org/namespaces/2003/03/gridWSDLExtensions" xmlns:sd="http://www.gridforum.org/namespaces/2003/03/serviceData" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/">

Page 16: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

Import the schema file

<import location="MathSDE.xsd" namespace="http://www.globus.org/namespaces/2004/02/progtutorial/MathService_sd/MathSDE"/>

Page 17: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

Add a new tag to portType

<gwsdl:portType name="MathPortType" extends="ogsi:GridService"> <!-- <operation>s --> <sd:serviceData name="MathData“

type="data:MathDataType" minOccurs="1" maxOccurs="1" mutability="mutable" modifiable="false" nillable="false">

</sd:serviceData> </gwsdl:portType>

Page 18: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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.

Page 19: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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/MathService_sd/MathSDE= org.globus.progtutorial.stubs.MathService_sd.servicedata

Page 20: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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.

Page 21: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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);

}

Page 22: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 23: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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.

Page 24: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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/services/core/servicedata/server-deploy.wsdd

Page 25: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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.

Page 26: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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());

Page 27: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 28: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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);

Page 29: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

Finally, for Math portType SDE

• Use the MathDataType object like any other local object

• Compile and run the client as before

Page 30: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 31: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

Some cool things with SDEs

• Notifications (Chapter 6 in the tutorial)• GT3 Service Data Browser

http://www.globus.org/ogsa/releases/final/docs/infosvcs/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.

Page 32: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 33: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

Polling – the old-fashioned approach

Page 34: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

Notification approach

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

Page 35: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 36: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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

Page 37: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

Notification Client

• This is more complex

• Must implement a deliverNotification method

Page 38: GT3 Tutorial Chapter 5, 6, and 7 Lecture for Cluster and Grid Computing, CSCE 490/590 Fall 2004, University of Arkansas, Dr. Amy Apon aapon/courses/gridcomputing/index.html

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