Distributed Objects SPL/ SPL 201 / 0 1

Similar documents
JAVA RMI. Remote Method Invocation

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A

RMI Case Study. A Typical RMI Application

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Desarrollo de Aplicaciones en Red RMI. Introduction. Considerations. Considerations. RMI architecture

Chapter 15: Distributed Communication. Sockets Remote Procedure Calls (RPCs) Remote Method Invocation (RMI) CORBA Object Registration

The UNIVERSITY of EDINBURGH. SCHOOL of INFORMATICS. CS4/MSc. Distributed Systems. Björn Franke. Room 2414

Remote Method Invocation

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION

Distributed Systems. 02r. Java RMI Programming Tutorial. Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017

Remote Procedure Call

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

Remote Objects and RMI

Distributed Systems COMP 212. Lecture 10 Othon Michail

Lecture VI: Distributed Objects. Remote Method Invocation

presentation DAD Distributed Applications Development Cristian Toma

Written by: Dave Matuszek

Remote Method Invocation in Java

5.4. Events and notifications

Info 408 Distributed Applications programming 2 nd semester of Credits: 5 Lecturer: Antoun Yaacoub Ph.D.

RMI. Remote Method Invocation. 16-Dec-16

IBD Intergiciels et Bases de Données

Reflection/RMI 4/28/2009

Distributed Programming in Java. Distribution (2)

Distributed Systems. 5. Remote Method Invocation

Generic architecture

5 Distributed Objects: The Java Approach

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

CS 5523 Operating Systems: Remote Objects and RMI

Message Passing vs. Distributed Objects. 5/15/2009 Distributed Computing, M. L. Liu 1

Questions and Answers. A. RMI allows us to invoke a method of java object that executes on another machine.

RMI. (Remote Method Invocation)

Remote Method Invocation

03 Remote invocation. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

55:182/22C:182. Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP)

Distributed Computing

RPC and RMI. 2501ICT Nathan

Chapter 4 Remote Procedure Calls and Distributed Transactions

Communication and Distributed Processing

15-498: Distributed Systems Project #1: Design and Implementation of a RMI Facility for Java

RMI (Remote Method Invocation) Over the year, there have been 3 different approaches to application development:

How are classes loaded into the Java Virtual Machine (JVM)? from the local file system (CLASSPATH). by an instance of ClassLoader

Remote Method Invocation R.M.I.

Programming with RMI Reminder

Communication and Distributed Processing

Distributed Information Systems

Last Class: RPCs. Today:

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

Remote Invocation Vladimir Vlassov and Johan Montelius

Distributed Systems Recitation 3. Tamim Jabban

Distributed Systems Lecture 2 1. External Data Representation and Marshalling (Sec. 4.3) Request reply protocol (failure modes) (Sec. 4.

Distributed Systems Theory 4. Remote Procedure Call. October 17, 2008

Grid Computing. Java Remote Method Invocation (RMI) RMI Application. Grid Computing Fall 2006 Paul A. Farrell 9/5/2006

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9,

Distributed Programming with RMI. Overview CORBA DCOM. Prepared By: Shiba R. Tamrakar

RMI Example RMI. CmpE 473 Internet Programming RMI

Agent and Object Technology Lab Dipartimento di Ingegneria dell Informazione Università degli Studi di Parma. Distributed and Agent Systems RMI

Last Class: RPCs. Today:

JAC444 - Lecture 11. Remote Method Invocation Segment 2 - Develop RMI Application. Jordan Anastasiade Java Programming Language Course

CSci Introduction to Distributed Systems. Communication: RPC In Practice

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Verteilte Systeme (Distributed Systems)

Component-Based Software Engineering

Lecture 17 Java Remote Method Invoca/on

CC755: Distributed and Parallel Systems

Distributed Objects. Chapter Distributing Objects Overview

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Distributed Software Systems

Distributed object component middleware I - Java RMI

Distributed object component middleware I - Java RMI


Project 1: Remote Method Invocation CSE 291 Spring 2016

Lecture 5: RMI etc. Servant. Java Remote Method Invocation Invocation Semantics Distributed Events CDK: Chapter 5 TVS: Section 8.3

RMI: Design & Implementation

IJESRT. http: //

Communication. Distributed Systems Santa Clara University 2016

Outline. Chapter 4 Remote Procedure Calls and Distributed Transactions. Remote Procedure Call. Distributed Transaction Processing.

Distributed Systems. The main method of distributed object communication is with remote method invocation

DISTRIBUTED COMPUTING

Remote Method Invocation

Last Class: Network Overview. Today: Distributed Systems

Dynamic code downloading using Java TM (Using the java.rmi.server.codebase Property)

CHAPTER - 4 REMOTE COMMUNICATION

COMP 6231 Distributed Systems Design. Tutorial 2 by Alexandre Hudon January 21 st, 2013

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

Java RMI Middleware Project

CORBA (Common Object Request Broker Architecture)

Communication Basics, RPC & RMI. CS403/534 Distributed Systems Erkay Savas Sabanci University

Object-Oriented Distributed Technology

BEAWebLogic Server and WebLogic Express. Programming WebLogic JNDI

Lecture 5: Object Interaction: RMI and RPC

BEA WebLogic. Server. Programming WebLogic RMI

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

Compaq Interview Questions And Answers

COMP 6231: Distributed System Design

Bharati Vidyapeeth s Institute of Computer Applications and Management A-4, Paschim Vihar, New Delhi-63.

A Typical RMI Application

REMOTE METHOD INVOCATION INTRODUCTION TO RMI, A JAVA API FOR RPC-STYLE INVOCATION OF REMOTE OBJECT METHODS

Transcription:

Distributed Objects 1

distributed objects objects which reside on different machines/ network architectures, benefits, drawbacks implementation of a remote object system 2

Why go distributed? large systems - avoid bottlenecks and single points of failure partition system into autonomic subsystems, self-contained Subsystem may be on different host, communicate by networking protocols 3

active object model objects reside on different RTE's send messages to one to another how objects communicate? remote method invocation: OO concept objects in different environments communicate=send messages 4

5

Distributed object applications do the following Locate remote objects - obtain references to remote objects. register remote objects with RMI's naming facility, the RMI registry. pass and return remote object references as part of remote invocations. 6

Distributed object applications do the following Communicate with remote objects. communication between remote objects handled by RMI. To programmer, looks similar to Java method invocations. 7

Distributed object applications do the following Load class definitions for objects that are passed around. mechanisms for loading object's class definitions and transmitting an object's data. 8

9

server calls the registry to associate (or bind) a name with a remote object. client looks up the remote object by its name in the server's registry and then invokes a method on it. RMI system uses an existing web server to load class definitions, from server to client and from client to server 10

RMI Architecture in Java framework for remote method invocation abstract subsystem A providing a service = interface interface used by subsystem, B, in a different JVM - invoke methods of A. 11

object becomes remote by implementing a remote interface, extends interface java.rmi.remote. each method declares java.rmi.remoteexception in throws clause, 12

Stub No copy of the implementation object in client Java virtual machine RMI passes a remote stub for a remote object. acts as local representative (proxy) for remote object - remote reference to client client invokes a method on local stub - method invocation on the remote object. 13

14

example class, representing a printing service. support printing lines of text sent other objects reside on different JVMs, on different hosts 15

interface of the service 16

remote interface supports remote method invocations 17

communication throws section 18

Service Implementation implementing the remote interface how class communicates remotely 19

Make the Service Available instantiate Object of class wait for messages from other RTE: 1. Instantiate LinePrinterImpl Object, L. 2. Make L available for remote invocations 3. Wait for remote invocations, and call the appropriate methods of L. 20

21

need to locate where on which host and JVM - printer object is located. process does not exit when the main function completes naming.rebind(name, object) - executor is created - waits for messages and executes 22

Naming Server keeps a mapping from abstract names, (strings) and their location class Naming - bind object to name and register with some name server. Naming.rebind("//names.cs.bgu.ac.il:2002/ALinePrinter", printer); 23

rebind arguments: Naming Server 1. URL - where to advertise the remote object and under what name 2. remote object (printer) URL: server + port + advertised object name: Host: names.cs.bgu.ac.il Port: 2002 Bind remote object to name: ALinePrinter. 24

Naming Server Anyone contacting the same name server and looking for ALineServer will be referred to the correct host. Ports contact a specific process on a host - host's name + port number name server implemented in Java 25

Naming Server invoke on command line prior to running PrintServer start the following command on the host (names.cs.bgu.ac.il): rmiregistry 2002 - started a naming server (rmiregistry) on port 2002 26

Skeleton Remote Object is now registered at the naming server. What happens when someone tries to contact remote Object? No code to handle remote invocations. just implemented LinePrinter interface 27

Java compiler creates a new class, the skeleton of our remote Object contains code for handling the communications aspects 28

Skeleton communication details: receiving requests for remote invocations calling methods of remote Object sending the replies Skeleton - special code generated automatically from java.rmi.server.unicastremoteobject implement interface inherited from java.rmi.remote 29

Skeleton code 30

Upon call Naming.rebind(uri, printer) : Create an instance of class LinePrinterSkel - skel. 1. Set skel.remoteobject = printer. 2. Assign local port to skel, on which skel receives incoming messages - PORT. 3. Contact naming server and register under requested name: the local host, on which our printer resides, PORT on which skeleton waits for messages 31

32

Writing a Client 33

Client side needs to know Interface implemented by remote Object. Naming server where remote Object is registered. Name under which the remote object is registered. 34

Client side asks for object, (representing remote object) registered as ALinePrinter. if no such object registered in name server, - java.rmi.notboundexception exception Naming.lookup returns object=stub - contacts remote object bound to "ALinePrinter", stub implements same interface as remote Object - LinePrinter interface! client invokes method print transparently 35

36

The Stub when we compiled LinePrinter interface, Java compiler created the stub for us 37

When we called Naming.lookup(uri), the following took place: naming server (uri) contacted and asked for the remote object (uri). naming server returns the address and port of the relevant skeleton. LinePrinterStub instantiated, with given address/port returned to the caller. 38

should the client need to hold, a priory, a copy of the LinePrinterStub class's code? 39

System Overview 40

Parameter Passing how arguments are passed to remote methods how return values are actually returned. 41

Serializable objects argument to, or return value from, a remote object primitive types remote objects non-remote objects that implement java.io.serializable interface. 42

Serialization process of converting an object into a format that can be stored saving an object onto file, memory transmit object across network serialization format: re-create an identical object in internal state to original object (clone). 43

Serialization: process of serializing an object is called deflating or marshaling an object Deserialization: opposite operation, extracting a data structure from a series of bytes, is (which is also called inflatingor unmarshalling). 44

reasons why objects are not serializable by default: Not all objects can be serialized example, a Thread object is tied to the state of the current JVM. Serialization allows access to nontransient private members of a class 45

Primitive Parameters passed/returned by value. RMI send parameter copy to remote method. return value's data is copied, and sent to the calling JVM. 46

Object Parameters passed object to remote method - RMI sends the object itself object passed by value RMI returns copy of the whole object to the calling program. Nontrivial: object refer to other Java objects in a complex graph-like structure different JVMs dont share heap memory 47

RMI must send the referenced object and all objects it references. Serialization: transform object into a linear format to sent over network flattens an object and any objects it references. Serialized objects can be de-serialized in remote JVM 48

Remote Object Parameters Passing objects by value has its own inefficiencies. referenced graph of objects is very large? large state to send across the network? network lag (delay) RMI can simulate a pass-by-reference arguments are not. remote method works with the original object. 49

receive a reference to a remote object, invoking Naming.lookup() remote object as a parameter or a return value 50

LinePrinter object is a return value of a remote method invocation. printer factory 51

52

53

what exactly is passed as a parameter when passing a remote object by reference? remote object's stub object. Stubs = network-aware references to remote objects; remote reference to a remote object java.rmi.remotestub objects are the manifestation of those remote references 54

all parameters in Java RMI are passed by value pass-by-remote-reference is only implemented for remote object which extends the UnicastRemoteObject class 55

a remote object reference is returned back to the server parameter of a method invocation. In this case, would the server work with the stub or the local implementation? 56

If an object implements a RemoteInterface but is not exported (does not extend UnicastRemoteObject), object will always be passed by value. it is possible to obtain a stub for that remote object via a call to the method java.rmi.server.remoteobject.tost ub 57

DVD example for parameter passing in RMI A DVD support the method fix which fixes it. simple DVD (Serializable) can be sent (copied) over the network DVD that supports remote fixing (a UnicastRemoteObject) only a reference (a stub) sent on the network, not the physical device (copied) 58

DVDRemoteFixer will act as server that can fix a simple DVD or a RemoteDVD. fix client will create instance of both kinds of DVDs and will send them to the DVDRemoteFixer twice each. for simple DVD - state is not saved (dvd doesnt know its fixed the second time) for RemoteDVD state is saved. 59

60

61

62

63

64

Summary of parameter passing in RMI primitive data types are passed by value. changes to data on remote host are not reflected at original host. to pass an object to a remote method by value, the object must implement the java.lang.serializable interface. changes to the object's copy will not propagate to the local object. 65

pass an object over the network by remote reference: must be an exported remote object (extend the UnicastRemoteObject), must implement a remote interface (which extends java.rmi.remote). stub for remote object will be serialized and passed to the remote host. remote host can use stub to invoke methods of our remote object. only one copy of the data at any time, which means that all hosts are updating the same data. 66