350 likes | 363 Views
This resource provides instructions for building and deploying the Sticky Note Service, as well as creating new notes. It uses the Java GT4 core and requires JDK and Apache Ant.
E N D
Web Service Resource Framework Notes on “sticky note” assignment Grid Computing, B. Wilkinson, 2005
Environment • Uses the Java GT4 core, which can be installed directly on a PC. • Needs: • jdk, Java software development kit • ant, open source tool for building java code
Sticky Note Service • Represents a “sticky note as one might stick on the wall to give reminders. • Resource property: a string containing the sticky note text Assignment due tomorrow
Sticky Note Operations • Operations: • Write text into a note – “write-note” • Display the text of a note – “show-note” • Create a note (introduced in Exercise 2)
Exercise 1 • Build sticky note service • Deploy sticky note service. (Uses ant, not GT4 deploy command) • Start GT4 container • Execute a “show-note” client to use the show-note operation
Building/Deploying service • Uses command: ant deploy where deploy is an xml build file.
Starting container $ bin/globus-start-container -nosec No Security -- Do not use GT 4 security mechanisms
Starting SOAP server at: http://192.168.123.100:8080/wsrf/services/ With the following services:[1]: http://192.168.123.100:8080/wsrf/services/InMemoryServiceGroupEntry[2]: http://192.168.123.100:8080/wsrf/services/TriggerFactoryService[3]: http://192.168.123.100:8080/wsrf/services/IndexFactoryService[4]: http://192.168.123.100:8080/wsrf/services/Version[5]: http://192.168.123.100:8080/wsrf/services/IndexService[6]: http://192.168.123.100:8080/wsrf/services/NotificationConsumerService[7]: http://192.168.123.100:8080/wsrf/services/DefaultTriggerServiceEntry[8]: http://192.168.123.100:8080/wsrf/services/TriggerServiceEntry[9]: http://192.168.123.100:8080/wsrf/services/IndexServiceEntry[10]: http://192.168.123.100:8080/wsrf/services/StickyNoteService[11]: http://192.168.123.100:8080/wsrf/services/AdminService[12]: http://192.168.123.100:8080/wsrf/services/DefaultIndexService[13]: http://192.168.123.100:8080/wsrf/services/DefaultIndexServiceEntry[14]: http://192.168.123.100:8080/wsrf/services/DefaultTriggerService[15]: http://192.168.123.100:8080/wsrf/services/ShutdownService[16]: http://192.168.123.100:8080/wsrf/services/ContainerRegistryService[17]: http://192.168.123.100:8080/wsrf/services/TriggerService[18]: http://192.168.123.100:8080/wsrf/services/gsi/AuthenticationService[19]: http://192.168.123.100:8080/wsrf/services/InMemoryServiceGroupFactory[20]: http://192.168.123.100:8080/wsrf/services/InMemoryServiceGroup[21]: http://192.168.123.100:8080/wsrf/services/ContainerRegistryEntryService[22]: http://192.168.123.100:8080/wsrf/services/SubscriptionManagerService All https if security used The deployed StickyNote Servicce
Executing show-note client Command: $GLOBUS_LOCATION/bin/show-note -s http://localhost:8080/wsrf/services/StickyNoteService Get: <ns1:message xmlns:ns1=http://tutorial.globus.org/stickynote >hello.</ns1:message> This is the message on the sticky note
Executing write-note client $GLOBUS_LOCATION/bin/write-note -s http://localhost:8080/wsrf/services/StickyNoteServicecheeseMessage written. This is the text to be written in sticky note
Exercise 2Creating a Resource • In this exercise, you are asked to modify files to introduce the “create note” operation. • Files to modify: • sticky note service wsdl file, to include the create note operation • Sticky note service code, to include the create note operation • jndi deployment configuration file • Also create a “create-note” client
Resource Home • For managing resources. • Must modify Resource Home from Exercise 1 so as to handle multiple resources. • Done in deploy-jndi-conf.xml, by changing type of resource from “SingleNoteHome” to “ManyNoteHome” and associated details changed also.
Creating a new note $GLOBUS_LOCATION/bin/create-note -s http://localhost:8080/wsrf/services/StickyNoteServicenew note created...EPR written to file: note--1947556620.epr To see note: $GLOBUS_LOCATION/bin/show-note -e note--1947556620.epr<ns1:message xmlns:ns1=http://tutorial.globus.org/stickynote >hello.</ns1:message> Endpoint Reference
Sample 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”
Sticky Note EPR Endpoint reference = EPR1 + resource “key” EPR1 (service URI) StickyNote service Resource Key Resource property “cheese” With multiple resources, each resource assigned a unique key identifying it
Exercise 3Destroying Resources • Add an operation “destroy” in service wsdl file • Add “DestroyProvider operation provider” in wsdd file • Test by creating Sticky note and using GT4 “wsrf-destroy” command.
Exercise 4Adding a resource property • A “lastModified” resource property is added which records the time that the sticky note message was last altered. • Requires 4 files to be modified: • wsdl file • Service code • A file containing constants • Client code to test it
Exercise 5Register with a Local Index Service • GT 4 provided with an index service that can maintain a list of available services. • Index service acts as local service registry. • In Exercise 5, the service is registered with the local GT 4 index service.
Container Index service Multiple Sticky notes (resources with resource properties) Note, the exercises asks each person to start their own container
Details to use index service • When resource created, “add” method of ResourceHome called. • Need to override this method to include registering Resource with local index service. • Need to modify ManyNoteHome.java
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.
Exercise 6Register with a “Community” Index Service • A remote index service is used, which holds all the services of the “virtual organization.” • For our purposes, the community index service is at: http://beowulf.bear.uncw.edu:8080/wsrf/ services/DefaultIndexService
Community index service beowulf.bear.uncw.edu:8080/wsrf/services/ DefaultIndexService Local Index service Sticky note resources client StickyNote service
Implementation • Configure local index to register with community index service. • All local information, including service resource properties, copied to community index service.
Implementation Modify the file: $GLOBUS_LOCATION/etc/globus_wsrf_mds_ index/hierarchy.xml to include the URL of the community index service (<upstream> parameter)
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.
Community index service Student 1 Index entry Student 2 Index entry Student 1 container Local Index service Resources Local Index service Resources client Service client Service Student 2 container Only container and GT 4 core needed at each site to handle services.
Exercise 7Lease-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.
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 Termination time in seconds File containing EPR of resource (StickyNote)
Implementation • Add subscribe operation to wsdl file. • Add SubscribeProvider to wsdd file. • Modify StickyNote.java • Modify post-deploy.xml file See exercise write-up for more details
Exercise 8Notifications • 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
In exercise 8, a second service, called watch-note, is used to display changes to the value of the StickyNote. watch-note Notification that note changed StickyNote resource property Different container Client Write note StickyNote Service
In Exercise 8, a second service, called watch-note, is used to inform the client of changes to the value of the StickyNote. • Need the client to “subscribe” to receive notifications. • Subscriptions are for a particular topic.
Exercise 9Resource Discovery • In this exercise, the local and community index services are searched for a particular StickyNote message. • 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)
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