Grid Services with Notifications

Notifications allow clients to be notified of changes that occur in a Grid Service. An illustrative example is provided here. In this example, all the clients of a CalculatorGrid Service are notified if any operation is performed by any client.

Step 1: Creating the Grid Service from GWSDL

In order to create a Grid Service with Notifications, some changes are made to the .gwsdl file of the service and then to the Grid Service Provider implementation.
 
First, the value ogsi:NotificationSource must be added to the extends attribute of the gwsdl:portType tag in the .gwsdl file. For example, CalculatorImpl.gwsdl  is used to create a Grid Service with Notifications. Note that the gwsdl:portType tag in CalculatorImpl.gwsdl is as follows:
<gwsdl:portType extends="ogsi:GridService ogsi:NotificationSource" name="CalculatorImplPortType">

Next, an ant buildfile is used to create a Top Down Grid Service using this .gwsdl file. For example, build.xml is used to create the Calculator Service using CalculatorImpl.gwsdl by executing the following command:
[purshah@danube mytry]$ ant createTopDownGridService

The corresponding output is shown in build_output.txt.

Step 2: Changes in the Implementation

Add whatever functionality is to be implemented within the operations of the Grid Service. And changes need to be made to the Grid Service Provider that implements OperationProvider and GridServiceCallBack. These changes are mainly with respect to Service Data.

For example, in CalculatorImplProvider.java, all the changes are marked with a comment //Added by Purvesh.

Step 3: Create a GAR

Create a Grid Service Archive (GAR) for the service.

For the Calculator Service, this is done using the command:
[purshah@danube mytry]$ ant topDownGar

The corresponding output is shown in gar_output.txt.

Step4: Deploy the Grid Service

In your GTK3.0 directory, use the command ant deploy -Dgar.name=<path to gar created in previous step> to deploy the Grid Service.

For example, the Calculator Service is deployed using the following command:
[purshah@danube test_install_dir]$ ant deploy -Dgar.name=/home/purshah/test_install_dir/mytry/notification/notificationCalculatorService.gar

The corresponding output is shown in deploy_output.txt.

Step 5: Run the Grid Service

Once the service is deployed, start the container in GTK 3.0. This is done by using the command ant startContainer from the GTK 3.0 directory.

Then in another window, create an instance of the Grid Service using java org.globus.ogsa.client.CreateService <service-url> <id>. In this command, <service-url> is the Grid Service Handle (GSH) of the Grid Service Factory that must produce an instance of the Grid Service called <id>.

For example, an instance named calc is created when the following command is executed:
[purshah@danube test_install_dir]$ java org.globus.ogsa.client.CreatService http://localhost:8080/ogsa/services/services/DefaultNamespace/CalculatorImplProviderFactoryService calc

The corresponding output was as follows:
Termination Time: infinity
Created service with reference:
<definitions name="CalculatorImpl" targetNamespace="http://DefaultNamespace/service" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:calculatorimplbinding="http://DefaultNamespace/bindings" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"><import location="http://156.56.104.61:8080/schema/services/DefaultNamespace/CalculatorImpl_bindings.wsdl" namespace="http://DefaultNamespace/bindings"/><service name="CalculatorImplService" xmlns:gsdl="http://ogsa.globus.org/"><gsdl:instanceOf handle="http://156.56.104.61:8080/ogsa/services/services/DefaultNamespace/CalculatorImplProviderFactoryService/calc" xmlns=""/><gsdl:instanceOf handle="http://156.56.104.61:8080/ogsa/services/instance" xmlns=""/><port binding="calculatorimplbinding:CalculatorImplSOAPBinding" name="CalculatorImplPort"><soap:address location="http://156.56.104.61:8080/ogsa/services/services/DefaultNamespace/CalculatorImplProviderFactoryService/calc"/></port></service></definitions>

Step 6: Create and use Clients

In order to make use of the Notifications feature incorporated in the Grid Service, there must be a Listener running at the client side. The Listener receives all the notifications.

For the Calculator Service, there are two clients:
  1. CalcListener.java - This acts as the Listener and receives all notifications.
  2. CalcAdder.java - This is a simple client which adds two numbers using the methods/operations provided by Calculator Service. Everytime this operation is performed from the client side, all the other Listerners are notified.
Now, first compile and run CalcListener.java as follows:
[purshah@danube notification]$ javac client/CalcListener.java
[purshah@danube notification]$ java -Dorg.globus.ogsa.schema.root=http://localhost:8080/ client.CalcListener http://localhost:8080/ogsa/services/services/DefaultNamespace/CalculatorImplProviderFactoryService/calc

Then the following message should be displayed:
Listening..

Keep the Listener running.

Next, in a new window, compile and run CalcAdder.java as follows:
[purshah@danube notification]$ javac client/CalcAdder.java
[purshah@danube notification]$ java client.CalcAdder http://localhost:8080/ogsa/services/services/DefaultNamespace/CalculatorImplProviderFactoryService/calc 10 15

The corresponding output message is as follows:
Sum:25

At the same time, in the Listener window, the following message is displayed:
Operation performed!