Software Engineering and Architecture

Slides:



Advertisements
Similar presentations
Systems Architecture Use Case Diagram, System Overview, Class Diagram Design Patterns (weve used) Refactorings (weve used) Table of Contents.
Advertisements

CMPT 401 Summer 2007 Dr. Alexandra Fedorova Lecture XVIII: Concluding Remarks.
Distributed Object & Remote Invocation Vidya Satyanarayanan.
PHP (2) – Functions, Arrays, Databases, and sessions.
Web Servers How do our requests for resources on the Internet get handled? Can they be located anywhere? Global?
N-Tier Architecture.
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
CS107 References and Arrays By Chris Pable Spring 2009.
Chapter 12 Review Chad Hagstrom CS 310 Spring 2008.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB Markus.
Mandatory 1 / AlphaCiv … Traps to be aware of …. Warn or not? I once asked Kent Beck the following –I have a lot of students in a course in design patterns.
Mandatory 1 / AlphaCiv … a few comments…. Overall: Generally – good work – good effort Seems you are generally doing TDD Minor hick-ups –”My own way is.
Channels. Models for Communications Synchronous communications – E.g. Telephone call Asynchronous communications – E.g. .
A service Oriented Architecture & Web Service Technology.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
RMI (Java RMI) P 460 in text UUIDs / system wide references Transparent: all objects either by ref. or by value. Not efficient, especially int, bool, etc.
Instantiating the MiniDraw Framework
Remote Procedure Calls
Cloud Computing and Architecuture
Summary prepared by Kirk Scott
N-Tier Architecture.
Web Development Web Servers.
CS 6560: Operating Systems Design
Remote Method Invocation
HotCiv Project Starting up!.
Submitting Requests to IT
Mandatory 1 / AlphaCiv … Traps to be aware of ….
Multiprocessor Cache Coherency
Error Handling Summary of the next few pages: Error Handling Cursors.
RFPMonkey.com External Review
Interfaces and Inheritance
Programming Models for Distributed Application
Interpreter Style Examples
The Object-Oriented Thought Process Chapter 05
Phil Tayco Slide version 1.0 Created Oct 9, 2017
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Lecture 1: Multi-tier Architecture Overview
Chapter 40 Remote Method Invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Outline Announcements Lab2 Distributed File Systems 1/17/2019 COP5611.
Channels.
Distribution Infrastructures
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
Lecture 6: RPC (exercises/questions)
Channels.
Outline Review of Quiz #1 Distributed File Systems 4/20/2019 COP5611.
Review of Previous Lesson
Channels.
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
Lecture 6: RPC (exercises/questions)
Lecture 7: RPC (exercises/questions)
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
MapReduce: Simplified Data Processing on Large Clusters
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Message Passing Systems
Presentation transcript:

Software Engineering and Architecture Broker II Object References

Henrik Bærbak Christensen TeleMed Limitations TeleMed was a three-wheeled bicycle  Only one object :TeleMedServant Only one class TeleMedServant Object id was given by domain Patients unique ID We need to ride an ‘ordinary bicycle’, like HotCiv Multiple objects Grid of Units Multiple classes Game, City, Unit, ... ‘new CityImpl()’ On the server! AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen New Case: GameLobby AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Roles AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Dynamics AU CS Henrik Bærbak Christensen

The Positive Viewpoint Let us approach the problem from the viewpoint of status: what does work on the ship? [Apolly 13 Movie ] What does Broker already handle Three Java interfaces in the GameLobby system Yep: We can make ClientProxies and Servants for the three roles GameLobby, FutureGame, Game Yep: Marshalling method names, arguments Yep: IPC, nothing new here either Invoker: Quite a few methods in the invoker, but Yep, we can do that – just put more if’s into the thing... AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen But... The culprit is the method call on client: On the server, createGame(), will create and return a FutureGame instance, but we cannot pass by reference. We can only pass by value Strings, integers, DTO/POJO, Record type (json stuff) On the client, we only can have ClientProxies, right? AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Revisit This is the deep and hard problem We create an object on the server (object reference to something on the java heap (=a memory address!))... But a memory address/object reference is only valid on the server A pass-by-value does not make sense in the heap of the client! :Server :FG :Client ? AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen The Insight The key insight is How does ClientProxies address their associate Servant objects? Through the ‘objectId’ So – the server must return a unique objectId of the object, not a reference to it the client proxy must create a proxy, and associate it with that particular objectId If you do not see this right away... It is because it is hard to see it  AU CS Henrik Bærbak Christensen

Client: GameLobbyProxy So, the ClientProxy code becomes That is, objectId replaces object reference AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen The Concept Concept: ClientProxy methods that return object references must Get an objectId from the server Create an appropriate ClientProxy, and assign that objectId to it AU CS Henrik Bærbak Christensen

ClientProxy Constructor That is, the objectId from the server must be assigned during client proxy construction, alas, in the constructor And it makes sense to also have a ‘getId()’ on the client proxy AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Server: Invoker The Invoker’s code is the normal one... But, - how do we assign a unique ID? Sigh – we have a new responsibility someone must have AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen I will assign it to... The Servant object That is: Servant objects will generate a unique objectId during construction; and provide a ‘getId()’ method... AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen But... The responsiblity could have been assigned elsewhere: The invoker that generates a unique UUID A Name Service that we ask to assign a UUID ... As usual in this course, each possible design decision have certain advantages and disadvantages Exercise: What disadvantage has my decision? Advantage? AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Server: Invoker Thus the Invoker must return this objectId then AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen A Comment Early Broker systems strove to achieve one ability: Transparency Ideally, you program as you normally do in OO, ignoring the fact that some objects where on the server Time has shown that transparency is not good! You need to be extremely aware when method invocations are remote and when not! Why? Failure modes! Remote calls fail!!! Performance! Remote calls are 2.000 times slower!!! Security! Someone nasty may listen in or modify calls!!! AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen A Comment So... ... Software architects must carefully and explicitly decide which method calls/objects are remote! Thus, adding the extra ‘generate ID’ behaviour in our remote objects are in line with this explicity... AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Next Issue ReCap But what happens when client uses the player1future? This is now a client side FutureGameProxy getJoinToken call... AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Next Issue But what happens when client uses the player1future? FutureGameProxy implementation is easy enough, the return type is just a String (pass by value) AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen But... In the Invoker? Someone is responsible for knowing the relation between objectId and actual servant object reference! name service  Someone is responsible for storing the relation. AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen So - Update I let the Invoker update a name service Refactoring pending: Rename ‘objectStorage’ in FRDS  AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Final Piece... Now Invoker code can be completed for handling the FutureGame’s getJoinToken method Retrieve the object reference based upon the objectId sent by the client side proxy Do the upcall on that particular object Marshall the return value and return back to ServerRequestHandl AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Discussion My name service, objectStorage, is an in-memory datastructure Does not work if server crashes  Does not work in case of horizontal scaling Production systems need to keep the name service directory in a tiered persistent system Database Slow RDB External cache Faster MemCached/Redis Internal cache Fastest MemCached/Redis AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Discussion Be aware that for given a given role... ... Not all methods are necessarily remote calls! Example: method getId() Servant ClientProxy AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Exercise Example: method getId() Exercise: Why is it extremely stupid to make the client side proxy ‘getId()’ into a remote method? Servant ClientProxy Because the client proxy needs its objectId in the request call, so it becomes ”to get my id, I need to send my id”. I have actually seen student solutions that do exactly that, sigh... AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Transparency Again Actually, you can (and should) do a lot of tricks in the proxy. Example: HotCiv GUI builds the world map by iterating 16x16 times ‘game.getTile()’ calls = 256 method calls. How often does the world tile set actually change? In our Civ clones the answer is : Never! Exercise: What can we do about that??? AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Summary Recipe: AU CS Henrik Bærbak Christensen