|
|||||||||||||||||
Student Exercises: Build a Semantically-Aware Grid Service Using GT4This is the Unix version of the student notes. If you are using Windows, you should use the Windows version of the notes. Document Style ConventionsFor the exercises two command windows will be needed:
If you can, you might want to just colour the backgrounds of your Terminal/Command/Xterm windows to match the colours that will be used in the tutorial.
PrerequisitesThis tutorial is based on the tutorial "How to Build a Service Using GT4", also known as BAS GT4 Sticky Note tutorial, which is available here (the students have completed it on Friday 14th). In order to make sure every student starts today’s Semantic Grid tutorial with the same code base we will provide, amongst others, a code base of the sticky note tutorial with exercises 1 to 4 already completed. The instructions for getting the initial code base for this tutorial (referred to as the SG-tutorial from now on) are supplied in Chapter 1. Chapter 1. Download Globus Container and Base Sticky Note Code and Set Environment VariablesIn this chapter we will setup the environment and obtain the tools and
sources needed for the tutorial. Please download the files gt-install.zip
and sg-tutorial-install.zip from here.
The first zip file is the Globus container. The second zip file is the
code base for this tutorial. The code base contains three 3 directories,
these are: 1.1 Unzip the gt install zip file in the GT window$ mkdir /tmp/semGridTutorial/$USER 1.2 Set environment variables in the GT windowThe following commands would allow you to set the GLOBUS_LOCATION variable so that it points to the newly downloaded container. $
cd gt-install $ export JAVA_HOME=/usr/java/jdk1.5.0_07 $ export PATH=/usr/java/jdk1.5.0_07/bin:$PATH $ java -version 1.3 Unzip the tutorial zip file in the Exercise windowThis installer contains demonstration code that has been written for today's tutorial. Please note that sg-tutorial-install.zip contains two other component directories in addition to the stickynote code. Deployment of these two components are explained in Chapter 2. $ cd /tmp/semGridTutorial/$USER 1.4 Set environment variables in the Exercise window$ export GLOBUS_LOCATION=[use
the value that was echoed earlier in the GT window, not $PWD] 1.5 Build and deploy the tutorial code in the Exercise window$ ant deploy 1.6 Start a web service container without security in the GT windowWhen you run the Globus container the cursor will not return to the command prompt. This container will stay running until you exit it with Control-C. Note 2: If the command cannot be run it could be due to the fact that your user has no execution permissions to run globus-start-container. In that case, you can run chmod +x * in the bin directory. Note 1: If you need to start up the container on an alternate port, use the "-p" command-line argument (e.g., "bin\globus-start-container -nosec -p 8888" will cause the container to listen on port 8888) $ bin/globus-start-container -nosec 1.7 In the exercise window, run the create-note client against your StickyNote service$ $GLOBUS_LOCATION/bin/create-note
-s http://localhost:8080/wsrf/services/StickyNoteService Also notice that a message is displayed by the container: 2006-07-07 12:23:00,234 INFO stickynote.ManyNoteHome [Thread-2,create:52] Creating a new StickyNote. Chapter 2. Deploy the Semantic Binding Service and the Semantics Operation ProviderIn this chapter we will deploy in the Globus Toolkit container the service that will be in charge of managing the repository of semantic bindings and we will also deploy an operation provider that can act as a proxy to the Semantic Binding Service. 2.1 Check the source code files necessary for Semantic Binding Service and Semantic Operation ProviderThe following directories contain files with the source code that will be compiled and deployed: exercise-install/SemanticBindingService/src/: 2.2 Deploy the Semantic Binding Service in the Globus ContainerUsing the command line in the exercise window execute a cd command to change to the directory that corresponds to the Semantic Binding Service. Command for this is given below: $ cd /tmp/semGridTutorial/$USER/SemanticBindingService/ Once you’re in the SemanticBindingService directory do the deployment of the Semantic Binding Service. For this execute these commands from the /tmp/semGridTutorial/$USER/SemanticBindingService/ directory of the Exercise window. $ ant clean 2.3 Deploy the metadata operation provider to the Web service containerUsing the command line in the exercise window execute a cd command to change to the directory that corresponds to the Semantics OperationProvider: $ cd /tmp/semGridTutorial/$USER/SemanticsOperationProvider/ Execute these commands from the /tmp/semGridTutorial/$USER/SemanticsOperationProvider/ directory of the Exercise window. $ ant clean 2.4 Kill and restart the Web service container in the GT window $ [ctrl-c] Please note that three new services are now available in the Web service container: SemanticBindingService, SemanticBindingFactoryService and MetadataQueryService. We will use these services in the following Chapters. Chapter 3. Augment the Sticky Note Service with the Semantics Operation Provider and attach Semantics to a Sticky NoteIn this exercise we will extend the StickyNoteService with an operation from the Semantics Operation Provider so that we can attach semantic bindings to sticky notes. 3.1 Preliminar workStarting with this exercise we will be editing source files. In this section we give general guidelines for source editing throughout the tutorial. 3.1.1 How to modify filesTake care not to edit the files in the build/ subdirectory, as files
in the build/ tree are overwritten by the "ant deploy" command. You should
run If you are not familiar with commenting out XML or WSDL, the comment characters are <!-- and -->. For instance: This is not commented out All modifications you need to make to source files begin with a comment tag of "EXERCISE SEMANTIC GRID n: <type of modification needed>" and end with "END OF EXERCISE SEMANTIC GRID n <type of modification>". Some files contain more than one set of changes to be made for a given file. 3.1.2 Files necessary for this chapter and files that will be editedThe files to modify are: exercise-install/stickynote/schema/tutorial/stickynote_port_type.wsdl: The following files are the ones that will be used in this exercise. Make sure the following files exist. exercise-install/stickynote/etc/StickyNote.rdf: 3.2 Clean, rebuild and redeploy the StickyNote codeIn the previous chapter we used the exercise window to deploy the semantic related components so now we need to come back to the sticky note directory. We can do this by running the following command in the exercise window. $ cd /tmp/semGridTutorial/$USER/exercise-install/stickynote Execute these commands from the /tmp/semGridTutorial/$USER/exercise-install/stickynote/ directory of the Exercise window. $ ant clean 3.3 Kill and restart the Web service container in the GT window$ [ctrl-c] We will obtain the same output as before, since we have just redeployed the StickyNoteService. 3.4 From the exercise window, create a new note$ $GLOBUS_LOCATION/bin/create-note
-s http://localhost:8080/wsrf/services/StickyNoteService Note that the sticky note serial number will be probably different to the one shown in the previous box. It will be used in the subsequent exercises, so the serial number must be replaced by the one obtained during the execution. 3.5 Now attach a Semantic Binding to the note$ $GLOBUS_LOCATION/bin/describe-note
-e note-1107777.epr etc/StickyNote.rdf The file etc/StickyNote.rdf contains RDF code that describes the content of the note, giving information about a set of events that the note contains, about the persons involved in those events (in the case of personal events) and about the dates of some of them. That code is now attached to the sticky note as a semantic binding. Chapter 4. Query the Semantic Binding associated with a StickyNoteIn this chapter we will include one more operation from the Semantics Operation Provider which will allow us to query the content of semantic bindings associated with sticky notes. As seen in the previous chapter the content of Semantic Bindings in our tutorial is RDF. Within this chapter we will use an RDF query language namely SeRQL to query these semantic bindings. 4.1 Preliminar work. Files that will be editedexercise-install/stickynote/schema/tutorial/stickynote_port_type.wsdl: Note that while we extend the StickyNote we do not provide implementation for the newly added querySemanticBinding operation. The implementation for this operation comes from the Semantic Operation provider. 4.2 Clean, rebuild and redeploy the stickynote codeExecute these commands from the /tmp/semGridTutorial/$USER/exercise-install/stickynote/ directory of the Exercise window. $ ant clean 4.3 Kill and restart the Web service container in the GT window$ [ctrl-c] 4.4 From the exercise window, create a new note$ $GLOBUS_LOCATION/bin/create-note
-s http://localhost:8080/wsrf/services/StickyNoteService 4.5 Now attach a Semantic Binding to the note$ $GLOBUS_LOCATION/bin/describe-note
-e note-1101108432.epr etc/StickyNote.rdf 4.6 Query about the Semantic Binding attached to the noteFirst we will ask for the URIs of all the events inside the semantic binding attached to the note. The query contained in the etc/Query1.serql file is the following: "SELECT N FROM {N} rdf:type {sti:Event} USING NAMESPACE sti=<http://www.ontogrid.net/StickyNote#>" $ $GLOBUS_LOCATION/bin/query-note
-e note-1101108432.epr etc/Query1.serql Then we will ask for all the personal events that involve Oscar Corcho. The query contained in the etc/Query2.serql file is the following: "SELECT N FROM {N} rdf:type {sti:Event}; sti:involves {sti:OscarCorcho} USING NAMESPACE sti=<http://www.ontogrid.net/StickyNote#>". This query should not return any results. $ $GLOBUS_LOCATION/bin/query-note -e
note-1101108432.epr etc/Query2.serql Finally we will ask for all the events that involve a professor. The query contained in the etc/Query3.serql file is the following: "SELECT N FROM {N} rdf:type {sti:Event}; sti:involves {M} rdf:type {sti:Professor} USING NAMESPACE sti=<http://www.ontogrid.net/StickyNote#>". This query should not return any results. $ $GLOBUS_LOCATION/bin/query-note -e
note-1101108432.epr etc/Query3.serql The first query has returned as a result the event that has been explicitly specified as an instance of the class Event. The other types of events are not returned. The second and third queries do not return any results, even if it seems that they should return event 4, for the second query, and events 3 and 5, for the third query. We will see how to return these results in the next chapter. Chapter 5. Make inferences about the Semantic Binding associated to a StickyNoteIn this chapter we will include in the operation provider the code necessary to make queries to the content of sticky notes using a query language such as SeRQL and performing inferences with the code, so that queries are not simply executed over the basic RDF graph of a Semantic Binding. Instead they are run taking into account the RDFS semantics and the resulting inferred statements. 5.1 Preliminar work. Files necessary for this chapter and files that will be editedThe files to modify are: exercise-install/stickynote/schema/tutorial/stickynote_port_type.wsdl: The following files are the ones that will be used in this exercise. Make sure the following files exist. exercise-install/stickynote/etc/StickyNote.rdfs: 5.2 Clean, rebuild and redeploy the stickynote codeExecute these commands from the /tmp/semGridTutorial/$USER/exercise-install/stickynote/ directory of the Exercise window. $ ant clean 5.3 Kill and restart the Web service container in the GT window$ [ctrl-c] 5.4 From the exercise window, create a new note$ $GLOBUS_LOCATION/bin/create-note
-s http://localhost:8080/wsrf/services/StickyNoteService 5.5 Now attach a Semantic Binding to the note$ $GLOBUS_LOCATION/bin/describe-note
-e note-1101108522.epr etc/StickyNote.rdf 5.6 Query about the Semantic Binding attached to the noteFirst we will ask for the URIs of all the events inside the semantic binding attached to the note. Please note that now all the command lines contain as well a reference to the model that will be used to infer information in the queries. $ $GLOBUS_LOCATION/bin/query-note-inference
-e note-1101108522.epr etc/StickyNote.rdfs etc/Query1.serql Then we will ask for all the personal events that involve Oscar Corcho. $ $GLOBUS_LOCATION/bin/query-note-inference
-e note-1101108522.epr etc/StickyNote.rdfs etc/Query2.serql Finally we will ask for all the events that involve a professor. $ $GLOBUS_LOCATION/bin/query-note-inference
-e note-1101108522.epr etc/StickyNote.rdfs etc/Query3.serql The first query has returned as a result all the events (which are instances of the class Event or of any of its subclasses). The second query returns event 4, since it is a type of event (Personal_Event) that involves Oscar Corcho. Finally, the third query returns events 3 and 5. Note that if the model used, currently stored in etc/StickyNote.rdfs, is changed (for instance, a Personal_Event is not defined as a type of Event) then the query results could be different. Chapter 6. Query about all the semantic bindings associated to a set of Sticky NotesIn this chapter we will make queries to the content of the semantic bindings of several sticky notes using a query language such as SeRQL. For this an operation provider attached to the sticky note service will not be necessary, but a repository of semantic bindings. That is, we will not deal directly with the sticky notes but with a metadata service that is in charge of storing all the semantic bindings attached to sticky notes. 6.1 Preliminar work. Files necessary for this chapter and files that will be editedThe files to modify are: exercise-install/stickynote/etc/post-deploy.xml: The following files are the ones that will be used in this exercise. Make sure the following files exist. exercise-install/stickynote/etc/StickyNote2.rdf: 6.2 Clean, rebuild and redeploy the stickynote codeExecute these commands from the /tmp/semGridTutorial/$USER/exercise-install/stickynote/ directory of the Exercise window. $ ant clean 6.3 Kill and restart the Web service container in the GT window$ [ctrl-c] 6.4 From the exercise window, create two notes$ $GLOBUS_LOCATION/bin/create-note
-s http://localhost:8080/wsrf/services/StickyNoteService $ $GLOBUS_LOCATION/bin/create-note
-s http://localhost:8080/wsrf/services/StickyNoteService 6.5 Now attach Semantic Bindings to the notes$ $GLOBUS_LOCATION/bin/describe-note
-e note-2034287.epr etc/StickyNote.rdf $ $GLOBUS_LOCATION/bin/describe-note
-e note-4839103.epr etc/StickyNote2.rdf 6.6 Query about both Semantic BindingsFirst we will ask for the URIs of all the events inside the semantic bindings attached to the note. $ $GLOBUS_LOCATION/bin/query-all-notes
-s http://localhost:8080/wsrf/services/MetadataQueryService
etc/Query1.serql We are not performing any inferences in this query, so only the instances that are direct instances of events have been selected. The result contains events from the first semantic binding and from the second semantic binding. Now we will ask for all the personal events that involve Oscar Corcho, which returns events from both semantic bindings as well. The query contained in the etc/Query4.serql file is the following: "SELECT N FROM {N} rdf:type {sti:Personal_Event}; sti:involves {sti:OscarCorcho} USING NAMESPACE sti=<http://www.ontogrid.net/StickyNote#>" $ $GLOBUS_LOCATION/bin/query-all-notes
-s http://localhost:8080/wsrf/services/MetadataQueryService etc/Query4.serql Finally we will ask for all the personal events that are to be held on May 15th, 2006, together with the persons involved in them. This will allow us to determine whether there are any clashes in the agenda of those people. The query contained in the etc/Query5.serql file is the following: "SELECT N, M FROM {N} rdf:type {sti:Personal_Event}; sti:involves {M}; sti:eventDate {D} WHERE D LIKE \"15/05/2006\" USING NAMESPACE sti=<http://www.ontogrid.net/StickyNote#>" $ $GLOBUS_LOCATION/bin/query-all-notes
-s http://localhost:8080/wsrf/services/MetadataQueryService etc/Query5.serql (Optional) Chapter 7. Use a remote Semantic Binding ServiceIn the previous examples we have used a local deployment of both the StickyNoteService and of the SemanticBindingService, SemanticBindingFactoryService and MetadataQueryService. In this exercise we will use a remote Semantic Binding service. This will act as a common repository for all the Semantic Bindings attached to notes generated by all students. Try all the steps in chapter 6 by replacing the existing service URI (which points to the localhost server) in the deploy_jndi_config.xml file with the service URI that will be given to you by the instructors during the tutorial, and try to find out to which events you have been invited by the other students in the classroom. |
|||||||||||||||||
|