Presentation is loading. Please wait.

Presentation is loading. Please wait.

4c1 GT 4 grid services and their implementation Advanced features: An overview Topics: Resource home Singleton resource Multiple resources Notifications.

Similar presentations


Presentation on theme: "4c1 GT 4 grid services and their implementation Advanced features: An overview Topics: Resource home Singleton resource Multiple resources Notifications."— Presentation transcript:

1 4c1 GT 4 grid services and their implementation Advanced features: An overview Topics: Resource home Singleton resource Multiple resources Notifications Lifecycles ITCS 4146/5146, UNC-Charlotte, B. Wilkinson, 2007 Feb. 22, 2007

2 4c2 Stateful GT 4 Grid Services Review “Pure” Web services are stateless. Stateful web services required for grid computing. Obtained in WSRF by having a web service front-end to a stateful “resource.”

3 4c3 Web Service Resource Resource properties Client Web Service Resource Framework (WSRF) Holds information retained between accesses.

4 4c4 GT 4 services Key aspect is the separation of the (web) service and a resource – conceptually if not actually. Provides the ability to have “state” without altering the statelessness of a web service.

5 4c5 Assignment 4 In Assignment 4, both service code and resource code held in a single file. End Point Reference (EPR) actually is only the URL of the service. Not necessary to have resource identification (key) Having one file not the preferred way except for simple service examples.

6 4c6 Resource Home Resources are managed by “Resource Homes” Provides resource management functions –for adding resources –for removing resources Although hidden in Assignment 4 where resource and service were in one file, a Resource Home did exist.

7 4c7 Resource Home Client Web Service Resource home Resource Manages Methods operate on resources properties create/ find resource Client only interacts with stateless web service

8 4c8 Service and resource code Client Web Service Resource home Resource Manages add() and subtract() methods operate on resource properties create/ find resource void add(int a) void subtract (int a) int value String lastOP

9 4c9 Resource Home Client Web Service Resource home Resource Previously, service and resource in one file and resource limited to one resource using a globus supplied resource home called ServiceResourceHome

10 4c10 Service and resource code Client Web Service Resource home “ServiceResourceHome” Resource add() and subtract() methods operate on resource properties create/ find resource void add(int a) void subtract (int a) int value String lastOP ServiceResourceHome returns service object

11 4c11 Separately service, resource and resource home files Singleton Resources (Single resource)

12 4c12 Resource Home Client Web Service Resource home Resource Three files: the service, the resource home, and the resource.

13 4c13 Acknowledgement The following applies to the code in the next five slides: /* * This file is licensed under the terms of the Globus Toolkit Public License v3, found at http://www.globus.org/toolkit/legal/4.0/license-v3.html. * * This notice must appear in redistributions of this file, with or without modification. */ You will be able to find the files in your assignment 4 software installation at: $EXAMPLES_DIR/org/globus/examples/servives/core/singleton /imp/

14 4c14 package org.globus.examples.services.core.singleton.impl; import org.globus.wsrf.Resource; import org.globus.wsrf.impl.SingletonResourceHome; public class MathResourceHome extends SingletonResourceHome { public Resource findSingleton() { try { // Create a resource and initialize it. MathResource mathResource = new MathResource(); mathResource.initialize(); return mathResource; } catch (Exception e) { return null; } Singleton Resource home code MathResourceHome.java Implemented by extending SingletonResourceHome class.

15 4c15 /* public class MathService { /* Private method that gets a reference to the resource specified in the * endpoint reference. */ private MathResource getResource() throws RemoteException { Object resource = null; try { resource = ResourceContext.getResourceContext().getResource(); } catch (NoSuchResourceException e) { throw new RemoteException("Specified resource does not exist", e); } catch (ResourceContextException e) { throw new RemoteException("Error during resource lookup", e); } catch (Exception e) { throw new RemoteException("", e); } MathResource mathResource = (MathResource) resource; return mathResource; } MathService code MathService.java

16 4c16 /* /* Implementation of add, subtract, and getValue operations */ public AddResponse add(int a) throws RemoteException { MathResource mathResource = getResource(); mathResource.setValue(mathResource.getValue() + a); mathResource.setLastOp("ADDITION"); return new AddResponse(); } public SubtractResponse subtract(int a) throws RemoteException { MathResource mathResource = getResource(); mathResource.setValue(mathResource.getValue() - a); mathResource.setLastOp("SUBTRACTION"); return new SubtractResponse(); } public int getValueRP(GetValueRP params) throws RemoteException { MathResource mathResource = getResource(); return mathResource.getValue(); }

17 4c17 public class MathResource implements Resource, ResourceProperties { /* Resource Property set */ private ResourcePropertySet propSet; /* Resource properties */ private int value; private String lastOp; /* Initializes RPs */ public void initialize() throws Exception { this.propSet = new SimpleResourcePropertySet( MathConstants.RESOURCE_PROPERTIES); ResourceProperty valueRP = new ReflectionResourceProperty( MathConstants.RP_VALUE, "Value", this); this.propSet.add(valueRP); setValue(0); ResourceProperty lastOpRP = new ReflectionResourceProperty( MathConstants.RP_LASTOP, "LastOp", this); this.propSet.add(lastOpRP); setLastOp("NONE"); } Resource code MathResource.java

18 4c18 /* Get/Setters for the RPs */ public int getValue() { return value; } public synchronized void setValue(int value) { this.value = value; } public String getLastOp() { return lastOp; } public synchronized void setLastOp(String lastOp) { this.lastOp = lastOp; } /* Required by interface ResourceProperties */ public ResourcePropertySet getResourcePropertySet() { return this.propSet; }

19 4c19 Multiple Resources Suppose there are multiple resources that a service might interact with: Client Web Service Resources

20 4c20 Creating Resources WS-Resource Factory Pattern A traditional object-oriented approach to creating resources is to use a “factory” service: The factory service is responsible for creating instances of objects. Each resource will be assigned a unique “key”, which together with the service URI identifies the WS-resource pair. (Endpoint Reference)

21 4c21 Client “Instance” Service Resources WS-Resource Factory Pattern Factory service Request resource creation Request operation on resource Create Perform operation Returns WS- Resource EPR

22 4c22 Relationship with Resource Home Client Service instance Resource Home Resource Manages Methods operate on resources properties Find resource Factory Service Request resource creation Use Resource Home to create resource Request operation

23 4c23 Factory service Create Resource operation endpointReference createResource() Returns an EPR to the newly created WS- Resource. “Fully qualified” EPR to include URI of service and key of resource Client needs to know location of factory service.

24 4c24 WS-Addressing Terms Endpoint – the destination where the web service can be accessed. Endpoint reference, EPR –describes the destination, and includes the destination location as URI, but can have other parameters

25 4c25 Endpoint reference, EPR Like all WS-* specs, defined in terms of XML. Defined as complex type. Can contain: Address (a URI) (required) Reference Properties Reference Parameters Port type Service name Policy elements Corresponds to portType and service of WSDL document

26 4c26 Minimum is simply service address, using tag: http://www.cs.uncc.edu/axis/abw/Myservice.jws

27 4c27 Reference Properties Used to identify resource properties in EPR: http://www.cs.uncc.edu/axis/abw/Myservice.jws 28

28 4c28 Another example file containing Endpoint Reference <StickyNoteEndpoint xsi:type="ns1:EndpointReferenceType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://schemas.xmlsoap.org/ws/2004/03/addressing"> <ns1:Address xsi:type="ns1:AttributedURI">http://192.168.1.100:8080/wsrf/ services/ StickyNoteService 25781085 Resource “key”

29 4c29 SOAP message WS-Addressing requires that contents of: and must appear in SOAP’s header:. http://www.cs.uncc.edu/axis/abw/Myservice.jws 28..

30 4c30 Index Service GT 4 provided with an index service that can maintain a list of available services. Index service acts as local service registry.

31 4c31 Container Index service Multiple services/Resources (with resource properties)

32 4c32 Querying Index Service wsrf-query Browse index service with the GT4 wsrf-query command: $GLOBUS_LOCATION/bin/wsrf-query -s http://localhost:8080/wsrf/services/DefaultIndexService '/*' which will list the services in an XML format.

33 4c33 “Community” Index Service A remote index service is used, which holds all the services of the “virtual organization.” Last year we located a community index service at: http://beowulf.bear.uncw.edu:8080/wsrf/ services/DefaultIndexService

34 4c34 Local Index service Resources Community index service beowulf.bear.uncw.edu:8080 /wsrf/services/ DefaultIndexService Service client

35 4c35 Implementation Configure local index to register with community index service. All local information, including service resource properties, copied to community index service.

36 4c36 Querying Community Index Service Have Community Index Service running. Use wsrf-query command: $GLOBUS_LOCATION/bin/wsrf-query -s http://beowulf.bear.uncw.edu:8080/wsrf/ services/DefaultIndexService '/*' Should see contents of all local index services.

37 4c37 Local Index service Resources Service client Local Index service Resources Service client Student 1 Index entry Student 2 Index entry Student 1 container Only container and GT 4 core needed at each site to handle services. Student 2 container Community index service

38 4c38 Notifications Notifying clients when something interesting happens. Example might be when a resource property reaches a certain value Could be found out by polling resource but that would be very inefficient. WS-notification provides mechanisms.

39 4c39 Notifications Notifications, generally, are a means by which a client can be informed of changes that have occurred such as: –Changes to resource property values. –Methods added –Methods removed –Resources destroyed

40 4c40 Clients Service “watch” service Service resource property Notification that property changed

41 4c41 Need the client to “subscribe” to receive notifications. Subscriptions are for a particular topic.

42 4c42 Implementation Add subscribe operation to wsdl file. Add SubscribeProvider to wsdd file. Modify.java Modify post-deploy.xml file

43 4c43 Lifecycle Management GT4 provides mechanisms to specify when a resource is destroyed: Immediately by invoking destroy operation Scheduled some time in the future –leased-based lifecycle management Lease periodically renewed otherwise resource destroyed within a specified time. Lifecycle mechanisms available in WSRF.

44 4c44 Lease-based Lifetime In lease-based model, resources must be kept alive by interested parties, otherwise resource dies. Set a lifetime for a service after which the service is destroyed. Clean up without having to use a destroy operation explicitly.

45 4c45 Termination Time Termination time exposed as a resource property. Can be set with GT4 wsrf-set-termination-time command. Example $GLOBUS_LOCATION/bin/wsrf-set-termination- time -e note--1234.epr 100 File containing EPR of resource Termination time in seconds

46 4c46 Resource Discovery Local and community index services can be searched for information Since Resources properties are XML, can use “XPath” queries for searching and retrieval. Uses a “XPath” query (apparently embedded in a script called search-note in this exercise)

47 4c47 XML Path Language (XPath) W3C recommendation, 1999 A query language for search XML documents. Queries formed by identifying a route to the desired data. For details: http://www.w3.org/TR/xpath

48 4c48 More Information GGF: http://www.ggf.org GT4 services: http://gdp.globus.org/gt4-tutorial/ GT4 tutorial by Foster: http://www.globus.org/toolkit/docs/4.0/key/GT4_Primer_0.6.pdf

49 4c49 Book Globus Toolkit 4 Programming Java Services Borja Sotomayor and Lisa Childer Morgan Kaufmann, 2006.


Download ppt "4c1 GT 4 grid services and their implementation Advanced features: An overview Topics: Resource home Singleton resource Multiple resources Notifications."

Similar presentations


Ads by Google