Presentation 4: Principles of Object-Oriented Middleware.

Slides:



Advertisements
Similar presentations
1 Communication in Distributed Systems REKs adaptation of Tanenbaums Distributed Systems Chapter 2.
Advertisements

Local vs. distributed Objects Differences between local and distributed objects in: –References (to objects) –Activation/Deactivation –Migration –Persistence.
RPC Robert Grimm New York University Remote Procedure Calls.
Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Tam Vu Remote Procedure Call CISC 879 – Spring 03 Tam Vu March 06, 03.
II. Middleware for Distributed Systems
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
Presentation 4: Principles of Object-Oriented Middleware.
University of British Columbia Software Practices Lab Introduction to Middleware for Software Engineering Eric Wohlstadter 539D.
Distributed components
Tutorials 2 A programmer can use two approaches when designing a distributed application. Describe what are they? Communication-Oriented Design Begin with.
Socket Programming.
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
Introduction to Remote Method Invocation (RMI)
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: Distributed Objects.
II. Middleware for Distributed Systems
Networks 1 CS502 Spring 2006 Network Input & Output CS-502 Operating Systems Spring 2006.
CS-3013 & CS-502, Summer 2006 Network Input & Output1 CS-3013 & CS-502, Summer 2006.
EEC-681/781 Distributed Computing Systems Lecture 4 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
© Chinese University, CSE Dept. Distributed Systems / Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering.
CS 352-Socket Programming & Threads Dept. of Computer Science Rutgers University (Thanks,this slides taken from er06/
Presentation 4: Principles of Object-Oriented Middleware.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Remote Procedure Call Andrew Whitaker CSE451. Remote Procedure Call RPC exposes a programming interface across machines: interface PriceService { Price.
Presentation 4: Principles of Object-Oriented Middleware.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
© 2003 Wolfgang Emmerich 1 Validating Distributed Object & Component Designs Wolfgang Emmerich and Nima Kaveh London Software Systems University College.
Introduction to Distributed Systems Slides for CSCI 3171 Lectures E. W. Grundke.
Chapter 4: Interprocess Communication‏ Pages
Distributed Systems Concepts and Design Chapter 4.
1. I NTRODUCTION TO N ETWORKS Network programming is surprisingly easy in Java ◦ Most of the classes relevant to network programming are in the java.net.
Presentation 18: RMI introduction. Goals of this lesson After this 35 min. lesson you will be: Introduced to Java RMI Ready to present RMI’s position.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Abhishek Bachchan Vishal Patangia
Presentation: RMI introduction. Goals of this lesson After this 35 min. lesson you will be: Introduced to Java RMI Ready to present RMI’s position in.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved RPC Tanenbaum.
CSE 451: Operating Systems Winter 2015 Module 22 Remote Procedure Call (RPC) Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
Objektorienteret Middleware (OOMI)
Presentation 4: Principles of Object-Oriented Middleware.
© Chinese University, CSE Dept. Distributed Systems / Distributed Systems Topic 3: Communication Dr. Michael R. Lyu Computer Science & Engineering.
Remote Procedure Calls CS587x Lecture Department of Computer Science Iowa State University.
Remote Procedure CallCS-502 Fall Remote Procedure Call (continued) CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System.
Presentation 11: RMI introduction. Ingeniørhøjskolen i Århus Slide 2 af 20 Goals of this lesson After these 2x35 lessons you will be –Introduced to Java.
Part 4: Network Applications Client-server interaction, example applications.
Distributed systems (NET 422) Prepared by Dr. Naglaa Fathi Soliman Princess Nora Bint Abdulrahman University College of computer.
Objektorienteret Netværkskommunikation (ITONK1) CORBA Introduction.
DISTRIBUTED OBJECTS AND REMOTE INVOCATION 1. 2 Topics  Middleware  Remote Method Invocation  Remote Procedure Call.
Presentation: Special Repetition Recap on Distributed Principles.
RPC Model, Stubs and Skeletons Divya Nampalli
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Socket Programming Ameera Almasoud
03 – Remote invoaction Request-reply RPC RMI Coulouris 5
Prof. Leonardo Mostarda University of Camerino
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Spring 2012 Module 22 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Remote Procedure Call Hank Levy 1.
CS551 Object Oriented Middleware (I) (Chap. 3 of EDO)
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

Presentation 4: Principles of Object-Oriented Middleware

Ingeniørhøjskolen i Århus Slide 2 Outline Students are assumed to be knowledgeable about Computer Networks – including the OSI model and the TCP, UDP protocols. If not … please read ; ) Types of Middleware –Transaction-Oriented Middleware –Message-Oriented Middleware –Remote Procedure Calls Object-Oriented Middleware Developing with Object-Oriented Middleware

Computer Networks - an ultra short introduction

Ingeniørhøjskolen i Århus Slide 4 Physical Application Presentation Session Transport Network Data link ISO/OSI Reference Model Middleware Specific Middleware Specific

Ingeniørhøjskolen i Århus Slide 5 Physical Application Presentation Session Transport Network Data link Transport Layer Level 4 of ISO/OSI reference model. Concerned with the transport of information through a network. Two facets in UNIX/Windows networks: –TCP and –UDP TCP & UDP do not follow the OSI model TCP/IP model

Ingeniørhøjskolen i Århus Slide 6 Transmission Control Protocol (TCP) Provides bi-directional stream of bytes between two distributed components. Reliable but slow protocol. Buffering at both sides de-couples computation speeds. Best at fairly unreliable Networks (as the Internet) Very practical –As the WWW uses the TCP/IP protocol family –And most Networking Operating Systems as well

Ingeniørhøjskolen i Århus Slide 7 Application Presentation Session Transport Application Presentation Session Transport Input Stream Output Stream Requests Results ClientServer TCP for Request Implementation

Ingeniørhøjskolen i Århus Slide 8 User Datagram Protocol (UDP) Enables a component to pass a message containing a sequence of bytes to another component. Other component is identified within message. Unreliable but very fast protocol. Restricted message length. Queuing at receiver Best at highly reliable networks (as a LAN)

Ingeniørhøjskolen i Århus Slide 9 Result Datagrams Application Presentation Session Transport Application Presentation Session Transport Request Datagrams ClientServer UDP for Request Implementation

Types of Middleware - and why to use …

Ingeniørhøjskolen i Århus Slide 11 Rolling your own Distributed Objects We may build directly on the TCP or UDP protocols to build a distributed system In Java: quite easy – thanks to the java.net package – which contains a complete network API incl. socket support for TCP/UDP BUT: if we want to ensure OO – more complex Lets take a look at how this may be done

Ingeniørhøjskolen i Århus Slide 12 The Basic Class to OO Class public class HelloWorldBasic { public static void main(String[] args) { System.out.println("HelloWorld!"); } HelloWorld – can it be more simple? public class HelloWorldOO { public HelloWorldOO() { } public void sayHelloWorld() { return “HelloWorld"; } public static void main(String[] args) { HelloWorldOO helloWorldOO = new HelloWorldOO(); System.out.println(helloWorldOO.sayHelloWorld()); } To OO:

Ingeniørhøjskolen i Århus Slide 13 First Issue: Making the Object Distributed - The Proxy Stub and MarshallingCalledCalled Stub CallerCalledCalledCaller Caller Transport Layer (e.g. TCP or UDP)

Ingeniørhøjskolen i Århus Slide 14 What Objects do we need to Implement This? Discussion: think 2 minutes: –We strive for Access Transparency –What objects do we need? –What responsibilities should they have?

Ingeniørhøjskolen i Århus Slide 15 Server Class – The Skeleton / Stub … public class HelloWorldServerThread extends Thread { protected DatagramSocket socket = null; public HelloWorldServerThread() throws IOException { super(); socket = new DatagramSocket(4450); } public void run() { while (true) { … if (request.startsWith("sayHelloWorld")) { new String(packet.getData()); // figure out response String response = null; //Call the HelloWorldOO method & place it in response HelloWorldOO helloWorldOO = new HelloWorldOO(); response = helloWorldOO.sayHelloWorld(); buf = response.getBytes(); … socket.send(packet); …CalledCalled Stub

Ingeniørhøjskolen i Århus Slide 16 The Client Stub - HelloWorldProxy public class HelloWorldProxy { public HelloWorldProxy() { } public String sayHelloWorld() { … // get a datagram socket socket = new DatagramSocket(); // send the request byte[] buf = new byte[256]; buf = methodCalled.getBytes(); InetAddress address = InetAddress.getByName("localhost"); DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 4450); socket.send(packet); // get a response packet = new DatagramPacket(buf, buf.length); socket.receive(packet); response = new String(packet.getData()); } catch (Exception e) { e.printStackTrace(); } socket.close(); return response; … Stub Caller

Ingeniørhøjskolen i Århus Slide 17 Achieving Access Transparency package chapter1; public class HelloWorldClient { public static void main(String[] args) { System.out.println("Recieved from Server: " + new HelloWorldProxy().sayHelloWorld()); } … and thus we have achieved access transparency using rather simple constructs (the Proxy pattern). We could have achieved an even higher degree of transparency by using an interface definition – and thus a contract between Client & Server. Stub Caller

Ingeniørhøjskolen i Århus Slide 18 Direct Use of Network Protocols implies Manual mapping of complex request parameters to byte streams or datagrams – is complex & error prone Manual resolution of data heterogeneity –encoding differs on NT & UNIX (what is the format of an Integer?) Manual identification of components –References must be established manually (host add., port nr. etc.) Manual implementation of component activation No guarantees for type safety Manual synchronization of interaction between distributed components –Developers need to handle TCP/UDP output stream/responses No quality of service guarantees –Transactions, Security, Concurrency, Scalability, Reliability Extremely difficult to achieve “Full Access Transparency”

Ingeniørhøjskolen i Århus Slide 19 = Reason for Using Middleware Layered between Application and OS/Network Makes distribution transparent Resolves heterogeneity of –Hardware –Operating Systems –Networks –Programming Languages Provides development and run-time environment for distributed systems “Gets you of the hook” – concerning the nasty stuff in network programming

Ingeniørhøjskolen i Århus Slide 20 Types of Middleware Transaction-Oriented –Suited for Database Applications –IBM CICS –BEA Tuxedo –Encina Message-Oriented –Suited for Asynchronous (EDI,Batch) –IBM MQSeries –DEC Message Queue –NCR TopEnd –(SOAP) RPC Systems –Suited for Access transparency etc –ANSA –Sun ONC –OSF/DCE –(SOAP) Object-Oriented –OMG/CORBA –DCOM –Java/RMI –(SOAP) First look at RPCs to understand origin of object-oriented middleware

Ingeniørhøjskolen i Århus Slide 21 Remote Procedure Calls Enable procedure calls across host boundaries Call interfaces are defined using an Interface Definition Language (IDL) RPC compiler generates presentation and session layer implementation from IDL RPC is the “legacy” of oo middleware

Ingeniørhøjskolen i Århus Slide 22 Type Safety and Heterogenity How can we make sure that –servers are able to perform operations requested by clients? –actual parameters provided by clients match the expected parameters of the server? –results provided by the server match the expectations of client? Middleware acts as mediator between client and server to ensure type safety. Achieved by interface definition in a mutually agreed upon language Supports Heterogenity

Ingeniørhøjskolen i Århus Slide 23 IDL Example (Unix RPCs) const NL=64; struct Player { struct DoB {int day; int month; int year;} string name ; }; program PLAYERPROG { version PLAYERVERSION { void PRINT(Player)=0; int STORE(Player)=1; Player LOAD(int)=2; }= 0; } = ;

Ingeniørhøjskolen i Århus Slide 24 Flashback to HelloWorld Example How to map complex types? –e.g. returning a struct (in C, C++) or an object (in C++, Java, C#, etc.)? –How would you do it? –Use 5 minutes to discuss this with your neighbor What are the issues? Which technology might help us? How would you do this in Java? How would you do it in C#? How would you do it in C++? How would you get them all to work together?

Ingeniørhøjskolen i Århus Slide 25 RPC Marshalling and Unmarshalling Marshalling: Disassemble data structures into transmittable form Unmarshalling: Reassemble the complex data structure char * marshal() { char * msg; msg=new char[4*(sizeof(int)+1) + strlen(name)+1]; sprintf(msg,"%d %d %d %d %s", dob.day,dob.month,dob.year, strlen(name),name); return(msg); }; void unmarshal(char * msg) { int name_len; sscanf(msg,"%d %d %d %d ", &dob.day,&dob.month, &dob.year,&name_len); name = new char[name_len+1]; sscanf(msg,"%d %d %d %d %s", &dob.day,&dob.month, &dob.year,&name_len,name); }; char * marshal() { char * msg; msg=new char[4*(sizeof(int)+1) + strlen(name)+1]; sprintf(msg,"%d %d %d %d %s", dob.day,dob.month,dob.year, strlen(name),name); return(msg); }; void unmarshal(char * msg) { int name_len; sscanf(msg,"%d %d %d %d ", &dob.day,&dob.month, &dob.year,&name_len); name = new char[name_len+1]; sscanf(msg,"%d %d %d %d %s", &dob.day,&dob.month, &dob.year,&name_len,name); };

Ingeniørhøjskolen i Århus Slide 26 RPC Stubs Creating code for marshalling and unmarshalling is tedious and error-prone. Code can be generated fully automatically from interface definition. Code is embedded (hidden away – de-coupled) in stubs for client and server. Client stub represents server for client, Server stub represents client for server. Stubs achieve type safety. Stubs also perform synchronization. NOT object-oriented, no support for exceptions or advanced error handling

Ingeniørhøjskolen i Århus Slide 27 Synchronization Goal: achieve similar synchronization to local method invocation Achieved by stubs: –Client stub sends request and waits until server finishes –Server stub waits for requests and calls server when request arrives

Object-Oriented Middleware

Ingeniørhøjskolen i Århus Slide 29 Interface Definition Language Every object-oriented middleware has an interface definition language (IDL) Beyond RPCs, object-oriented IDLs support object types as parameters, failure handling and inheritance Object-oriented middleware provide IDL compilers that create client and server stubs to implement session and presentation layer

Ingeniørhøjskolen i Århus Slide 30 IDL Example interface Player : Object { typedef struct _Date { short day; short month; short year; } Date; attribute string name; readonly attribute Date DoB; }; interface PlayerStore : Object { exception IDNotFound{}; short save (in Player p); Player load(in short id) raises(IDNotFound); void print(in Player p); };

Ingeniørhøjskolen i Århus Slide 31 Presentation Layer Implementation The way data is represented Ensuring compatible encoding across platforms In addition to RPC presentation layer implementation, object-oriented middleware needs to –define a transport representation for object references –deal with exceptions –need to marshal inherited attributes

Ingeniørhøjskolen i Århus Slide 32 Object References HostsProcessesObjects Session Layer Implementation - Mapping of Object references to hosts -Activation & deactivion of objects -Invocation of requested operation -Synchronization of client & server (state) - Mapping of Object references to hosts -Activation & deactivion of objects -Invocation of requested operation -Synchronization of client & server (state)

Developing with Object-Oriented Middleware

Ingeniørhøjskolen i Århus Slide 34 Interface Definition Design Server Stub Generation Client Stub Generation Server Coding Client Coding Server Registration Development Steps

Ingeniørhøjskolen i Århus Slide 35 Team.idl included in generates reads IDL-Compiler Teamcl.hh Teamcl.cc Teamsv.cc Teamsv.hh Stub Generation Team.wsdl Team.java Team.midl

Ingeniørhøjskolen i Århus Slide 36 C++ Compiler, Linker Server Client.cc Server.cc C++ Compiler, Linker Client Team.idl included in generates reads IDL-Compiler Teamcl.hh Teamcl.cc Teamsv.cc Teamsv.hh Client and Server Implementation