58
4c1 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 Research and Education Network (NCREN) to universities across North Carolina. Oct 15a, 2008

4c1 GT 4 Services Advanced features: A very brief overview Topics: Resource home Singleton resource Multiple resources Notifications Lifecycles Copyright

  • View
    217

  • Download
    0

Embed Size (px)

Citation preview

4c1

GT 4 Services

Advanced features:A very brief overview

Topics:Resource home

Singleton resourceMultiple resources

NotificationsLifecycles

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

Research and Education Network (NCREN) to universities across North Carolina. Oct 15a, 2008

4c2

Stateful GT 4 Grid ServicesReview

• “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.”

4c3

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.

4c4

Web Service

Resource

Resource properties

Client

Web Service Resource Framework(WSRF)

Holds information retained between accesses.

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

4c6

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.

4c7

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)

4c8

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.

4c9

Resource Home

Client Web Service

Resource home

Resource

Manages

Methods operate on resources properties

create/find resource

Client only interacts with stateless web service

4c10

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

4c11

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

4c12

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

4c13

Separately service, resource and resource home files

4c14

Separate Service, Resource & Resource Home files

Singleton Resources (Single resource)

Client Web Service

Resource home

Resource

Three files: the service, the resource home, and the resource.

void add(int a)void subtract (int a)

int valueString lastOP

4c15

Multiple Resources

Suppose there are multiple resources that a service might interact with:

Client Web Service

Resources

4c16

Creating ResourcesWS-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)

4c17

Client“Instance” Service

Resources

WS-Resource Factory Pattern

Factory service

Request resource creation

Request operation

on resource

Create

Perform operation

Return WS-Resource EPR

4c18

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

4c19

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.

4c20

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

4c21

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

4c22

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>

4c23

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>

4c24

SOAP messageWS-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>

4c25

Question

Q: Why would one want to have multiple resources for a Web service?

4c26

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

4d.27

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

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

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.

4c30

Question

Q: Why would one want to have a termination time set for a resource?

4c31

Resource Properties

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>

4c39

Notifications

4c40

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

4d.41

Resource property changes

• Examples:

– Changes to resource property values.– Methods added– Methods removed– Resources destroyed

4d.42

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

Automatic notifications

ClientService

Resource property

Write value

Notification that value changed

value

Subscribed for notification

Resource

Listening client

4c44

GT 4 Information Services

Monitoring and Discovery Services

(MDS)

Principal components:Index service

Trigger serviceWebMDS

4c45

Index service

WebMDS

Trigger service

Information services

Globus core does not include information services such as index services.

When installed, would see it in list of services, e.g.:

4c46

Index service

Trigger service

4d.47

Container

Index service

(resources with resource properties)

Index ServiceGT 4 provided with an index service that can maintain a list of available resources.

4c48

ResourceHome add method

Register resource in index service

Remove

destroy

Resource

Index service

Resource properties

XML

Index Service• “add” method of

ResourceHome used to create resource.

• Override method to include registering resource with lindex service.

4d.49

Querying Index Servicewsrf-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.50

“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.51

Local Index service

Resources

Community index service

torvalds.cis.uncw.edu/wsrf/ services/DefaultIndexService

Service

Client

4d.52

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/services/DefaultIndexService '/*'

Should see contents of all local index services.

4d.53

Local Index service

Resources

Service Client

Local Index service

Resources

ServiceClient

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

4d.54

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

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

MDS4 Trigger Service

• Subscribe to a set of resource properties

• Evaluate that data against a set of pre-configured conditions (triggers)

• When a condition matches, action occurs

– Email is sent to pre-defined address

– Website updated

4c56From: Monitoring and Discovery in a Web Services Framework: Functionality and

Performance of Globus Toolkit MDS4 Jennifer M. Schopf, Sept 11, 2006

WebMDSWeb-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

4c58

More InformationBook

Globus Toolkit 4 Programming Java Services

Borja Sotomayor and Lisa Childer

Morgan Kaufmann, 2006.

On-line

GT4 services: http://gdp.globus.org/gt4-tutorial/