Vous êtes sur la page 1sur 97

Grid Architecture

Distributed Systems Laboratory KNU

Outline
Introduction to Grid Architecture Basic Components of a Grid WSRF and OGSA: Creating Grid Enabled Web Services
Web services WSRF OGSA

Creating MathService in RMI and WSRF

Designing Parallel Behavior in CORBA


What should be the interface between ORB and parallel codes? How should the IDL be changed? What should happen at the client stubs? What should be the data distribution model? What should happen to the result of the parallel object invocation?

PaCO (Parallel CORBA Object)


Collection of Standard CORBA Objects Separate object for each SPMD process. Objects combine to form collection. During remote invocation, method is executed concurrently in all objects.

Generic Grid Architecture/Components


Problem Solving Environments

Grid Access & Info User Portals

Application Science Portals

Service Layers Authentication

Scheduling & Co- Scheduling

Naming & Files

Resource Discovery & Allocation Events

Fault Tolerance

Computers Resource Layer

Data bases Online instruments

Software

High speed networks and routers


5

Early Proto-Grids (Meta-Computers)


For powerful computation, why not institutions (clustered infra) cooperate with other institutions? Problems of cooperation:
clusters typically consisted of identical or similar machines long network connections are unacceptable for cluster technology security threats administrative and political issues

How to effectively connect and harness the geographically dislocated computer power? Answer: meta-computing

Early Proto-Grids (Meta-Computers) (2)


Meta-computing: knowledge of available compute servers stored in a meta-computer Some meta-computing solutions
Ninf Japanese project middleware programming on Grid Unicore Germany provided job submission Condor scheduling and resource management Legion object oriented programming model Globus Toolkit not a complete solution but rather system integrators toolkit

Early Design of Globus


GIIS Grid Index Information Service GRIS Grid Resource Information Service Higher level software DUROC Dynamic Updated Request Online Coallocator GRAM Grid Resource Allocation & Management

GIIS

DUROC

GRIS

GRAM

GRIS

GRAM

GRIS

GRAM

GLOBUS and JVM


Java Virtual Machine lowers the cooperation boundary between architectures but does not take full advantage of the specifics of the underlying hardware.
applications done in Java can execute on any OS with JVM performance of java applications are not optimized

Globus provides a uniform API for high-level functions like discovery and job submission but does not ease building the application across platforms.
resource sharing can be used to divide the workloads not easy to integrate with applications
9

Basic Components of a Grid

10

Non-Computational Resources
Resource (Grid) is any element of the networked infrastructure that is made available for usage with standardized Grid protocols.
storage system with standardized interfaces network sensors, telescopes, industrial infra and other specialized instruments application software where confidentiality of data is managed

Each resource has a feature set that makes it unique. Resource interfaces differs in characteristics that is important for interoperability.

11

Non-Computational Resources (2)


Resource communicates using each interfaces. Network is the means of transporting communication between resources. People interact with the system interfaces via visual applications, command shells or web portals. Interoperability of the interfaces is among the crucial problems in building the distributed environment.

12

Virtualization
While the hardware capabilities are constant, the application demand fluctuates overtime. service pool : adopt an organized approach to pooling the resources. Virtualization: applications contact the services to submit their processing request but do not need to know the execution. Benefits of virtualization
better classification and presentation of capabilities effective utilization of common resources thinner and better maintainable application layer common access to rare resources
13

Virtualization Organization
On the management layer, the entities are constrained by membership to various categories A VO is a set of Grid entities that are related to each other by some level of trust United for a common goal rather than membership One grid could host several VOs, an entity may join several host and VOs can overlap

14

Virtual vs. Organic Structure


Virtual communities (virtual organizations) are many An individual will typically be part of many communities
has different roles in different VOs (distinct from organizational role) all at the same time, at the same set of resources but will require single sign-on across all these communities

Trust Relationships
For the VO model to work, parties need a trust relationship
the alternative: every user needs to register at every resource we need to provide a sign-on for the user that works across VOs

Org. Certification Authority

Org. Certification Authority

Policy Authority

Policy Authority

Sub-Domain A1

Sub-Domain B1

Domain A

Task

Domain B
AuthZ Service Federation GSI Server X

Virtual Organization Domain

Server Y

Federated Certification Authorities

Security for Virtualization Organization


Secure communications for Grid entities.
communication channel encryption (SSL) message integrity (PKI)

Access to service must preceded by authorization process. Requirements for VO


Grids and VOs are built on top of real organization possible to create and manage dynamic trust domains services are created dynamically

Proxy certificates (GSI) allows other host to process the services of an original host.

17

The Case for Open Grid Service

Interface

Interface

Grid adapter Scheduler service


Another scheduler service

18

Open Grid Service Architecture


OGSA is an attempt to standardize and categorize the various higher level services that are considered crucial for grids OGSA assumes that such application are built on top of service layers composed of Grid services adhering to the WSRF specifications OGSA defines functional requirements for the Grid infrastructure

19

WSRF and OGSA: Creating Grid Enabled Web Services

20

Web Service

Web Applications
Web is designed for application to human interactions.
Information sharing: a distributed content library. Enabled B2C e-commerce. Non-automated B2B interactions.

The Web is everywhere. There is a lot more we can do!


Open, automated B2B e-commerce: Business process integration on the Web. Collaboration on science researches.

Current approach is ad-hoc on top of existing standards.


e.g., application-to-application interactions with HTML forms.

22

What is the Web Service (WS) technology?


Web services define a technique
For describing software components to be accessed Methods for accessing these components Discovery methods that enable the identification of relevant service providers

A web service is a piece of software that is made available on the Internet and utilizes a standardized XML messaging system. In other words a web service is a remote procedure call over the Internet using XML messages. Web services standards are being defined within the W3C (World Wide Web Consortium) and other standard bodies

23

WS Standards 1: SOAP and WSDL

Service requester
Service interface: WSDL file (XML)

Service provider

Messages: SOAP XML over HTTP

SOAP provides a means of messaging between a service provider and a service requester. SOAP is a simple enveloping mechanism for XML payloads that defines an RPC convention. Benefit: loosely coupling components by document oriented communication 24

WS Standards 2: UDDI
How can I discover business partners with compatible web service solutions? How do let other business know about my exposed web services? Web services are great, after you find out about them, but the discovery process is difficult Information system for Web services: UDDI - Universal Description, Discovery and Integration

25

The WS vision
1.
SW companies, standards bodies, and programmers populate the registry with descriptions of different types of services Marketplaces, search engines, and business apps query the registry to discover services at other companies

4.

2.

UDDI Business Registry


Business Registrations Service Type Registrations

5.

Businesses populate the registry with descriptions of the services they support

3.

UBR assigns a programmatically unique identifier to each service and business registration

Business uses this data to facilitate easier integration with each other over the Web

Business processes realized by on-demand workflows of Web services

26

Web Services Are Not Enough


Barebones Web services lacked security, reliability and performance.
independent implementations benefit from common set of higher level functions

SOA implies the next step of evolution of distributed architecture but will break the security model of enterprises. Web services are static and cannot provide developers to design on-demand systems. What is needed? Service-base utility computing paradigm Technology needed: cross-organizational virtualization of the resources
27

Business Meets Academia


Grid computing technology needs a protocol fabric generic enough for any resource to be abstracted as a service: XML and SOAP. Globus Toolkit 2.x has no service interoperability. XML and SOAP of Web services seem to fill up the requirements for interoperability. Business community started to notice the enormous business value of Grid computing.
more effective separation of service providers and consumers on-demand services and dynamic service provisioning

28

Business Meets Academia(2)


Web service and Grid computing communities were heading in the same direction. Global Grid Forum (GGF), in 2001, discussed the need for interoperability by creating protocol standards. Formed working groups to focus on certain standards.

29

Grid Technology: Take Services Seriously


Model the world as a collection of services
Computations, computers, instruments, storage, data, communities, agreements,

Focus on what these things have in common


E.g., state modeling & lifecycle: Negotiation, deployment/creation, modeling, monitoring, management, termination E.g., security: Authentication, authorization, audit,

Result is Grid infrastructure


Using Web services as a platform

30

A Grid Services
Describe Web service interfaces that implement useful behaviors
primitives: resources, state, security services: program execution, data movement, data access,

Also, describe open source software that implements those interfaces


in particular, Globus Toolkit (GT4)

This is all standard Web services!


Grid is a use case for Web services, focused on resource management

31

Web Service Resource Framework

The Emergence of Open Grid Standards

Increased functionality, standardization

Computer science research


Web services, etc. Open Grid Services Arch

Managed shared virtual systems

Internet standards
Custom solutions

Real standards Multiple implementations

Globus Toolkit
Defacto standard Single implementation

1990

1995

2000

2005

2010 33

Why Open Standards Matter


Ubiquitous adoption demands open, standard protocols
Standard protocols enable interoperability Avoid product/vendor lock-in Enables innovation/competition on end points

Further aided by open, standard interfaces and APIs


Standard APIs enable portability Allow implementations to port to different vendor platforms

34

OGSI to WSRF
Open Grid Service Infrastructure (OGSI) was published by the Global Grid Forum (GGF) in June 2003
intended to provide an infrastructure layer for the Open Grid Services Architecture (OGSA) extending Web services to accommodate grid computing resources that are both transient and stateful

IBM realized that OGSI was too far from standard Web services OGSI was replaced by WS Resource Framework which is more appropriate WSRF retains essentially all of OGSI concepts
35

WS-Resource Framework
Researchers from Globus group and IBM, in 2004, proposed a standard called WS-Resource Framework (WSRF) WSDL (Web Service Definition Language) is the language on creating interfaces WS-Resource is a resource associated with a Web service WSRF aim is to define the foundation of virtualized service layer and its relation to the resource layer Standardized layer for virtualized services will ease and open the communication of services

36

Standard Web Services Interfaces & Behaviors


Naming and bindings (basis for virtualization)
Every service instance has a unique name, from which can discover supported bindings

Lifecycle (basis for fault resilient state management)


Service instances created by factories Destroyed explicitly or via soft state

Information model (basis for monitoring & discovery)


Service data (attributes) associated with GS instances Operations for querying and setting this info Asynchronous notification of changes to service date

Service Groups (basis for registries & collective svcs)


Group membership rules & membership management

Base Fault type

37

WSRF Specification
Defines fundamental interfaces (using extended WSDL) and behaviors that define a Grid Service
A unifying framework for interoperability & establishment of total system properties

Defines WSDL conventions and extensions


For describing and naming services

Defines basic patterns of interaction, which can be combined with each other and with custom patterns in a myriad of ways

38

Grid Infrastructure: Open Standards


Applications of the framework (Compute, network, storage provisioning, job reservation & submission, data management, application service QoS, )

WS-Agreement (Agreement negotiation)

WS Distributed Management (Lifecycle, monitoring, )

WS-Resource Framework & WS-Notification* (Resource identity, lifetime, inspection, subscription, ) Web services (WSDL, SOAP, WS-Security, WS-ReliableMessaging, )
39

*WS-Transfer, WS-Enumeration, WS-Eventing, WS-Management define similar functions

A WSRF Illustration
Client
Introspection: What port types? What policy? What state? Lifetime management Explicit destruction Soft-state lifetime Data access Other standard interfaces: factory, notification, collections Service
data element

GridService (required)

Grid Service Handle

handle resolution
Grid Service Reference

Service data element

Service data element

Implementation
Hosting environment/runtime (C, J2EE, .NET, )

40

The WSRF Specification


The Web Services Resources Framework is a collection of 4 different specifications:
WS-ResourceProperties WS-ResourceLifetime WS-ServiceGroup WS-BaseFaults

Related specifications
WS-Notification WS-Addressing

41

Open Grid Service Architecture

Open Grid Services Architecture


Service-oriented architecture
Key to virtualization, discovery, composition, local-remote transparency

Leverage industry standards


Internet, Web services

Distributed service management


A component model for Web services

A framework for the definition of composable, interoperable services

The Physiology of the Grid: An Open Grid Services Architecture for Distributed Systems Integration, Foster, Kesselman, Nick, Tuecke, 2002

OGSA Structure
A standard substrate:
Standard interfaces and behaviors that address key distributed system issues A refactoring and extension of the Globus Toolkit protocol suite

supports standard service specifications


Resource management, databases, workflow, security, diagnostics, etc., etc. Target of current & planned GGF efforts

and arbitrary application-specific services based on these & other definitions

Globus Toolkit version 2 (based on custom protocols)

Web Services Components

Pre-WS Authentication Authorization

GridFTP

Grid Resource Monitoring Alloc. Mgmt & Discovery

(GRAM)

(MDS)

C Common Libraries

Non-WS Components

Security

Data Mgmt

Execution Mgmt

Info Services

Common Runtime

Globus Toolkit version 3 OGSI based (~pre WSRF)


Community Data Access Authorization & Integration
WS Authentication Authorization Pre-WS Authentication Authorization

Reliable File Transfer

Grid Resource Alloc. Mgmt (WS GRAM)

MDS3

Java WS Core

Web Services Components

GridFTP
Replica Location

Grid Resource Monitoring Alloc. Mgmt & Discovery

(GRAM)

(MDS)

C Common Libraries eXtensible IO (XIO)

Non-WS Components

Security

Data Mgmt

Execution Mgmt

Info Services

Common Runtime

Globus Toolkit version 4 WSRF based


Grid Telecontrol Protocol Delegation Data Replication Community Scheduling Framework WebMDS Python WS Core C WS Core Java WS Core

Core Contrib/ Preview Deprecated

Community Data Access Workspace Authorization & Integration Management


Authentication Authorization

Trigger

Reliable File Transfer

Grid Resource Allocation & Management

Web Services Components

Index

Pre-WS Authentication Authorization

GridFTP
Replica Location Data Mgmt

Pre-WS Pre-WS Grid Resource Monitoring Alloc. & Mgmt & Discovery

C Common Libraries eXtensible IO (XIO) Common Runtime

Credential Mgmt Security

Non-WS Components

www.globus.org
Execution Mgmt Info Services

Security Service
Data Replication Credential Mgmt Delegation
Community Authorization
Authentication Authorization

Globus Toolkit v4 www.globus.org


Grid Telecontrol Protocol

Replica Location
Data Access & Integration

Community Scheduling Framework


Workspace Management
Grid Resource Allocation & Management

WebMDS

Python Runtime
C Runtime Java Runtime Common Runtime

Reliable File Transfer

Trigger

GridFTP
Data Mgmt

Index
Info Services

Security

Execution Mgmt

48

Grid Security Infrastructure (GSI)


Extensions to standard protocols & APIs
Standards: SSL/TLS, X.509 & CA, GSS-API Extensions for single sign-on and delegation

Globus Toolkit reference implementation of GSI


SSLeay/OpenSSL + GSS-API + SSO/delegation Tools and services to interface to local security
Simple ACLs; SSLK5/PKINIT for access to K5, AFS;

Tools for credential management


Login, logout, etc. Smartcards MyProxy: Web portal login and delegation K5cert: Automatic X.509 certificate creation

User Proxies
Minimize exposure of users private key A temporary, X.509 proxy credential for use by our computations
We call this a user proxy certificate Allows process to act on behalf of user User-signed user proxy cert stored in local file Created via grid-proxy-init command

Proxys private key is not encrypted


Rely on file system security, proxy certificate file must be readable only by the owner

Delegation
Remote creation of a user proxy Results in a new private key and X.509 proxy certificate, signed by the original key Allows remote process to act on behalf of the user Avoids sending passwords or private keys across the network

Community Authorization Service


Community Authorization Service (CAS)
Community negotiates access to resources Resource outsources fine-grain authorization to CAS Resource only knows about CAS user credential
CAS handles user registration, group membership

User who wants access to resource asks CAS for a capability credential
Restricted proxy of the CAS user cred., checked by resource

CAS provides user community with information needed to authenticate resources


Sent with capability credential, used on connection with resource Resource identity (DN), CA

Execution Management
Data Replication Credential Mgmt Delegation
Community Authorization
Authentication Authorization

Globus Toolkit v4 www.globus.org


Grid Telecontrol Protocol

Replica Location
Data Access & Integration

Community Scheduling Framework


Workspace Management
Grid Resource Allocation & Management

WebMDS

Python Runtime
C Runtime Java Runtime Common Runtime

Reliable File Transfer

Trigger

GridFTP
Data Mgmt

Index
Info Services

Security

Execution Mgmt

53

I. Foster, Globus Toolkit Version 4: Software for Service-Oriented Systems, LNCS 3779, 2-13, 2005

Managing Computers & Computation


GRAM (Grid Resource Allocation & Management) service
Negotiate access Stage code Monitor service Manage service Collect accounting data

Client GRAM

Can negotiate access to clusters, creation of virtual machines, establishment of virtual networks,
54

Community Scheduler
Individual users
Require service Have application goals

Community schedulers
Broker service Aggregate scheduling

Individual resources
Provide service to clients Have policy autonomy

Data Management
Data Replication Credential Mgmt Delegation
Community Authorization
Authentication Authorization

Globus Toolkit v4 www.globus.org


Grid Telecontrol Protocol

Replica Location
Data Access & Integration

Community Scheduling Framework


Workspace Management
Grid Resource Allocation & Management

WebMDS

Python Runtime
C Runtime Java Runtime Common Runtime

Reliable File Transfer

Trigger

GridFTP
Data Mgmt

Index
Info Services

Security

Execution Mgmt

56

Managing Storage & Data


Service interfaces for managing storage & data movement
Storage management (SRM, NeST) Data movement (GridFTP, RFT) Replica management (RLS, DRS)

Service interfaces for accessing data in diverse formats


OGSA Data Access & Integration GridFTP data access & movement

57

GridFTP in GT4
100% Globus code No licensing issues Stable, extensible IPv6 Support XIO for different transports Striping multi-Gb/sec wide area transport
27 Gbit/s on 30 Gbit/s link
Bandwidth Vs Striping 20000 18000 16000 14000 12000 10000 8000 6000 4000 2000 0 0 10 20 30 40 50 60 70 Degree of Striping # Stream = 1 # Stream = 8 # Stream = 2 # Stream = 16 # Stream = 4 # Stream = 32

Pluggable
Front-end: e.g., future WS control channel Back-end: e.g., HPSS, cluster file systems Transfer: e.g., UDP, NetBLT transport

Bandwidth (Mbps)

Disk-to-disk on TeraGrid

58

Reliable File Transfer


Fire-and-forget transfer Web services interface Integrated failure recovery
RFT Client SOAP Messages Notifications (Optional)

RFT Service

GridFTP Server
Master DSI Protocol Interpreter Data Channel Data Channel

GridFTP Server
Protocol Interpreter Master DSI

IPC Link
IPC Receiver Slave DSI Data Channel Data Channel

IPC Link
Slave DSI IPC Receiver 59

Replica Location Service


Identify location of files via logical to physical name map Distributed indexing of names, fault tolerant update protocols GT4 version scalable & stable Managing ~40 million files across ~10 sites

Index

Index

60

Information Service
Data Replication Credential Mgmt Delegation
Community Authorization
Authentication Authorization

Globus Toolkit v4 www.globus.org


Grid Telecontrol Protocol

Replica Location
Data Access & Integration

Community Scheduling Framework


Workspace Management
Grid Resource Allocation & Management

WebMDS

Python Runtime
C Runtime Java Runtime Common Runtime

Reliable File Transfer

Trigger

GridFTP
Data Mgmt

Index
Info Services

Security

Execution Mgmt

61

MDS in VO Constructing a Hierarchy

Indexes can be registered to other indexes Indexes at top of slide contains information about all 6 hours

MDS Components

Collective services aggregate information from multiple resources Index service maintains the set of registered Grid Resources Trigger service contains the list of rules to perform actions Component-specific information Queue status information for GRAM GT4 WSRF core provides underlying layer

Monitoring & Discovery


WS-ServiceGroup

Clients (e.g., WebMDS)

GT4 Container

MDSIndex
adapter

Registration & WSRF/WSN Access

Automated registration in container

GT4 Container MDSIndex

GT4 Cont.
Custom protocols for non-WSRF entities

MDSIndex

GridFTP User RFT


64

GRAM

Relationship between OGSA, GT4, WSRF, and Web Services

65

Creating MathService in RMI and WSRF

Reference: The Globus Toolkit 4 Programmers Tutorial

66

MathService
MathService is a service processing simple mathematical operation using a server Client sends a request to process the values and operations to the server Allow users to perform the following operations:
Addition Subtraction

67

RMI Program

68

Creating Remote object


1. Create the server and client codes
interface the implementation or server the client

2.

Compile the interface and implementations


compile using javac create the Stub using rmic

3.

Run the codes


run naming service and server run the client

69

Interface
import java.rmi.*; public interface Math extends Remote{ public void add(int a) throws RemoteException; public void subtract(int a) throws RemoteException; public int getValueRP() throws RemoteException; }

java.rmi.* is a library for RMI implementations interface Math, not class Math, to declare the code as interface and extend to Remote for RMI procedure Both add and subtract are procedures (void) getValueRP returns the current value

70

Implementation class (Properties)


import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; public class MathImpl extends UnicastRemoteObject implements Math{ MathImpl() throws RemoteException{ super(); } public int value; public void add(int a) throws RemoteException { value += a; } public void subtract(int a) throws RemoteException { value -= a; } public int getValueRP() throws RemoteException { return value; } 71 }

MathImpl Procedures
class MathImp name of the server that will handle the

object
UnicastRemoteObject - for non-replicated remote

object whose references are valid only while the server process is alive procedures public void add(int a) add the value of a to current value public void subtract(int a) - subtracts the value of a to current value public int getValueRP() getting the value
72

Implementation class (Initialization)


public static void main(String args[]){ try { System.setSecurityManager(new RMISecurityManager()); MathImpl Mathserver = new MathImpl(); Naming.rebind("rmi://nodea:1099/mathserver", Mathserver); System.out.println("Mathserver is waiting"); } catch (java.net.MalformedURLException me) { System.out.println("Malformed URL:"+me.toString()); } catch (RemoteException re) { System.out.println("Remote exception:"+re.toString()); } }

System.setSecurityManager() security access of the

remote object
MathImpl Mathserver = new MathImpl() creating an

instance of the class


Naming.rebind("rmi://nodea:1099/mathserver", Mathserver) registering to the rmi registry server

Naming Service
Directory that associates names to remote objects (bind)

Naming
X Y

Remote Object A Remote Object B Host 192.168.0.5

Remote Object C

74

Client code
import java.rmi.*; import java.rmi.server.*; public class MathClient{ public static void main(String[] args) { System.setSecurityManager(new RMISecurityManager()); try { System.out.println("Security Manager loaded"); String url = "rmi://nodea:1099/mathserver"; Math remoteObject = (Math)Naming.lookup(url); remoteObject.add(10); remoteObject.add(5); System.out.println("Current value: " + remoteObject.getValueRP()); remoteObject.subtract(5); System.out.println("Current value: " + remoteObject.getValueRP()); } catch (RemoteException exc){ System.out.println("Error in lookup: "+exc.toString()); } catch (java.net.MalformedURLException exc){ System.out.println("Malformed URL: "+exc.toString()); } catch (java.rmi.NotBoundException exc){ System.out.println("Not bound: "+exc.toString()); } 75 }}

Client Procedures
Naming.lookup(url) searches the rmi server with the remote object method and passes to remoteObject "rmi://nodea:1099/mathserver the name of the

server
remoteObject.add() and remoteObject.subtract()

the interface for the remote method of the object remoteObject.getValueRP - get the current value of the object

76

Naming Service
Client use Naming Service to find a particular Server object (lookup)

Naming
Object Client lookup(Y) X Y Remote Object Server

Remote ref. to Server tata.epfl.ch

Z Host titi.epfl.ch
77

Compiling the codes


Compile the interface javac Math.java Compile the implementation javac MathImpl.java Generate the stub rmic MathImpl Compile the Client javac MathClient.java

78

Running the codes


Start the rmiregistry rmiregistry & Start the object server java MathImpl Start the client java MathClient

79

Creating MathService in WSRF


Write and deploy a simple stateful web service that uses WSRF Our first web service is an extremely simple MathService. It will allow users to perform the following operations:
Addition Subtraction

following resource properties


Value (integer) Last operation performed (string)

80

The Five Steps


1. 2. 3. 4.
5.

Define the service's interface. This is done with WSDL Implement the service. This is done with Java. Define the deployment parameters. This is done with WSDD and JNDI Compile everything and generate a GAR file. This is done with Ant Deploy service. This is also done with a GT4 tool

81

Defining the interface in WSDL (Imports)


<?xml version="1.0" encoding="UTF-8"?> <definitions name="MathService" targetNamespace="http://www.globus.org/namespaces/examples/core/MathService_instance" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.globus.org/namespaces/examples/core/MathService_instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsrp="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft01.xsd" xmlns:wsrpw="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft01.wsdl" xmlns:wsdlpp="http://www.globus.org/namespaces/2004/10/WSDLPreprocessor" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:import namespace= "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl" 82 location="../../wsrf/properties/WS-ResourceProperties.wsdl" />

Defining the interface in WSDL (Properties)


<types> <xsd:schema targetNamespace="http://www.globus.org/ namespaces/examples/core/MathService_instance" xmlns:tns="http://www.globus.org/ namespaces/examples/core/MathService_instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <!-- REQUESTS AND RESPONSES --> <xsd:element name="add" type="xsd:int"/> <xsd:element name="addResponse"> <xsd:complexType/> </xsd:element> <xsd:element name="subtract" type="xsd:int"/> <xsd:element name="subtractResponse"> <xsd:complexType/> </xsd:element> <xsd:element name="getValueRP"> <xsd:complexType/> </xsd:element> <xsd:element name="getValueRPResponse" type="xsd:int"/> <!-- RESOURCE PROPERTIES --> <xsd:element name="Value" type="xsd:int"/> <xsd:element name="LastOp" type="xsd:string"/> <xsd:element name="MathResourceProperties"> <xsd:complexType> <xsd:sequence> <xsd:element ref="tns:Value" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:LastOp" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element>

</xsd:schema> </types>

83

Defining the interface in WSDL (Ports)


<portType name="MathPortType" wsdlpp:extends="wsrpw:GetResourceProperty" wsrp:ResourceProperties="tns:MathResourceProperties"> <operation name="add"> <input message="tns:AddInputMessage"/> <output message="tns:AddOutputMessage"/> </operation> <operation name="subtract"> <input message="tns:SubtractInputMessage"/> <output message="tns:SubtractOutputMessage"/> </operation> <operation name="getValueRP"> <input message="tns:GetValueRPInputMessage"/> <output message="tns:GetValueRPOutputMessage"/> </operation> </portType> </definitions>

84

WSRF and Globus-specific features of WSDL


Resource properties: We use the srp:ResourceProperties attribute of the portType element to specify what our service's resource properties are. The WSDL Preprocessor: A WSDL Preprocessor will use the value of that attribute to generate correct WSDL which includes our own portType definitions plus any WSRF portType we might need in our service. No bindings: Don't have to add binding, since they are generated automatically by a GT4 tool that is called when we build the service. 85

Implementing the service in Java (Qnames)


Qualified Names
we have to refer to just about anything related to a service, we will need to do so using its qualified name, or QName for short. This is a name which includes a namespace and a local name.
package org.globus.examples.services.core.first.impl; import javax.xml.namespace.QName; public interface MathQNames { public static final String NS = "http://www.globus.org/namespaces/examples/core/MathService_instanc e"; public static final QName RP_VALUE = new QName(NS, "Value"); public static final QName RP_LASTOP = new QName(NS, "LastOp"); public static final QName RESOURCE_PROPERTIES = new QName(NS, "MathResourceProperties"); 86 }

Implementing the service in Java (Imports)


need to implement the Resource interface - a way of tagging a class as being a resource. The class has a set of resource properties which we want to make available
package org.globus.examples.services.core.first.impl; import import import import import import import import import import java.rmi.RemoteException; org.globus.wsrf.Resource; org.globus.wsrf.ResourceProperties; org.globus.wsrf.ResourceProperty; org.globus.wsrf.ResourcePropertySet; org.globus.wsrf.impl.ReflectionResourceProperty; org.globus.wsrf.impl.SimpleResourcePropertySet; org.globus.examples.stubs.MathService_instance.AddResponse; org.globus.examples.stubs.MathService_instance.SubtractResponse; org.globus.examples.stubs.MathService_instance.GetValueRP;

public class MathService implements Resource, ResourceProperties { }

87

Implementing the service in Java (Initialize)


private ResourcePropertySet propSet; private int value; private String lastOp; public MathService() throws RemoteException {

this.propSet = new SimpleResourcePropertySet( MathQNames.RESOURCE_PROPERTIES); try { 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()); } }

create the individual resource properties, and initialize them

88

Implementing the service in Java (Property set)


add an attribute for each resource property along with a get/set method pair for each resource property
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; } 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; } public ResourcePropertySet getResourcePropertySet() { return this.propSet; }

89

Configuring the Deployment (WSDD)


key components of the deployment phase is a file called the deployment descriptor file that tells the Web Services container how a service should publish
<?xml version="1.0" encoding="UTF-8"?> <deployment name="defaultServerConfig" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <service name="examples/core/first/MathService" provider="Handler" use="literal" style="document"> <parameter name="className" value="org.globus.examples.services.core.first.impl.MathService"/> <wsdlFile>share/schema/examples/MathService_instance/Math_service.wsdl</wsdlFile> <parameter name="allowedMethods" value="*"/> <parameter name="handlerClass" value="org.globus.axis.providers.RPCProvider"/> <parameter name="scope" value="Application"/> <parameter name="providers" value="GetRPProvider"/> <parameter name="loadOnStartup" value="true"/> </service> 90 </deployment>

Configuring the Deployment (JNDI)


<?xml version="1.0" encoding="UTF-8"?> <jndiConfig xmlns="http://wsrf.globus.org/jndi/config"> <service name="examples/core/first/MathService"> <resource name="home" type="org.globus.wsrf.impl.ServiceResourceHome"> <resourceParams> <parameter> <name>factory</name> <value>org.globus.wsrf.jndi.BeanFactory</value> </parameter> </resourceParams> </resource> </service> </jndiConfig>

91

Compile everything and generate a GAR file


Creating a GAR file is a pretty complex task which involves the following:
Processing the WSDL file to add missing pieces (such as bindings) Creating the stub classes from the WSDL Compiling the stubs classes Compiling the service implementation Organize all the files into a very specific directory structure

92

Compile everything and generate a GAR file (2)


Solution: globus-build-service script and buildfile (GSBT project) allow to create a GAR file with minimal effort. Do the following:
./globus-build-service.sh \ -d org/globus/examples/services/core/first/ \ -s schema/examples/MathService_instance/Math.wsdl

93

Deploying the Service


This deployment command must be run with a user that has write permission in $GLOBUS_LOCATION.
globus-deploy-gar ./org_globus_examples_services_core_first.gar

There is also a command to undeploy a service:


globus-undeploy-gar org_globus_examples_services_core_first

94

The Client
EndpointReferenceType object representing the endpoint reference of this service. an endpoint reference is used to address a particular WS-Resource Obtain a reference to the service's portType

MathServiceAddressingLocator locator = new MathServiceAddressingLocator(); try { String serviceURI = args[0]; EndpointReferenceType endpoint = new EndpointReferenceType(); endpoint.setAddress(new Address(serviceURI)); MathPortType math = locator.getMathPortTypePort(endpoint); math = locator.getMathPortTypePort(endpoint); math.add(10); math.add(5); System.out.println("Current value: + math.getValueRP(new GetValueRP())); math.subtract(5); System.out.println("Current value: "+ math.getValueRP(new GetValueRP())); } catch (Exception e) { e.printStackTrace(); 95 }

Compiling and Running the Client


Compile the client by this command:
javac \ -classpath ./build/stubs/classes/:$CLASSPATH \ org/globus/examples/clients/MathService_instance/Client.java

Run the client:


java \ -classpath ./build/stubs/classes/:$CLASSPATH \ org.globus.examples.clients.MathService_instance.Client \ http://192.168.0.5:8080/wsrf/services/examples/core/first/MathService

96

Exercises
Build the codes for RMI and WSRF that performs multiplication and division using the same implementation codes from the previous lesson.
Modify the current code to add the 2 new methods Create a client that will invoke these methods

97

Vous aimerez peut-être aussi