4c1 gt 4 grid services and their implementation advanced features: an overview topics: resource home...
Post on 21-Dec-2015
218 views
TRANSCRIPT
4c1
GT 4 grid services and their implementation
Advanced features:An overview
Topics:Resource home
Singleton resourceMultiple resources
NotificationsLifecycles
ITCS 4146/5146, UNC-Charlotte, B. Wilkinson, 2007 Feb. 22, 2007
4c2
Stateful GT 4 Grid ServicesReview
• “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.”
4c3
Web Service
Resource
Resource properties
Client
Web Service Resource Framework(WSRF)
Holds information retained between accesses.
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.
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.
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.
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
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 valueString lastOP
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
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 valueString lastOP
ServiceResourceHome returns service object
4c11
Separately service, resource and resource home files
Singleton Resources(Single resource)
4c12
Resource Home
Client Web Service
Resource home
Resource
Three files: the service, the resource home, and the resource.
4c13
AcknowledgementThe 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/
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 codeMathResourceHome.java
Implemented by extending SingletonResourceHome class.
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 codeMathService.java
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();
}
}
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 codeMathResource.java
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;}
}
4c19
Multiple Resources
Suppose there are multiple resources that a service might interact with:
Client Web Service
Resources
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)
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
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
4c23
Factory serviceCreate 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.
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
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
4c26
Minimum is simply service address, using <wsa:Address> tag:
<wsa:EndpointReference>
<wsa:Address>
http://www.cs.uncc.edu/axis/abw/Myservice.jws
</wsa:Address>
</wsa:EndpointReference>
4c27
Reference Properties <wsa:ReferenceProperties>
Used to identify resource properties in EPR:
<wsa:EndpointReference>
<wsa:Address>
http://www.cs.uncc.edu/axis/abw/Myservice.jws
</wsa:Address>
<wsa:ReferenceProperties> <resourceID>28</resourceID> </wsa:ReferenceProperties>
</wsa:EndpointReference>
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
</ns1:Address>
<ns1:ReferenceProperties “xsi:type="ns1:ReferencePropertiesType">
<ns1:NoteKey xmlns:ns1="http://sticky.com">25781085
</ns1:NoteKey>
</ns1:ReferenceProperties>
<ns1:ReferenceParameters xsi:type="ns1:ReferenceParametersType"/>
</StickyNoteEndpoint>
Resource “key”
4c29
SOAP messageWS-Addressing requires that contents of: <wsa:Address> and <wsa:ReferenceProperties>must appear in SOAP’s header:
<soap:Envelop><soap:Header>... <wsa:To>http://www.cs.uncc.edu/axis/abw/Myservice.jws</wsa:To> <resourceID>28</resourceID>...</soap:Header>
<soap:Body> ...</soap:Body>
</soap:Envelop>
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.
4c31
Container
Index service
Multiple services/Resources(with resource properties)
4c32
Querying Index Servicewsrf-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.
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
4c34
Local Index service
Resources
Community index service
beowulf.bear.uncw.edu:8080/wsrf/services/
DefaultIndexService
Service
client
4c35
Implementation
• Configure local index to register with community index service.
• All local information, including service resource properties, copied to community index service.
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.
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
4c38
NotificationsNotifying 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.
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
4c40
Clients
Service
“watch” service
Serviceresource property
Notification that property changed
4c41
• Need the client to “subscribe” to receive notifications.
• Subscriptions are for a particular topic.
4c42
Implementation
• Add subscribe operation to wsdl file.
• Add SubscribeProvider to wsdd file.
• Modify <service_code>.java
• Modify post-deploy.xml file
4c43
Lifecycle ManagementGT4 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.
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.
4c45
Termination TimeTermination 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
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)
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
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
4c49
Book
Globus Toolkit 4 Programming Java Services
Borja Sotomayor and Lisa Childer
Morgan Kaufmann, 2006.