95-702 Distributed SystemsObjectivesReview from last weekSlide 4PowerPoint PresentationSlide 6Review: Examples of external data representation:Review: Generic Request-Reply message structureSlide 9Slide 10Slide 11What are the goals of Java RMI?Slide 13The traditional object model (OOP 101)The distributed object modelSlide 16Slide 17An important RMI design issueSlide 19Slide 20Slide 21Slide 22Slide 23Slide 24Registries promote space decouplingSlide 26Java RMISlide 28Slide 29Slide 30The proxy design pattern (used to talk to the service and the registry)A simple Java RMI clientSlide 33Notes about the client(1)Notes about the client(2)Notes about the client(3)Notes about the client(4)File client.policyNotes About the client(5)Files on the Server Product.javaNotes on Product InterfaceFiles on the Server ProductImpl.javaNotes on ProductImpl.javaFiles on the server ProductServer.javaSlide 45Notes on the ProductServer.javaSummary of ActivitiesParameter passing in remote methodsSlide 49Slide 50QuizJava RMI Example 2 - RMI WhiteboardClient DirectoryServer DirectoryGraphicalObject.javaSlide 56Shape.javaShapeServant.javaSlide 59ShapeList.javaShapeListServant.javaSlide 62Slide 63ShapeListServer.javaSlide 65ShapeListClient.javaSlide 67Slide 68Slide 69Slide 7095-702 Distributed SystemsDistributed Objects Using Java RMIObjectives•Understand distributed objects•Understand Java RMI•Be able to describe the functional and non-functional characteristics of distributed systems•Compare and contrast distributed objects with web services95-702 Distributed SystemsReview from last week•Web applications are built to interact with browsers•Web services are built to interact with clients that may or may not be associated with a browser•Web service API styles: RPC, Messaging and Resource95-702 Distributed SystemsReview from last week•Web service API styles: RPC, Messaging and Resource•RPC API’s use SOAP and include procedure names and parameters•Messaging API’s uses SOAP but includes a document to be handled on the server•Resource API’s take HTTP, URL’s Representations, and HATEOS seriously95-702 Distributed Systems5Review: What is Middleware?ApplicationsMiddlewarelayers Request reply protocolExternal data representationOperating SystemRMI, RPC and events95-702 Distributed Systems•Applications (clients and services) speak to the middleware.•TCP/IP is provided by the operating system.6Review: external data representation•External data representation – an agreed standard for the representation of data structures and primitive values •Marshalling – the process of taking a collection of data items and assembling them into a form suitable for transmission in a message•Unmarshalling – is the process of disassembling them on arrival into an equivalent representation at the destination•The marshalling and unmarshalling are intended to be carried out by the middleware layer 95-702 Distributed Systems7Review: Examples of external data representation:• CORBA’s CDR binary data may be used by different programming languages when CORBA middleware is present•Java RMI and .Net Remoting use object serialization. These are platform specific (that is, Java on both sides or .Net on both sides) and binary.•XML and JSON are primarily textual formats, verbose when compared to binary but interoperable. Why? Not tied to a particular language or machine architecture•In these slides, we are looking at Java RMI 95-702 Distributed Systems895-702 Distributed Systems95-702 Distributed Systems Information System Management 8Review: Generic Request-Reply message structuremessageTyperequestIdobjectReferencemethodIdargumentsint (0=Request, 1= Reply)intRemoteObjectRefint or Methodarray of bytes995-702 Distributed SystemsReview: generic remote object referenceInternet address port number time object numberinterface of remote object32 bits 32 bits 32 bits 32 bitsA remote object reference is an identifier for a remote object.May be returned by or passed to a remote method in Java RMI.How do these references differ from local references?10How would you build this?Dealer’s computerInformationproviderDealerExternalsourceExternalsourceInformationproviderDealerDealerDealerNotificationNotificationNotificationNotificationNotificationNotificationNotificationNotificationDealer’s computerDealer’s computerDealer’s computerNotificationNotification95-702 Distributed Systems11Alternative architectures for distributed event notificationsubscriberobserverobject of interestEvent serviceobject of interestobject of interest observersubscribersubscriber3.1.2.notificationnotificationnotificationnotification95-702 Distributed SystemsWhat are the goals of Java RMI?•Distributed Java •Almost the same syntax and semantics used by non-distributed applications•Promote separation of concerns – the implementation is separate from the interface •The transport layer is TCP/IP95-702 Distributed SystemsWhat is an IDL?•Definition: An interface definition language (IDL) provides a notation for defining interfaces in which each of the parameters of a method may be described as for input or output in addition to having its type specified.•These may be used to allow objects written in different languages to invoke one another.•In Java RMI, we use a Java interface.•See also WSDL, WADL, and AIDL95-702 Distributed SystemsThe traditional object model (OOP 101)• Each object is a set of data and a set of methods. • Object references are assigned to variables.• Interfaces define an object’s methods.• Actions are initiated by invoking methods.• Exceptions may be thrown for unexpected or illegal conditions.• Garbage collection may be handled by the developer (C++) or by the runtime (.NET and Java).•We want similar features in the distributed case 95-702 Distributed SystemsThe distributed object model• Having client and server objects in different processes enforces encapsulation. You must call a method to change its state.• Methods may be synchronized to protect against conflicting access by multiple clients.• Objects are accessed remotely through RMI or objects are copied to the local machine (if the object’s class is available locally) and used locally.• Remote object references are analogous to local ones in that: 1. The invoker uses the remote object reference to identify the object and 2. The remote object reference may be passed as
View Full Document