OGSI on Microsoft .NET Daragh Byrne, Ally Hume, Mike Jackson EPCC
Transcription
OGSI on Microsoft .NET Daragh Byrne, Ally Hume, Mike Jackson EPCC
OGSI on Microsoft .NET Daragh Byrne, Ally Hume, Mike Jackson EPCC http://www.epcc.ed.ac.uk/~ogsanet [email protected] Budapest, Hungary – November 10th-11th 2003 Some slides within this presentation have been graciously contributed by the OGSA-DAI project. Microsoft is a trademark of Microsoft Corporation. Overview MS.NETGrid Project Web Services, OGSA and OGSI OGSI on Microsoft .NET – MS.NETGrid-OGSI Grid Service Demonstrators Training Courses Project Goals Goals: Engaging and training the UK e-Science community in OGSI and .NET Facilitate uptake of .NET for developing Grid services Achieve via delivery of: Free-source OGSI implementation on .NET Free-source Grid service demonstrators Training materials Training courses Project Partners EPCC: Project management Design, development and implementation Authoring training materials Delivering training courses Microsoft Research Limited (Cambridge): Technical consultancy and expertise Provision of training materials NeSC – UK National e-Science Centre: Production and negotiation of collaboration agreement Hosting training courses Project Activities OGSADAI e-Science Application e-Science Application OGSI Microsoft .NET OGSI and Microsoft .NET OGSI and Course Microsoft .NET … OGSI … …Course … … and Microsoft .NET … OGSI … …Course … … and Microsoft .NET … Course ………… … ………… Web Services, OGSA and OGSI Web Services Network-enabled application Exposes a well-defined interface Stateless: Born Services Request Dies Accessible using common Internet protocols HTTP XML-oriented technology: Describe services and their interfaces WSDL – Web Services Description Language Support messaging SOAP – Simple Object Access Protocol WSDL Web Services Description Language XML description of Web Services: Define input and output messages Define operations in terms of input and output messages Aggregate operations into portTypes Application-specific collections of related operations Combine portTypes with a concrete network protocol and message format to form a binding Combine a binding and a network address to define a concrete network endpoint or port Aggregate ports into an abstract network endpoint or service Current W3C version is 1.1 What is OGSA? Open Grid Services Architecture Open Grid Architecture + Web Services = Grid Services Grid Services: Dynamic Transient Stateful – have a finite lifetime Defined by a well-defined set of interfaces and behaviours More information from http://forge.gridforge.org OGSA Characteristics Supports: Resource access Resources sharing Service integration Uniform access to services Specifies protocols and standards that: Are: Implementation-independent Platform-independent Support: Communication Data access, transfer, translation and transformation Access and security Auditing and logging What is OGSI? Open Grid Services Infrastructure Minimum set of standards and behaviours with which Grid Services must comply Exploits existing Web Services properties: Interface abstraction via WSDL portTypes Web Service protocols Hosting platform-independent Extends these to provide for: State management Event notification Service location and access Lifecycle management Service data More information from: http://forge.gridforge.org Anatomy of a Grid Service • Service Data Access • Lifetime Management GridService portType (required) Other PortTypes (Optional) •Service Creation •Service Grouping •Notification •Handle Resolution •Other functions e.g: Handle Element Element Service Data Element Grid Service Hosting Environment •Workflow •Auditing •Resource Management Anatomy of a Grid Service • Service Data Access • Lifetime Management GridService portType (required) Other PortTypes (Optional) •Service Creation •Service Grouping •Notification •Handle Resolution •Other functions e.g: Handle Service Element Element ElementSet Data Implementation Hosting Environment •Workflow •Auditing •Resource Management Anatomy of a Grid Service • Service Data Access • Lifetime Management GridService portType (required) Other PortTypes (Optional) •Service Creation •Service Grouping •Notification •Handle Resolution •Other functions e.g: Handle Service Data Service Data Service Data Implementation Hosting Environment •Workflow •Auditing •Resource Management OGSI PortTypes (1) GridService findServiceData setServiceData requestTerminationBefore requestTerminationAfter destroy Factory createService HandleResolver findByHandle ServiceGroup OGSI PortTypes (2) ServiceGroupRegistration add remove ServiceGroupEntry NotificationSource subscribe NotificationSubscription NotificationSink deliverNotification WSDL and GWSDL WSDL 1.1: Lack of portType inheritance A portType cannot be defined in terms of an aggregation or extension of one or more other portTypes Lack of an open content model Needed for specifying service data GWSDL: portType inheritance Open content model Stepping stone to WSDL 1.2 GWSDL => WSDL 1.1: Flattening the inheritance hierarchy The “most-derived” portType WSDL 1.2 Grid Service Identification Grid Services are identified by means of a Grid Service Handle (GSH), which is used to find the Grid Service Reference (GSR) that is unique to an instance of a Grid Service A HandleResolver service is used to provide a GSR given a GSH GSH: Type of URI (or URL) Constant for the lifetime of the Grid Service GSR: Representation of the service interfaces Can be a WSDL document Can change if the service evolves OGSI Implementations Microsoft .NET: EPCC: MS.NETGridOGSI Release 1.1 University of Virginia: OGSI.NET Release 1.1 Java: Globus: Globus Toolkit 3 Release 1.0 Unicore Perl: University of Manchester: OGSI::Lite Python: Lawrence Berkley National Labs: pyGlobus OGSI on Microsoft .NET MS.NETGrid-OGSI Design Dimensions Use IIS/ASP.NET: Facilitate speed of development SOAP and WSDL handling for free! Industry-standard Web services programming model Maintain integration with existing technology Exploit existing knowledge of developers Utilise .NET class library Rich framework for XML programming, serialization etc. Use an object instance to represent a service instance Creating service object and loading state every request is too costly: Performance-wise Development time-wise Design Limitations No rich client-side support: No Grid service-specific support But Grid services ARE Web services! GSH / GSR support Subset of OGSI portTypes Security But can secure using ASP.NET Web Services Security No GWSDL MS.NETGrid-OGSI Implementation of OGSI on Microsoft .NET Leverages ASP.NET functionality Provides support for: Grid service hosting in ASP.NET Web services container GridService portType-related functionality Factory portType-related functionality Service data management Management of persistent and transient services Client-Service Interaction C# Implementation 8. C# method return Proxy (from WSDL) Client 1. C# method call 7. SOAP response 2. SOAP request HTTP ASP.NET Web Service Proxy (.asmx) 3. Grid Service ID C# Implementation 4. Grid Service Object Reference 5. Operation Call 6. Operation Return OGSI Container Grid Service Grid Service Grid Service Service Lifetime and Naming Persistent services: Server-managed services Necessary for factories, permanent services Naming http://host/Ogsi.Container/services/persistent/Som eServiceFactory.asmx Transient services: Client-managed services Naming http://host/Ogsi.Container/services/transient/Some Service.asmx?instanceID=someService1 Service Proxy Model Service proxy is standard ASP.NET Web service Created – processes request - dies Communications layer between client and Grid services: One proxy type corresponds to one or more Grid services One instance of a proxy created per service request to .asmx file GSH is used by proxy to find Grid service object Reflection allows invocation of a service method on that object Operations exposed via WebMethod attributes SOAP communication and WSDL description for free! Familiar model to ASP.NET users Potential for auto-generation of proxy code Developing a Grid Service Grid Service Design What services will your Grid service provide? What operations will it support? How are these operations aggregated into portTypes? What existing and new portTypes will your service implement? No need to write WSDL! Grid Service Development Implement the service functionality: GridServiceSkeleton-derived OR PersistentGridServiceSkeleton-derived PortTypeProviders for portTypes Provide a service proxy class: Communications layer between clients and services No original effort required! Represents the most-derived portType Inherits from GridServiceInstanceAspProxy (which derives from ASP.NET class WebService) Deploy the service: ASP.NET Web service deployment descriptor (Web.config) Location of classes and proxies / service lifetime type Application-specific information Implement the Service Functionality MS.NETGrid-OGSI Classes Inherit from: GridServiceSkeleton OR PersistentGridServiceSkeleton Hello Service: public class HelloServiceImpl : PersistentGridServiceSkeleton { . . . . . . . . . } GridServiceSkeleton (1) Implements GridService portType functionality: findServiceData, setServiceData, requestTerminationBefore, requestTerminationAfter, destroy InstanceServiceDataSet property: ServiceDataSet for the live running service instance ServiceDataSet and ServiceData APIs ServiceParameters property: General purpose hashtable Loaded with configuration data from a deployment descriptor when service is initialised PortTypeProviders property: Hashtable containing references to implementations of portTypes GridServiceSkeleton (2) PostCreate method public abstract class GridServiceSkeleton { public virtual void PostCreate() { } } Can be used for resource acquisition, service data initialisation, other initialisation: Called by the container or factory when service is created Store useful items in ServiceParameters hashtable Only for objects used by all the portTypes of a service Implementing PortType Operations Option 1 - Inheritance: Provide methods on a GridServiceSkeleton-derived class Recommended when only one portType is required Quick and convenient Option 2 – PortType Providers: Use IPortTypeProvider implementations Use OgsiPortType attribute to associate with service class PortTypeProviders property of GridServiceSkeleton Maps requests to IPortTypeProvider instances Modularises portType and service implementations Inheritance public class HelloServiceImpl : PersistentGridServiceSkeleton { int i = 0; // sayHello is an operation on some portType public string sayHello(string name) { return “Hello, “ + name + “ “ + (++i); } } PortType Providers (1) public class HelloPortType : PortTypeProviderBase { int i = 0; public string sayHello(string name) { return “Hello, “ + name + “ “ + (++i); } public override void Initialise() { } } // Declare service and attach portType using attribute [OgsiPortType(typeof(HelloPortType), “http://mydomain.com/NameSpace”, “HelloPortType”] public class HelloServiceImpl : PersistentGridServiceSkeleton { } PortType Providers (2) public interface IPortTypeProvider { GridServiceSkeleton ServiceInstance { get; set; } void Initialise(); } Provides for: Access to service instance Custom initialisation code – called after the IPortTypeProvider is created Attach to service with OgsiPortTypeAttribute PortTypeProviderBase gives simple implementation of PortTypeProvider How PortType Providers Work Attributes and reflection! On instantiation of GridServiceSkeleton: Reflects upon self to get OgsiPortType attributes Uses the information in the attributes to instantiate implementation classes [OgsiPortType(typeof(HelloPortType), “http://mydomain.com/NameSpace”, “HelloPortType”] Stores instances in PortTypeProviders hashtable Methods can then be called on these instances Service Data Named like any XML element: (namespace, local name) Represented by an instance of the Ogsi.ServiceData.ServiceData type ServiceDataSet type represents the entire collection of service data for a service GridServiceSkeleton.InstanceServiceData Service Data APIs ServiceDataSet: Create(XmlQualifiedName name); Add(ServiceData data); Contains(XmlQualifiedName name); Delete(XmlQualifiedName name); Remove(XmlQualifiedName name); ServiceData: Contains System.Object(s) GetValues() / GetValuesArray() Value property SetValues(object [ ]) Callback property for on-demand generation Uses IServiceDataValuesCallback Provide a Service Proxy Class Service Proxies Communications layer between clients and Grid service objects Proxies are Web services Based on System.Web.Services.WebService class of ASP.NET Allows ASP.NET to forward service requests to/from Grid service objects: GridServiceInstanceAspProxy and PersistentGridServiceInstanceAspProxy Proxies and Inheritance // HelloService.cs public class HelloService : PersistentGridServiceInstanceAspProxy { [WebMethod] // Any other ASP.NET attributes public string SayHello(string name) { object [] args = { name }; return (string) CallMethod(“SayHello”, args); } } GridServiceInstanceAspProxy / PersistentGridServiceInstanceAspProxy constructor provides reference to service instance object via container CallMethod invokes on service instance object Proxies and PortType Providers // HelloService.cs public class HelloService : PersistentGridServiceInstanceAspProxy { [WebMethod] // Any other ASP.NET attributes public string SayHello(string name) { object [] args = { name }; return (string) CallMethodOnProvider(“HelloPortType”, “SayHello”, args); } } Completing the Proxy Write .asmx file which references proxy type <%@ WebService Class=“HelloService"%> Deploy the Service Deployment Descriptors and ASP.NET Web.Config gridContainer element Add gridServiceDeploymentDescriptor: <gridServiceDeploymentDescriptor asmxFileName=“HelloService.asmx” serviceClass=“HelloServiceImpl” assembly=“HelloAssembly” persistence=“persistent”> <serviceParameter name=“key” value=“value”/> </gridServiceDeploymentDescriptor> Attributes: asmxFileName - .asmx file for proxy service – main service implementation class assembly - service and proxy assembly persistence - transient or persistent Provide the Service Copy assemblies to Ogsi.Container/bin/ directory Copy .asmx file to: services/persistent directory OR services/transient directory Grid Service Demonstrators Grid Service Demonstrators Representative examples provided with the MS.NETGrid-OGSI distribution Basic GridService: Implements GridService portType Persistent and transient services available, with factory Counter Service: A simple transient counter service which maintains state An associated persistent factory service A client with a graphical user-interface OGSA-DAI Grid Data Service (1) Client Request (GDS-Perform document) Response (GDS-Response document) (WebRowSet) Grid Data Service SQL Server Open Grid Services Architecture – Data Access and Integration http://www.ogsadai.org.uk Stripped down from full OGSA-DAI functionality Service-database communication over ADO.NET OGSA-DAI Grid Data Service (2) Training the UK e-Science Community Training Courses “OGSI on Microsoft .NET” Designed for UK e-Scientists Four courses each for 25 attendees: September 9th-10th 2003 November 4th-5th 2003 January 27th-28th 2004 February 2004 e-Science Institute in Edinburgh http://www.nesc.ac.uk/esi Course Goals Introduce / review: Grid Services Microsoft .NET Introduce OGSI on Microsoft .NET MS.NETGrid-OGSI Use MS.NETGrid-OGSI: Develop a Grid Service Develop a client Introduce related OGSI on Microsoft.NET work Course Outline – Day 1 Welcome and Workshop Overview Grid Services Web Services and XML Grids, OGSA and OGSI Essential Microsoft .NET Concepts .NET Framework Overview C# Recap, Assemblies and Using Metadata ASP.NET OGSI and .NET Why OGSI on .NET? MS.NETGrid-OGSI Obtaining, installing and testing MS.NETGrid-OGSI Practical Course Outline – Day 2 Recap Developing a Grid Service 1 Practical Developing a Grid Service 2 Practical Developing a Grid Service 3 Practical Miscellaneous: MS.NETGrid-OGSI Demonstrators Course Feedback Discussion Near Future Revision of OGSI on .NET container Facilitating scalability and service persistence Development of additional Grid service demonstrators: Practical demonstration of the utility of OGSI on .NET Revision of training materials: Courses and supporting materials on OGSI and .NET Delivery of additional courses