Software Engineering and Architecture

Slides:



Advertisements
Similar presentations
Remote Method Invocation (RMI) Mixing RMI and sockets
Advertisements

C# and Windows Programming Application Domains and Remoting.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
Distributed components
Remote Object Invocation
Technical Architectures
Distributed Systems Lecture #3: Remote Communication.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
Communication in Distributed Systems –Part 2
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets Rethinking out tic-tac-toe game.
1 Chapter 2. Communication. STEM-PNU 2 Layered Protocol TCP/IP : de facto standard Our Major Concern Not always 7-layered Protocol But some other protocols.
1 HKU CSIS DB Seminar: HKU CSIS DB Seminar: Web Services Oriented Data Processing and Integration Speaker: Eric Lo.
CSCI 6962: Server-side Design and Programming Web Services.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
Algoval: Evaluation Server Past, Present and Future Simon Lucas Computer Science Dept Essex University 25 January, 2002.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Client Call Back Client Call Back is useful for multiple clients to keep up to date about changes on the server Example: One auction server and several.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
TCP Sockets Reliable Communication. TCP As mentioned before, TCP sits on top of other layers (IP, hardware) and implements Reliability In-order delivery.
Hwajung Lee.  Interprocess Communication (IPC) is at the heart of distributed computing.  Processes and Threads  Process is the execution of a program.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
1 Chapter 2. Communication. STEMPusan National University STEM-PNU 2 Layered Protocol TCP/IP : de facto standard Our Major Concern Not always 7-layered.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Operating Systems {week 11a}
Introducing a Framework ... and a few patterns
Last Class: Introduction
Software Architecture in Practice
Client-Server Communication
Scalability: Load Balancing
Prof. Leonardo Mostarda University of Camerino
Chapter 5 Remote Procedure Call
WEB SERVICES.
CORBA Alegria Baquero.
Software Architecture in Practice
Distribution and components
Distributed web based systems
Dave Eckhardt RPC Dave Eckhardt
Chapter 3: Windows7 Part 4.
Ch > 28.4.
Knowledge Byte In this section, you will learn about:
Programming Models for Distributed Application
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 Autumn 2003 Lecture 16 RPC
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Architectures of distributed systems Fundamental Models
Lecture 6: TCP/IP Networking 1nd semester By: Adal ALashban.
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Architectures of distributed systems Fundamental Models
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
Creating a Distributed System with Remote Procedure Calls and Web Services Ch.5 B.Ramamurthy 2/17/2019 B.Ramamurthy.
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
An Introduction to Internetworking
Architectures of distributed systems Fundamental Models
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Message Passing Systems Version 2
Software Engineering and Architecture
Software Engineering and Architecture
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Software Engineering and Architecture
Software Engineering and Architecture
Message Passing Systems
Presentation transcript:

Software Engineering and Architecture Broker Pattern Architectural Pattern for Remote Method Invocation

Henrik Bærbak Christensen Broker Broker Complex pattern Three levels Domain level Marshalling level IPC level Two mirrored ‘sides’ Client side Server side Let’s have a look at each… CS@AU Henrik Bærbak Christensen

The ‘Side’ Perspective Client side CS@AU Henrik Bærbak Christensen

The ‘Side’ Perspective Server side CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Dynamics (Client) CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Dynamics (Server) CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Domain Level Domain level represents the actual Role CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Marshalling Level Encapsulate translation to/from bits and objects CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen IPC Level Interprocess Communication Encapsulate low-level OS/Network communication CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Relating to    Broker pattern and    ? Yes, yes, and yes  Encapsulate what varies We would like to vary marshalling format: Requestor+Invoker We would like to vary IPC method : RequestHandler  Object composition We delegate to the requestor. We delegate to the RequestHandl. However, the roles bleed into each other somewhat Often RequestHandlers need additional marshalling/demarshalling REST and HTTP solves multiple aspects => natural ‘bleeding’ CS@AU Henrik Bærbak Christensen

In Practice How Does It Look Then…

Henrik Bærbak Christensen TeleMed Proxy ClientProxy = Proxy calls Note: location is hardcoded in TeleMed (only one server) so no need for that parameter. CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Identity of Methods Remember: We can only send byte arrays = Strings Need to Marshall method names as well. ”Mangling” = Concatenate class name and method name CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Requestor General Implementation! Use JSON and the GSON library Generic return type is pretty helpful… And Object… = arrays of mixed types are really nasty that required some googling to find out how. CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Request Handlers Let us skip them for the moment… Basically they are responsible for the send/receive pairs Broker Library code base come with two variants: Socket: Raw Java TCP/IP network implementations HTTP: Use as a raw transport (URI Tunneling) CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Invoker Basically you need a large switch on each method name to do the ‘upcall’, and extract the relevant parameters for the method For multi-object system, you need something more complex. Stay tuned – we will look at it next week... CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen TeleMed Servant Servant = Domain implementation CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Summary The flow CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Summary Framework ! Only ClientProxy Invoker Are TeleMed specific! CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Limitations No Name Service / Registry required for TeleMed Hardcoded which machine the servant object resides on Use DNS as kind of registry, I used ‘localhost’ here More RPC than RMI Remote Procedure Call on ‘single type object’, not on multiple objects Only Value types can be passed, not Reference types No object references ever pass a network border Asymmetric Client-server protocol, no ‘callback’ from server possible I.e. The Observer pattern can not be implemented CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Limitations? Are these severe limitations? Actually, not really All web service architectures obey them They are RPC ! Only value types are passed ! Callbacks are not part of standard web programming We cannot make an Observer Pattern! (But lots of tricks to implement it still COMET, WebSockets, ‘long calls’, polling) And they are pretty successful  CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Limitations? Web architectures impose limitations that make perfect architectural sense If you have callback, you cannot scale-out That is, increase power by adding more servers / load balancing Exercise: why not? Hint: Consider 12.000.000 WoW clients to be notified if one tree in the world is chopped down… If you have real remote object references you will get callbacks remoteServer.addCustomer(localCustomerObject) On remote server, the ‘localCustomerObject’ is now remote! Pure client-server + value passing saves the day! CS@AU Henrik Bærbak Christensen

Marshalling Robustness Jon Postel Scenario: Change the marshalling format for messages Redeploy the server Bang! All deployed clients fail to talk to server! CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Robustness Key point Include a version identity in the marshalling format ! The demarshalling must ‘taste’ it and next decide on the full demarshalling I.e. parse the ‘raw byte array’ for the version identity Select the proper demarshalling algorithm to use JSON and XML are very flexible formats! You can add new attributes, but older algorithms can still pick out those attributes that they know the semantics of Gson can demarshall ‘half’ objects CS@AU Henrik Bærbak Christensen

Deployment In the code bases distributed, the client and server side classes are pooled into one big source tree src and src-lib In real deployments you need to split’em Server: Server side specific classes Core: Core domain interfaces and PODOs Client: Client side specific classes The client side deployment (Core + Client) The server side deployment (Core + Server) Simply easier in our teaching CS@AU Henrik Bærbak Christensen

The Process? How did I get there?

Henrik Bærbak Christensen Developing it All well – you see the final picture but how was it painted? Challenge: TDD of a distributed system? I cannot (easily) automate that a server needs to be running on some remote machine, can I? (well we can, but that is another course…) CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Exercise Which level hinders TDD??? And you know how to deal with it, right?!? What is the answer??? CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Principle 1+2+Doubles It is the IPC Level that hinders TDD But Programmed to an interface Object compose a Test Double into place instead!!! A Fake Object IPC CS@AU Henrik Bærbak Christensen

LocalMethodCall ClientRequestHandler Faking the IPC No need to start server. No concurrency. All aspects (except IPC) can be TDD’ed LocalMethodCall ClientRequestHandler CS@AU Henrik Bærbak Christensen

@Before Binding the Broker / Coupling the delegates together That is Link proxy to requestor, requestor to CRH double, CRH to invoker, and the Invoker to the servant object The only test double! Rest are production code! CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Make a Test Case Call client proxy, assert something stored in XDS CS@AU Henrik Bærbak Christensen

The IPC Level Talking network’ish

Henrik Bærbak Christensen Choosing IPC The most fundamental level Sockets More modern approach URI Tunneling using HTTP web servers Next lesson in next week ReST based CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Rule #1 Find stuff on the internet  Jakob Jenkov has fine tutorials on socket server programming Single thread Multi thread Thread pooled Question of concurrency Single thread Only one call at the time Multi thread Unlimited => Memory exhausted! Thread pool N threads = Best of both worlds CS@AU Henrik Bærbak Christensen

Client Request Handler Socket = ”file” Not tied to disk, but remote computer… The old HTTP protocol Create socket Send request Read reply Close socket Inefficient but reliable CS@AU Henrik Bærbak Christensen

Server Request Handler Jenkov single thread Accept incoming socket Read request Call invoker Send reply Close socket CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Summary CS@AU Henrik Bærbak Christensen