A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid...

27
A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    215
  • download

    0

Transcript of A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid...

Page 1: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.1ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson

Assignment 2

“Simple” Grid Services Assignment

Page 2: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.2

GT 4 Stateful Web Services

Preliminaries

• Web services as created in assignment 1 are stateless.

• Stateful web services required for grid computing.

• Obtained in WS-RF by having a web service front-end to a stateful “resource.”

Page 3: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.3

Web Service

Resource

Resource properties

Client

Web Service Resource Framework(WS-RF)

Holds information retained between accesses.

Page 4: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.4

Assignment Goals

• Build on the Web Services assignment.

• Show how stateful WS-RF web services can be created using Globus 4.0

• See the difference between stateful WS-RF web services and stateless Web services.

Page 5: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.5

Purpose of Service

To store an integer value which can be acted upon by methods to:

• Get its value• Increment its value (add one), and• Decrement its value (subtract one).

These methods are given. Further methods will be implemented. The service is stateful (the value is retained between accesses).

Page 6: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.6

Resource Properties

In the code provided in assignment 2, there are actually two resource properties:

• Value -- an integer acted upon by the operations: add, sub, and getValueRP

and

• “Last operation performed” -- a string holding the name of the last operation done, addition or subtraction, which is not used in assignment 2

Page 7: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.7

Math Web Service

Resource

Resource properties“value”

(integer)

“last operationperformed”

(string)

Client

Assignment 2 Resource Properties

Page 8: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.8

Steps in Assignment 2

• Preliminary set-up.

• Define the Service Interface using WSDL

• Write the stateful web service code using Java

• Write the Deployment Descriptor

• Build the Math service

• Deploy the Math service

• Write and compile the client

• Start the container and execute the client

• Add functionality to the service

Page 9: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.9

WSDL and Service Implementation

• In Assignment 1, we wrote the service implementation first and then provided the WSDL description.

Page 10: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.10

Service Implementation

• In Assignment 2, we will start with the interface/WSDL and write the implementation second.

• This is a more appropriate way from a software engineering perspective, i.e. describe what we want to do first and do a specific implementation afterwards.

Page 11: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.11

Step 1: Preliminaries

The files that you will need for this assignment are provided in a tar file:

http://cs.wcu.edu/~certauthority/ new_assignment2.tar.gz

which you download.

This tar includes specially written scripts.

Page 12: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.12

Step 2: Defining service Interface using WSDL

WSDL file is provided in the tar file in:

assignment2/schema/

examples/MathService_instance/Math.wsdl

This file is discussed in detail in Assignment 2 “Presentation slides” and in lecture slides slides4c.

Page 13: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.13

Step 2 Implement Service Using Java

Service is implemented in Java. Code provided in the tar file at:

assignment2/org/globus/examples/services/

MathService/impl/MathImpl.java

Page 14: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.14

Service

The code has two major parts:

• Resource properties• Service code (methods)

which are combined into one file for this assignment.

Page 15: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.15

Service – Resource Propertiespublic class MathService implements Resource, ResourceProperties { private ResourcePropertySet propSet; /* Resource Property set */ private int value; private String lastOp; public MathService() throws RemoteException { /* RP Constructor */

this.propSet = new SimpleResourcePropertySet( MathQNames.RESOURCE_PROPERTIES); /* Create RP set */ try { /* Initialize the RP's */ ResourceProperty valueRP = new ReflectionResourceProperty( MathQNames.RP_VALUE, "Value", this); this.propSet.add(valueRP); setValue(0); ResourceProperty lastOpRP = new ReflectionResourceProperty( MathQNames.RP_LASTOP, "LastOp", this); this.propSet.add(lastOpRP); setLastOp("NONE"); } catch (Exception e) { throw new RuntimeException(e.getMessage()); }}

Resource Property code

Resource properties

Page 16: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.16

/* Get/Setters for the RPs */

public int getValue() {

return value;

}

public void setValue(int value) {

this.value = value;

}

public String getLastOp() {

return lastOp;

}

public void setLastOp(String lastOp) {

this.lastOp = lastOp;

}

Service – Resource Properties methods

Page 17: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.17

Service code - methods /* Remotely-accessible operations */  public AddResponse add(int a) throws RemoteException { value += a; lastOp = "ADDITION"; return new AddResponse(); }  public SubtractResponse subtract(int a) throws

RemoteException { value -= a; lastOp = "SUBTRACTION"; return new SubtractResponse(); }  public int getValueRP(GetValueRP params) throws

RemoteException { return value; } /* Required by interface ResourceProperties */ public ResourcePropertySet getResourcePropertySet() { return this.propSet; }

Page 18: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.18

Step 4: Writing Deployment Descriptor

Code for deployment descriptor for service is provided in:

org/globus/services/MathService/server-deploy.wsdd

Page 19: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.19

Step 5: BuildingInitial building in assignment 2 is done using (in essence) the GT4 command (script):

globus-build-service

This command is embedded in a script:

build.sh

which also includes a script called:

nameChangeScript

to rename student files to make them each unique.

Page 20: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.20

Step 6: Deploying Service

Deployment is done using the GT4 command:

globus-deploy-gar

as user “globus”, using gar file created by globus-build-service.

Page 21: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.21

Step 7: Write and Compile Clientpublic class Client {public static void main(String[] args) {MathServiceAddressingLocator locator = new MathServiceAddressingLocator();try {String serviceURI = args[0];EndpointReferenceType endpoint = new EndpointReferenceType();endpoint.setAddress(new Address(serviceURI)); //service endpt ref.MathPortType math; math = locator.getMathPortTypePort(endpoint); // Get PortType

math.add(10); // Perform an addition math.add(5); // Perform another addition System.out.println("Current value: " + math.getValueRP(new GetValueRP())); // Access value

math.subtract(5); // Perform a subtraction System.out.println("Current value: " + math.getValueRP(new GetValueRP())); // Access value} catch (Exception e) {e.printStackTrace();}}} 

Page 22: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.22

Step 7 (continued)

The code for the client is provided in:

assignment2/org/globus/examples/clients/MathService_instance/Client.java

Compile it using javac.

Page 23: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.23

Steps 8-9: Start Container

As user globus, start Globus container on a TCP port not in use:

globus-start-container -p 8081

This example assumes port 8081 is not in use; use netstat –t –all to see which ports are in use.

MathService will be listed as two of the services that are available once the container has started.

Page 24: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.24

Step 10: Execute Client

Execute client:

java –classpath ./build/classes/org/globus/examples/services/core/yourusername_first/impl/:$CLASSPATH org/globus/examples/clients/MathService_instance/Clienthttp://localhost:yourportnumber/wsrf/services/examples/

core/yourusername_first/MathService

You will see the following result (hopefully): Current value: 15 Current value: 10

 

Page 25: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.25

Step 11 Undeploy sevice

Deploy service in preparation to modifying it.

As user Globus, issue command:

globus-undeploy-gar

with (re)named gar file.

Page 26: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.26

Step 12: Extend Functionality of Service

Add a multiply method to your Math Service.

Repeat all the steps to test it.

Page 27: A2.1 ITCS 4010/5010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson Assignment 2 “Simple” Grid Services Assignment.

A2.27

Acknowledgment

This assignment is derived from Borja Sotomayor’s Globus Toolkit 4 Programmer’s Tutorial:

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