Grid Services Programming Exercise

Objective: The objective of this exercise is to understand the steps in using and developing Grid services, and to understand the similarities and differences between this programming tool and other, similar, tools such as Remote Procedure Call (RPC) and Web Services. The objective is also learn to use Globus Toolkit 3 (GT3) to write and deploy a stateful Grid Service. The exercise will consist of stepping through the development of an example GT3 application that performs some arithmetic transactions for a user, such as adding to a value, subtracting from a value, and obtaining the current state of the value.

Background: Writing a Grid Service is similar to Remote Procedure Call in that the first step is to define the service interface. The interface specifies what operations will be available to the users, but it does not implement the actual operations. The interface is used to build a client and server stub, and then the client and server are implemented in possibly different languages. A runtime system performs functions such as marshalling of operands, directing client requests to the correct server instance, and returning values to the client.

In Grid Services the interface is known as the PortType. The language used for defining the interface is Web Services Definition Language (WSDL). Since WSDL is not a very user-friendly language, the Globus Toolkit 3 provides tools for defining the interface in Java first and then generating the WSDL code using an Apache Axis tool called Java2WSDL. This approach is best suited for beginners.

Grid Services have much in common with Web Services. Both Grid Services and Web Services define an interface using WSDL and offer a service-oriented view to a requesting program. There are also some significant differences between Grid Service and Web Services. Web Services have instances that are stateless and persistent. In contrast, Grid Services can be either stateful or stateless, and can be either transient or persistent. A service instance is stateless if it cannot remember prior events, and persistent (non-transient) if the instances outlive all their clients. Unlike Web Services, Grid Services use a factory approach to maintain multiple service instances. The factory manages the instances and allows the Grid Service to be stateful and transient. These can be divided into types of services as follows:

Because WSDL is used to access the services, the clients of a Grid Service can be developed using any language that have bindings to WSDL. The GT3 examples and starting code use Java to develop Grid Service applications, and use a very handy build tool known as ant. Ant greatly simplifies the compilation and building process of Grid Services. GT3 provides a build file for ant to generate the necessary executables from the source files. The build file specifies the files to be compiled, the order and the way files should be compiled. Moreover, the build file is generic so that it can be used over and over for different Grid Services, and it can be modified to suite the purpose of the programmers. All that is needed by ant is the interface description generated from a Java interface, the implementation of service written in Java, and the deployment descriptor written in WSDD.

The example provided here is a step by step guide for implementing and running the programs in the online Globus Toolkit 3 tutorial found at http://www.casa-sotomayor.net/gt3-tutorial/. It is a short version of the online tutorial customized for our environment.

For best results, you should read through the tutorial materials along the way. However, you can do this short exercise by following the steps here. To start, login to your account at kite.csce.uark.edu and perform these steps starting from your home directory.

Step 1: Copy the Globus Toolkit 3 Tutorial files to your kite account.

Step 2: Set up the environment for your userid and create a unique Grid Service source. In this example we will be modifying the Math Service that is provided by the GT3 Tutorial to run on our system using your userid. The scripts in GT3 assume that exactly one Service will be installed system-wide with a particular name. In particular, your account has been set up to have group write access to a GT3 directory that the GT3 scripts will write files into. Since several accounts will be installing the same Math Service, we will need to modify the name of the service with our own userid's to make a unique system-wide name. We also need to be sure that we use a unique subdirectory name for the source files since some of the files stored in the common directory are named according to the subdirectory that the source comes from.

Step 3: Define the Service Interface, also known as PortType. Note that you can change the file names to whatever you want, but be sure to use the correct syntax for the file and directory names. Use an Uppercase character for the first letter of your file name. For example: MyProgram.java, Math.java, Euclid.java

The interface specifies what operations will be available to the users. You will start with the files provided by the GT3 Tutorial and modify them to fit your userid. In this example Java is used to create the interface. The file should be saved with the '.java' extension.

Step 4: Implement the service. That is, write the actual Java code that performs the required operations specified in the interface. The Java code will begin with the typical package, import declarations, followed by all the necessary public and/or private methods.

Step 5: Write the Deployment Descriptor. The deployment descriptor provides the web server with information on how to publish the Grid Service. The descriptor follows the Web Service Deployment Descriptor (WSDD) format.

Step 6: Compile and deploy the Service using ant. Ant will compile the source files and generate the necessary server/client stubs and it will also create Grid Archive (GAR) files. GAR file is the actual package that will be deployed into the web server.

Step 7: Write and compile the client.

Step 8: Start the service and run the client. Since this client connects to an existing instance of the Service, the Service must be running before the client can be executed and contact the server.

Congratulations! You have written and executed your first Grid Service!!

Post exercise questions to think about:

  1. In what ways are Grid Services similar to RPC as described in the paper by Birrell?
  2. In what ways do Grid Services extend the concepts of Web Services?

Enjoy!