Resource Home`s - Personal Web Pages
Download
Report
Transcript Resource Home`s - Personal Web Pages
GT 4 Services
Advanced features:
A very brief overview
Topics:
Resource home
Singleton resource
Multiple resources
Notifications
Lifecycles
Copyright B. Wilkinson, 2008. This material is the property of Professor Barry Wilkinson (UNC-Charlotte) and is for the sole
and exclusive use of the students enrolled in the Fall 2008 Grid computing course broadcast on the North Carolina
4c1
Research and Education Network (NCREN) to universities across North Carolina. Oct 15a, 2008
Stateful GT 4 Grid Services
Review
• “Pure” Web services are stateless.
• Stateful web services required for Grid
computing.
• WSRF provides stateful web services by
having a Web service as a front-end to a
stateful “resource.”
4c2
GT 4 services
• Key aspect is separation of (Web)
service and a resource – conceptually if
not actually.
• Provides ability to have “state” without
altering the statelessness of Web
service.
4c3
Web Service Resource Framework
(WSRF)
Resource
Web Service
Client
Resource properties
Holds
information
retained
between
accesses.
4c4
Resource properties
• Name given to data items in the resource
• Can consist of:
– Data values about current state of service
(results of calculations etc.)
– Metadata: Information about data
– Information about whole resource: Termination
time, etc.
4c5
Combined Service Code
Resource
• In Assignment 5, both service code and resource
code were held in a single file.
• Ideally, we would like to have multiple resources
for a Web service
• Having one file not the preferred way except for
simple service examples.
4c6
Separate Resource
More generally, resource is a (stateful) class.
End Point Reference (EPR) is XML document that
has URL of service and possibly a resource
identification (key)
Classes provided for different arrangements:
ReflectionResourceProperty class used in
assign 5 (implementation of a simple Resource)
4c7
Resource Home
• Resources are managed by Resource Home's
• Provides resource management functions
– for adding resources
– for removing resources
• Although hidden in Assignment 5 where resource
and service were in one file, a Resource Home
did exist.
4c8
Resource Home
Resource home
create/
find resource
Client
Web Service
Manages
Client only
interacts with
stateless web
service
Methods
operate on
resources
properties
Resource
4c9
Service and resource code
Resource home
create/
find resource
Client
Web Service
void add(int a)
void subtract (int a)
Manages
Resource
add() and subtract()
methods operate on
resource properties
int value
String lastOP
4c10
Resource Home
Resource home
Client
Web Service
Resource
Previously, service and resource in one file and
resource limited to one resource using a globus
supplied resource home called ServiceResourceHome
4c11
Service and resource code
Web Service
Client
void add(int a)
void subtract (int a)
Resource
int value
String lastOP
Resource home
“ServiceResourceHome”
create/
find resource
ServiceResourceHome
returns service object
add() and subtract()
methods operate on
resource properties
4c12
Separately service, resource
and resource home files
4c13
Separate Service, Resource & Resource Home
files
Singleton Resources (Single resource)
Resource home
Client
Web Service
void add(int a)
void subtract (int a)
int value
String lastOP
Resource
Three files: the service, the resource home, and the resource.
4c14
Multiple Resources
Suppose there are multiple resources that a service
might interact with:
Resources
Client
Web Service
4c15
Creating Resources
WS-Resource Factory Pattern
Traditional object-oriented approach to creating
resources is to use a “factory” service:
Factory service is responsible for creating instances
of resources.
Each resource assigned a unique “key”, which
together with service URI identifies WS-resource
pair. (Endpoint Reference)
4c16
WS-Resource Factory Pattern
Factory service
Resources
Request
resource
creation
Return WSResource EPR
Request
operation
on resource
Client
Create
Perform
operation
“Instance” Service
4c17
Relationship with Resource Home
Factory Service
Use Resource Home
to create resource
Request
resource
creation
Find resource
Client
Service instance
Resource
Home
Manages
Request
operation
Methods operate on
resources properties
Resource
4c18
Factory service
Create Resource operation
endpointReference createResource()
Returns an EPR to the newly created WSResource.
“Fully qualified” EPR to include URI of service
and key of resource
Client needs to know location of factory service.
4c19
WS-Addressing Terms
Endpoint – the destination where the web
service can be accessed.
Endpoint reference, EPR –describes the
destination: includes the destination
location as URI, but can have other
parameters like a key
4c20
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
4c21
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>
4c22
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>
4c23
SOAP message
WS-Addressing standard 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>
4c24
Question
Q: Why would one want to have multiple
resources for a Web service?
4c25
Lifecycle Management
Lifecycle mechanisms available in WSRF.
GT4 provides mechanisms to specify when a
resource is automatically destroyed.
• Immediately by invoking destroy operation through
the web service
• Scheduled some time in the future
• Leased-based lifecycle management
4c26
Immediate Destruction
Destruction is requested through the web service by
the client:
math.destroy(new Destroy());
Notice that the factory is responsible for creating a
Resource, but the service instance destroys it.
Command line:
globus-wsrf-destroy -e EPR1234.epr
File containing
EPR of resource
4d.27
Scheduled Termination Time
Termination time exposed as a resource property.
Can be set with GT4 command:
wsrf-set-termination-time
Example
wsrf-set-termination-time -e EPR1234.epr 100
File containing
EPR of resource
Termination
time in seconds
4d.28
Lease-based Lifetime
• In lease-based model, resources must be kept
alive by interested parties, otherwise resource
dies.
• A lifetime for a service is set after which the service
is destroyed.
• Interested parties (clients) must renew the lease
(reset the termination time) or it will be destroyed.
• Clean up without having to use a destroy operation
explicitly.
4d.29
Question
Q: Why would one want to have a termination
time set for a resource?
4c30
Resource Properties
4c31
Resource Properties
• Resource Properties are declared in the
WSDL file
• This is a schema because it describes
how the properties must be exchanged in
XML (between clients, services, etc.)
Contents of Math.xml Schema
...
<!-- RESOURCE PROPERTIES -->
<xsd:element name="Value" type="xsd:int"/>
<xsd:element name="LastOp" type="xsd:string"/>
<xsd:element name="MathResourceProperties">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tns:Value" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:LastOp" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Resource Properties
• MathService_rp has Resource Properties
implemented the correct way
• Do globus-build-service.py rp
• deploy the gar
• restart the container
Client Code Examples
MathPortType math =
locator.getMathPortTypePort(endpoint);
math.add(10);
updateRP(endpoint,
MathConstanst.RP_VALUE,“100”);
printResourceProperties(math);
Client Code Examples
valueRP = math.getResourceProperty(
MathQNames.RP_VALUE);
value = valueRP.get_any()[0].getValue();
System.out.println("Value RP: " + value);
Resource Properties from the
Command Line
C:\> wsrf-query -s http//localhost/wsrf/
services/examples/core/rp/MathService
<ns1:MathResourceProperties
xmlns:ns1=”http://www.globus.org/namespaces/
examples/mathService_instance_rp”>
<ns1:Value>100</ns1:Value>
<ns1:LastOp>ADDITION</ns1:LastOp>
</ns1:MathResourceProperties>
Resource Properties from the
Command Line
C:\>wsrf-get-property -s
http//localhost/wsrf/services/examples/
core/rp/MathService
{http://www.globus.org/namespaces/
examples/mathService_instance_rp}Value
<ns1:Value
xmlns:ns1=”http...”>100</ns1:Value>
Notifications
4c39
Notifications
Notifying clients when something interesting
happens.
Example might be when a resource property
reaches a certain value
Could use polling but this is very inefficient.
WS-notification defines mechanisms.
4c40
Resource property changes
• Examples:
– Changes to resource property values.
– Methods added
– Methods removed
– Resources destroyed
4d.41
Subscribe for notifications
• Need client to “subscribe” to receive notifications.
• Subscriptions are for a particular topic.
• Resource implemented with GT 4 classes that
provide for automatic notifications whenever
property changes.
4d.42
Automatic notifications
Subscribed for
notification
Listening client
Resource
Notification
that value
changed
Resource
property
value
Write value
Client
Service
4d.43
GT 4 Information
Services
Monitoring and
Discovery Services
(MDS)
Principal components:
Index service
Trigger service
WebMDS
4c44
Information
services
WebMDS
Index service
Trigger service
4c45
Globus core does not include information services
such as index services.
When installed, would see it in list of services, e.g.:
Index
service
Trigger
service
4c46
Index Service
GT 4 provided with an index service that can
maintain a list of available resources.
Container
Index service
(resources with resource properties)
4d.47
Index Service
• “add” method of
ResourceHome
used to create
resource.
• Override method
to include
registering
resource with
lindex service.
Index service
XML
Register
resource
in index
service
Remove
Resource
ResourceHome
add method
Resource
properties
destroy
4c48
Querying Index Service
wsrf-query
Browse index service with the GT4 command:
wsrf-query
Example
wsrf-query –s
http://localhost:8080/wsrf/services/
DefaultIndexService '/*'
which will list resource properties in an XML format.
4d.49
“Community” Index Service
• A remote index service that holds all the
index services of the “virtual organization.”
• For example a community index service
might be at:
https://torvalds.cis.uncw.edu/wsrf/
services/DefaultIndexService
4d.50
Community index service
torvalds.cis.uncw.edu/wsrf/
services/DefaultIndexService
Local Index service
Resources
Client
Service
4d.51
Querying Community Index
Service
Have Community Index Service running.
Use wsrf-query command:
$GLOBUS_LOCATION/bin/wsrf-query -s
https://torvalds.cis.uncw.edu/wsrf/serv
ices/DefaultIndexService '/*'
Should see contents of all local index services.
4d.52
Community index service
Student 1 Index entry
Student 2 Index entry
Local Index service
Local Index service
Resources
Resources
Service
Client
Client
Service
Student 1 container
Student 2 container
Only container and GT 4 core needed at each site to handle services.
4d.53
Resource Discovery
• The local and community index services can
be searched for a particular resource
property.
• Since Resources properties are XML, can
use “XPath” queries for searching and
retrieval.
4d.54
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
4d.55
MDS4 Trigger Service
• Subscribe to a set of resource properties
• Evaluate that data against a set of preconfigured conditions (triggers)
• When a condition matches, action occurs
– Email is sent to pre-defined address
– Website updated
From: Monitoring and Discovery in a Web Services Framework: Functionality and
Performance of Globus Toolkit MDS4 Jennifer M. Schopf, Sept 11, 2006
4c56
WebMDS
Web-based interface to display resource property information.
Front-end to index services.
Sample: http://mds.globus.org:8080/webmds/
webmds?info=indexinfo&xsl=servicegroupxsl
4c57
More Information
Book
Globus Toolkit 4 Programming Java Services
Borja Sotomayor and Lisa Childer
Morgan Kaufmann, 2006.
On-line
GT4 services: http://gdp.globus.org/gt4tutorial/
4c58